Some tips of GDB
November 10th, 2006 mysurface Posted in Developer, gdb | Hits: 16269 | 3 Comments »
Usually people uses gdb to debug when obtain core dump file. A very common error that trigger core dump is segmentation fault happen, check out this example to get more idea regarding core dump, and gdb. Additional link, here is a great tutorial shows you how to debug when occur segmentation fault.
This post is to show you some tips while using gdb. To run gdb with on an errornous program, do this:
gdb program-name
1. To run shell command in gdb, let say I wanna make clean and make again.
shell make clean;make
2. Auto complete feature by hitting <Tab>, let say I wanna break at a function in class Client, I can see the alternatives symbols like this
b Client.<Tab><Tab>
[b is also known as break]
3. To get help in gdb. Gdb have plenty of command, usually people uses help to search for the command info.
help break
Alternatively what if you do not know the command name, you can search for keyword using apropos.
apropos backward
This will return
reverse-search -- Search backward for regular expression (see regex(3)) from last line listed
tfind -- Select a trace frame;
You can also list all the commands available by giving initial
complete b
It returns
backtrace
break
bt
4. Threads, If your program have multiple threads, you can check out them like this
info threads
And you can get into the thread by
thread 2
to go to thread #2.
If you are seriously wanna use gdb, remember to read this, It is a very complete documentation regarding gdb.
Okay, I have to get back to my debugging @.@







November 10th, 2006 at 10:16 pm
A couple of suggestions:
1. It would be great to mention about compiling with debug symbol in your example. (gcc -g ….). This would facilitate the process of debugging.
2. Alternatively, you can refer “info gdb” instead of going to the online link.
April 9th, 2007 at 12:39 am
[...] More tips of GDB? Check out Some tips of GDB. [...]
April 10th, 2013 at 11:46 am
I can testify that you will be an expert at your field! I would be launching a web site quite soon, and your material are going to be really useable for me. Numerous thanks for all your help and wishing you all the success within your company enterprise.