hugsy / gef-extras

Extra goodies for GEF to (try to) make GDB suck even less
https://hugsy.github.io/gef-extras
MIT License
149 stars 50 forks source link

Cannot print stack frame using `stack-view` when in main method #66

Closed noahboegli closed 2 years ago

noahboegli commented 2 years ago

I'm having a small issue when willing to display the stack being in the main method.

It would seem that this condition is executed when main's stackframe is selected: https://github.com/hugsy/gef-extras/blob/3d83535d3626226a2d995e4fa09e5823b7725b24/scripts/stack.py#L18-L22

Which does not make sense to me, because when I execute info frame, it clearly shows that the frame has a calling frame (thus frame.older() should not return None)

Stack level 0, frame at 0xffffce20: eip = 0x804863e in simple_echo; saved eip = 0x8048700 called by frame at 0xffffcff0 Arglist at 0xffffce18, args: Locals at 0xffffce18, Previous frame's sp is 0xffffce20 Saved registers: ebp at 0xffffce18, eip at 0xffffce1c

Edit: After a bit more investigation, I have found a way to fix it and proposed a PR (#67), the spoiler below contains the former content of the issue

Click to expand There is probably an easy fix but I'm not at ease with the Python-GDB API and I have not been able to work around it. The only issue I'm not able to fix is finding the stack HI adress without using the calling frame SP: ```python # Could something like this exist? stack_hi = align_address(int(frame.read_register("bp"))) ``` If someone has the code to find the HI address of the frame, I'm open to make a PR.