0
  1. What is the difference between b main and b *main in gdb?
  2. I want to find main return address using gdb.

Is it right?

(gdb) b main
(gdb) r
(gdb) x/x $esp
ks1322
  • 33,961
  • 14
  • 109
  • 164
Frodo
  • 36
  • 1
  • 7

1 Answers1

0

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).

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362