@ -656,3 +656,62 @@ async def test_stack_variable_names_from_dwarf(ctrl: Controller) -> None:
# Test that telescope shows variable names
telescope_out = await ctrl . execute_and_capture ( f " telescope { buffer_addr : #x } 1 " )
assert " {buffer} " in telescope_out
@pwndbg_test
async def test_regs_command_resolves_sp_pc_aliases ( ctrl : Controller ) - > None :
"""
If running ` regs pc ` or ` regs sp ` , these aliases should be resolved
to the real architectural names of the registers .
"""
import pwndbg . aglib . regs
await ctrl . launch ( REFERENCE_BINARY )
sp_name = pwndbg . aglib . regs . current . stack
pc_name = pwndbg . aglib . regs . current . pc
real_sp_value = pwndbg . aglib . regs . read_reg ( sp_name )
real_pc_value = pwndbg . aglib . regs . read_reg ( pc_name )
regs_sp_output = await ctrl . execute_and_capture ( " regs sp " )
regs_pc_output = await ctrl . execute_and_capture ( " regs pc " )
assert sp_name . upper ( ) in regs_sp_output
assert hex ( real_sp_value ) in regs_sp_output
assert pc_name . upper ( ) in regs_pc_output
assert hex ( real_pc_value ) in regs_pc_output
@pwndbg_test
async def test_cli_fixup_resolves_sp_pc_aliases ( ctrl : Controller ) - > None :
"""
CLI argument fixup should resolve " sp " and " pc " correctly .
Note :
The fixup process by default ( without any special handling of these aliases )
would just adds a " $ " infront of register names .
GDB reading $ sp and $ pc will internally handle the conversion , meaning this test
passes without any special logic in the register fixup .
However , this is not necessarily true of all underlying debuggers .
"""
import pwndbg . aglib . regs
await ctrl . launch ( REFERENCE_BINARY )
sp_name = pwndbg . aglib . regs . current . stack
pc_name = pwndbg . aglib . regs . current . pc
real_sp_value = pwndbg . aglib . regs . read_reg ( sp_name )
real_pc_value = pwndbg . aglib . regs . read_reg ( pc_name )
regs_sp_output = await ctrl . execute_and_capture ( " telescope sp 1 " )
regs_pc_output = await ctrl . execute_and_capture ( " telescope pc 1 " )
assert sp_name in regs_sp_output
assert hex ( real_sp_value ) in regs_sp_output
assert pc_name in regs_pc_output
assert hex ( real_pc_value ) in regs_pc_output