- What is the difference between
b main
andb *main
in gdb? - I want to find
main
return address using gdb.
Is it right?
(gdb) b main
(gdb) r
(gdb) x/x $esp
Is it right?
No.
This would be correct if you used b *main
(on 32-bit i*86
host), but not if you use b main
.
As this answer explains, the former sets a breakpoint in the first instruction of main
(when the stack pointer still points just below the return address pushed by the CALL
instruction), the latter on the first instruction after function prolog (at which point several other values have likely been pushed onto the stack).