fix: show "x" when the condition instruction will not be taken (#3027)

* fix: show "x" when the condition instruction will not be taken

Fixes #3025

* Update disasm.py

* Update disasm.py

* Update disasm.py

* Fix X marker in cross-arch tests (aarch64, riscv64)
pull/3048/head
Disconnect3d 6 months ago committed by GitHub
parent effa016b33
commit 04b209925a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -13,6 +13,7 @@ from pwndbg.color import ColorConfig
from pwndbg.color import ColorParamSpec
from pwndbg.color import ljust_colored
from pwndbg.color import strip
from pwndbg.color.message import off
from pwndbg.color.message import on
c = ColorConfig(
@ -41,8 +42,10 @@ def one_instruction(ins: PwndbgInstruction) -> str:
# If we know the conditional is taken, mark it as taken.
if ins.condition == InstructionCondition.TRUE or ins.is_conditional_jump_taken:
asm = on("") + asm
elif ins.condition == InstructionCondition.FALSE:
asm = off("") + asm
else:
asm = " " + asm
asm = f" {asm}"
return asm

@ -219,7 +219,7 @@ def test_aarch64_conditional_jump_output(qemu_assembly_run):
" 0x1010140 <C> ✔ tbnz w2, #3, D <D>\n"
"\n"
" 0x1010148 <D> cmp x2, x3 0xa - 0x0 CPSR => 0x20000000 [ n z C v q pan il d a i f el:0 sp ]\n"
" 0x101014c <D+4> b.eq E <E>\n"
" 0x101014c <D+4> b.eq E <E>\n"
" \n"
" 0x1010150 <D+8> nop \n"
" 0x1010154 <E> ✔ b.ne F <F>\n"

@ -185,12 +185,12 @@ def test_riscv64_jumps(qemu_assembly_run):
"───────────────────────[ DISASM / rv64 / set emulate on ]───────────────────────\n"
" ► 0x1001158 <_start> c.li t0, 4 T0 => 4\n"
" 0x100115a <_start+2> c.li t1, 5 T1 => 5\n"
" 0x100115c <_start+4> beq t0, t1, 6 <first>\n"
" 0x100115c <_start+4> beq t0, t1, 6 <first>\n"
" \n"
" 0x1001160 <_start+8> c.nop \n"
" 0x1001162 <first> ✔ bne t0, t2, 6 <second>\n"
"\n"
" 0x1001168 <second> blt t0, t3, 6 <third>\n"
" 0x1001168 <second> blt t0, t3, 6 <third>\n"
" \n"
" 0x100116c <second+4> c.nop \n"
" 0x100116e <third> ✔ bge t0, t4, 6 <fourth>\n"
@ -215,12 +215,12 @@ def test_riscv64_jumps(qemu_assembly_run):
"LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA\n"
"───────────────────────[ DISASM / rv64 / set emulate on ]───────────────────────\n"
" 0x100115a <_start+2> c.li t1, 5 T1 => 5\n"
" 0x100115c <_start+4> beq t0, t1, 6 <first>\n"
" 0x100115c <_start+4> beq t0, t1, 6 <first>\n"
" \n"
" 0x1001160 <_start+8> c.nop \n"
" 0x1001162 <first> ✔ bne t0, t2, 6 <second>\n"
"\n"
" 0x1001168 <second> blt t0, t3, 6 <third>\n"
" 0x1001168 <second> blt t0, t3, 6 <third>\n"
" \n"
" ► 0x100116c <second+4> c.nop \n"
" 0x100116e <third> ✔ bge t0, t4, 6 <fourth>\n"

Loading…
Cancel
Save