Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
cc4c1adf
Commit
cc4c1adf
authored
Jan 27, 2017
by
Damien George
Browse files
py/showbc: Make sure to set the const_table before printing bytecode.
parent
4614403f
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/bc.h
View file @
cc4c1adf
...
...
@@ -94,9 +94,9 @@ mp_code_state_t *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, s
struct
_mp_obj_fun_bc_t
;
void
mp_setup_code_state
(
mp_code_state_t
*
code_state
,
struct
_mp_obj_fun_bc_t
*
self
,
size_t
n_args
,
size_t
n_kw
,
const
mp_obj_t
*
args
);
void
mp_bytecode_print
(
const
void
*
descr
,
const
byte
*
code
,
mp_uint_t
len
,
const
mp_uint_t
*
const_table
);
void
mp_bytecode_print2
(
const
byte
*
code
,
mp_uint_t
le
n
);
void
mp_bytecode_print2
(
const
byte
*
code
,
size_t
len
,
const
mp_uint_t
*
const_tab
le
);
const
byte
*
mp_bytecode_print_str
(
const
byte
*
ip
);
#define mp_bytecode_print_inst(code) mp_bytecode_print2(code, 1)
#define mp_bytecode_print_inst(code
, const_table
) mp_bytecode_print2(code, 1
, const_table
)
// Helper macros to access pointer with least significant bits holding flags
#define MP_TAGPTR_PTR(x) ((void*)((uintptr_t)(x) & ~((uintptr_t)3)))
...
...
py/showbc.c
View file @
cc4c1adf
...
...
@@ -82,7 +82,6 @@ const mp_uint_t *mp_showbc_const_table;
void
mp_bytecode_print
(
const
void
*
descr
,
const
byte
*
ip
,
mp_uint_t
len
,
const
mp_uint_t
*
const_table
)
{
mp_showbc_code_start
=
ip
;
mp_showbc_const_table
=
const_table
;
// get bytecode parameters
mp_uint_t
n_state
=
mp_decode_uint
(
&
ip
);
...
...
@@ -159,7 +158,7 @@ void mp_bytecode_print(const void *descr, const byte *ip, mp_uint_t len, const m
printf
(
" bc="
INT_FMT
" line="
UINT_FMT
"
\n
"
,
bc
,
source_line
);
}
}
mp_bytecode_print2
(
ip
,
len
-
0
);
mp_bytecode_print2
(
ip
,
len
-
0
,
const_table
);
}
const
byte
*
mp_bytecode_print_str
(
const
byte
*
ip
)
{
...
...
@@ -547,8 +546,9 @@ const byte *mp_bytecode_print_str(const byte *ip) {
return
ip
;
}
void
mp_bytecode_print2
(
const
byte
*
ip
,
mp_uint_t
le
n
)
{
void
mp_bytecode_print2
(
const
byte
*
ip
,
size_t
len
,
const
mp_uint_t
*
const_tab
le
)
{
mp_showbc_code_start
=
ip
;
mp_showbc_const_table
=
const_table
;
while
(
ip
<
len
+
mp_showbc_code_start
)
{
printf
(
"%02u "
,
(
uint
)(
ip
-
mp_showbc_code_start
));
ip
=
mp_bytecode_print_str
(
ip
);
...
...
py/vm.c
View file @
cc4c1adf
...
...
@@ -38,8 +38,7 @@
#include
"py/bc.h"
#if 0
//#define TRACE(ip) printf("sp=" INT_FMT " ", sp - code_state->sp); mp_bytecode_print2(ip, 1);
#define TRACE(ip) printf("sp=%d ", sp - code_state->sp); mp_bytecode_print2(ip, 1);
#define TRACE(ip) printf("sp=%d ", (int)(sp - code_state->sp)); mp_bytecode_print2(ip, 1, code_state->const_table);
#else
#define TRACE(ip)
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment