Search This Blog

Friday, October 2, 2009

OpenSource, GDB

You can also attach to a running process with gdb. i.e.

gdb firefox3 your_running_process_id

(gdb) quit – exit the debugger
(gdb) file – load an executable file
(gdb) break line-number/function name -- Set a break-point on a line/at start of function
(gdb) run -- start running the program; if there are command-line arguments, put them afterthe run invocation
(gdb) cont -- continue running, after a break
(gdb) next -- Next program line (step over function calls)
(gdb) step -- Step into function calls.
(gdb) finish - Step out of the present function
(gdb) print expression -- Show value of a variable or expression
(gdb) list – List 10 lines of the program being debugged. The sixth line is the preset statement. Subsequent, consecutive entry of list will list the next 10 lines.
(gdb) where – obtain a backtrace showing all function calls before the current statement
(gdb) up – Move to the function that called the present function. Useful if your program crashes in a library function; use up to get to the last function call in your program
(gdb) down – Reverses the action of up
(gdb) delete – Removes breakpoint by number (see example following). If no number, all deleted.
(gdb) kill – Terminates the program.

-----------------------
debug build under freebs

WITH_DEBUG is the variable you're interested in. It must be defined, so something like:

`make WITH_DEBUG=yes install`

should do the trick.

http://markmail.org/message/3kxvma6nd3wkeygb#query:how to build debug build of firefox in freebsd+page:1+mid:5ar2lxsf54imxkvd+state:results

how to build a debug freebsd environment

trap firefox with gdb

----------------------

Reference:
http://faculty.kutztown.edu/spiegel/Debugging/DebugPrimer.htm
http://betterexplained.com/articles/debugging-with-gdb/

No comments: