Skip to content

Commit 8bf8404

Browse files
committed
showbc: Print code block header at the beginning, not in the middle of dump.
Also, dump code block in bytes.
1 parent b325d25 commit 8bf8404

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

py/showbc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ void mp_bytecode_print(const byte *ip, int len) {
6464
const byte *code_info = ip;
6565
ip += code_info_size;
6666

67+
qstr source_file = code_info[4] | (code_info[5] << 8) | (code_info[6] << 16) | (code_info[7] << 24);
68+
qstr block_name = code_info[8] | (code_info[9] << 8) | (code_info[10] << 16) | (code_info[11] << 24);
69+
printf("File %s, code block '%s' (%d bytes)\n", qstr_str(source_file), qstr_str(block_name), len);
70+
6771
// bytecode prelude: state size and exception stack size; 16 bit uints
6872
{
6973
uint n_state = ip[0] | (ip[1] << 8);
@@ -87,9 +91,6 @@ void mp_bytecode_print(const byte *ip, int len) {
8791

8892
// print out line number info
8993
{
90-
qstr source_file = code_info[4] | (code_info[5] << 8) | (code_info[6] << 16) | (code_info[7] << 24);
91-
qstr block_name = code_info[8] | (code_info[9] << 8) | (code_info[10] << 16) | (code_info[11] << 24);
92-
printf("File %s, block '%s'\n", qstr_str(source_file), qstr_str(block_name));
9394
machine_int_t bc = (code_info + code_info_size) - ip;
9495
machine_uint_t source_line = 1;
9596
printf(" bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);

0 commit comments

Comments
 (0)