Some tips of GDB

November 10th, 2006 mysurface Posted in Developer, gdb | Hits: 20898 | 5 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


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

5 Responses to “Some tips of GDB”

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

  2. [...] More tips of GDB? Check out Some tips of GDB. [...]

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

  4. If not, ask any queries you could possibly have prior to you
    signing preparer the
    book was packed with blatant lies that seem so obvious as well as comic in retrospect.

  5. Need for Speed ShiftThe simcity buildit cheats most addicitve racing game of 2008.

Leave a Reply