Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to force gdb to stop right after the start of program execution?

Tags:

debugging

gdb

I've tried to set breakpoint on every function that makes any sense but program exit before reaching any of those. Is there a way to make program run in step-by-step mode from the start so I can see what's going on?

I'm trying to debug /usr/bin/id if it's important (we have custom plugin for it and it's misbehaved)

P.S. Start command doesn't work for me here(it should be a comment, but I don't have enough rep for it)

like image 900
Mendor Avatar asked Sep 09 '13 08:09

Mendor


1 Answers

Get the program entry point address and insert a breakpoint at that address.

One way to do this is to do info files which gives you for example "Entry point: 0x4045a4". Then do "break *0x4045a4". After run-ning program, it will immediately stop.

From here on you can use single stepping instructions (like step or stepi) to proceed.

You did not tell what system you are trying to debug. If code is in read-only memory you may need to use hardware breakpoints (hbreak) if they are supported by that system.

like image 96
dbrank0 Avatar answered Nov 01 '22 09:11

dbrank0