Skip to content

Commit

Permalink
Fix arguments alignment in PYC disassembler (#3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
borzacchiello authored Jun 11, 2023
1 parent b52ebcc commit d0426f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion librz/asm/arch/pyc/pyc_dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int rz_pyc_disasm(RzAsmOp *opstruct, const ut8 *code, RzList /*<pyc_code_object
}
const char *arg = parse_arg(&ops->opcodes[op], oparg, names, consts, varnames, freevars, cellvars, ops->opcode_arg_fmt);
if (arg != NULL) {
rz_strbuf_appendf(&opstruct->buf_asm, "%20s", arg);
rz_strbuf_setf(&opstruct->buf_asm, "%-22s%s", name, arg);
free((char *)arg);
}
} else if (ops->bits == 8) {
Expand Down
56 changes: 28 additions & 28 deletions test/db/formats/pyc
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,17 @@ EXPECT=<<EOF
;-- entry0:
;-- section.module:
;-- <module>:
0x0000002e LOAD_CONST Multiline strings can be written
0x0000002e LOAD_CONST Multiline strings can be written
using three "s, and are often used
as documentation. ; [00] ---- section size 3248 named module
0x00000030 STORE_NAME __doc__
0x00000032 LOAD_CONST True
,=< 0x00000034 JUMP_IF_FALSE_OR_POP 10
| 0x00000036 LOAD_CONST False
0x00000030 STORE_NAME __doc__
0x00000032 LOAD_CONST True
,=< 0x00000034 JUMP_IF_FALSE_OR_POP 10
| 0x00000036 LOAD_CONST False
`-> 0x00000038 POP_TOP
0x0000003a LOAD_CONST False
,=< 0x0000003c JUMP_IF_TRUE_OR_POP 18
| 0x0000003e LOAD_CONST True
0x0000003a LOAD_CONST False
,=< 0x0000003c JUMP_IF_TRUE_OR_POP 18
| 0x0000003e LOAD_CONST True
`-> 0x00000040 POP_TOP
EOF
REGEXP_FILTER_ERR=<<EOF
Expand All @@ -203,17 +203,17 @@ EXPECT=<<EOF
;-- entry0:
;-- section.module:
;-- <module>:
0x0000002a LOAD_CONST Multiline strings can be written
0x0000002a LOAD_CONST Multiline strings can be written
using three "s, and are often used
as documentation. ; [00] ---- section size 3218 named module
0x0000002c STORE_NAME __doc__
0x0000002e LOAD_CONST True
,=< 0x00000030 JUMP_IF_FALSE_OR_POP 10
| 0x00000032 LOAD_CONST False
0x0000002c STORE_NAME __doc__
0x0000002e LOAD_CONST True
,=< 0x00000030 JUMP_IF_FALSE_OR_POP 10
| 0x00000032 LOAD_CONST False
`-> 0x00000034 POP_TOP
0x00000036 LOAD_CONST False
,=< 0x00000038 JUMP_IF_TRUE_OR_POP 18
| 0x0000003a LOAD_CONST True
0x00000036 LOAD_CONST False
,=< 0x00000038 JUMP_IF_TRUE_OR_POP 18
| 0x0000003a LOAD_CONST True
`-> 0x0000003c POP_TOP
EOF
REGEXP_FILTER_ERR=<<EOF
Expand Down Expand Up @@ -249,16 +249,16 @@ EXPECT=<<EOF
;-- entry0:
;-- section.module:
;-- <module>:
0x0000001e LOAD_CONSTCodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module
0x0000001e LOAD_CONST CodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module
0x00000021 MAKE_FUNCTION
0x00000024 STORE_NAME hello_world
0x00000027 LOAD_CONST 'world'
0x00000024 STORE_NAME hello_world
0x00000027 LOAD_CONST 'world'
0x0000002a PRINT_ITEM
0x0000002b PRINT_NEWLINE
0x0000002c LOAD_NAME hello_world
0x0000002f CALL_FUNCTION0 positional, 0 named
0x0000002c LOAD_NAME hello_world
0x0000002f CALL_FUNCTION 0 positional, 0 named
0x00000032 POP_TOP
0x00000033 LOAD_CONST None
0x00000033 LOAD_CONST None
EOF
REGEXP_FILTER_ERR=<<EOF
free_object\ \(0\)
Expand All @@ -279,16 +279,16 @@ EXPECT=<<EOF
;-- section.module:
;-- <module>:
/ entry0();
| 0x0000001e LOAD_CONSTCodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module
| 0x0000001e LOAD_CONST CodeObject(hello_world) from hello.py ; [00] ---- section size 25 named module
| 0x00000021 MAKE_FUNCTION
| 0x00000024 STORE_NAME hello_world
| 0x00000027 LOAD_CONST 'world'
| 0x00000024 STORE_NAME hello_world
| 0x00000027 LOAD_CONST 'world'
| 0x0000002a PRINT_ITEM
| 0x0000002b PRINT_NEWLINE
| 0x0000002c LOAD_NAME hello_world
| 0x0000002f CALL_FUNCTION0 positional, 0 named
| 0x0000002c LOAD_NAME hello_world
| 0x0000002f CALL_FUNCTION 0 positional, 0 named
| 0x00000032 POP_TOP
| 0x00000033 LOAD_CONST None
| 0x00000033 LOAD_CONST None
\ 0x00000036 RETURN_VALUE
EOF
REGEXP_FILTER_ERR=<<EOF
Expand Down

0 comments on commit d0426f9

Please sign in to comment.