ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Change default behavior when emulating in new trace to set the current context's stack pointer

Open sadeli413 opened this issue 1 year ago • 1 comments

Current behavior When setting registers at an address 0x08049196 in the register manager, the emulator will apply those registers when I Emulate program in new trace at that address. All general purpose registers will be applied except for the stack pointer. image

By default the stack pointer will be set to some arbitrary value. In this example, it's set to 0x5000 but my register manager has the stack pointer set to 0xffffd2bc. The address 0xffffd2bc is inside a valid and initialized block in my Memory map. image

Desired behavior When starting the emulator at an address that has the stack pointer set in the register manager, I'd like the emulator to use that stack pointer by default, rather than having to manually editing the stack pointer after I start the new trace

sadeli413 avatar Apr 15 '24 21:04 sadeli413

That's a decent idea.

FWIW, an alternative is to create an uninitialized block called "STACK" in the Memory Map. The SP should get initialized to the highest address (maybe +1) in that block. Granted, that winds up applying to the entire program rather than just the specific function.

nsadeveloper789 avatar May 08 '24 18:05 nsadeveloper789