Questions tagged [gdb]

Use this tag for problems related to or involving GDB, the standard debugger for the GNU software system.

The GNU Debugger, usually called just GDB and named gdb as an executable file, is the standard debugger for the GNU software system. It is a portable debugger that runs on many Unix-like systems and Microsoft Windows variants. GDB works for many programming languages, including C, C++, D, Go, Objective-C, Fortran, Java, OpenCL C, Pascal, assembly, Modula-2, and Ada.

Related Resources

11325 questions
39
votes
1 answer

How to get ndk-gdb working on Android?

I'm trying to get the NDK debugger working but with no success so far. To make sure my debug symbols are present and valid, I use the compiler options -O0 and -g, and the ndk-build parameter NDK_DEBUG=1. The ndk-gdb script runs with out issues and…
Simplex
  • 930
  • 1
  • 9
  • 20
38
votes
3 answers

How to use GDB to find what function a memory address corresponds to

I am using google's heap checker to track down a memory leak. It gives me a stack trace such as: Leak of 21 bytes in 1 objects allocated from: …
Nathaniel Flath
  • 15,477
  • 19
  • 69
  • 94
38
votes
4 answers

How to disassemble the main function of a stripped application?

Let's say I compiled the application below and stripped it's symbols. #include int main() { printf("Hello\n"); } Build procedure: gcc -o hello hello.c strip --strip-unneeded hello If the application wasn't stripped, disassembling…
karlphillip
  • 92,053
  • 36
  • 243
  • 426
38
votes
3 answers

How to change the Python Interpreter that gdb uses?

I'm using ubuntu 14.04, where python3 is a default system package. I want to debug Python2.7 programs with gdb, but I seem to encounter this issue: When i'm in gdb, using the py command puts me in an interpreter, so i ran these commands in the…
vlad-ardelean
  • 7,480
  • 15
  • 80
  • 124
38
votes
1 answer

How do I jump to a breakpoint within GDB?

I set a breakpoint, which worked fine. Is there a way to jump immediately to that breakpoint without using "next" or "step"? Using "next" or "step", it takes really long to get to the final breakpoint.
Chris Smullian
  • 2,237
  • 4
  • 18
  • 8
37
votes
5 answers

gdb: exit program without exiting gdb

I am debugging a program using gdb. First I load my executable, then I continue to run the program. I sometimes want to interrupt execution of my program, so I do Ctrl + C. My problem is that this closes both my program and gdb. How can I exit my…
Randomblue
  • 112,777
  • 145
  • 353
  • 547
37
votes
1 answer

How do I enable reverse debugging on a multi-threaded program?

I'm trying to use the reverse debugging features of gdb 7.3.1 on a multi-threaded project (using libevent), but I get the following error: (gdb) reverse-step Target multi-thread does not support this command. From this question, I thought perhaps…
rps
  • 1,263
  • 3
  • 13
  • 18
37
votes
1 answer

Can we define a new data type in a GDB session

Is there a way to define a new data type (C structure or union) in gdb. The idea is to define a structure and then make gdb print data from an address interpreted as the newly defined structure. For example, lets say we have a sample…
aufather
  • 651
  • 2
  • 7
  • 9
37
votes
3 answers

gdb with assembler: Print status of carry flag

I've got an x86 assembler program which I'm debugging with gdb. Is there a way to print the status of the carry flag inside gdb with, like, "print $cf"?
Hinton
  • 2,320
  • 4
  • 26
  • 32
37
votes
6 answers

Use GDB to debug a C++ program called from a shell script

I have a extremely complicated shell script, within which it calls a C++ program I want to debug via GDB. It is extremely hard to separate this c++ program from the shell since it has a lot of branches and a lot of environmental variables setting.…
CuriousMind
  • 15,168
  • 20
  • 82
  • 120
37
votes
6 answers

GDB breakpoints

I have a list of breakpoints which I want to add each time I debug a particular program. Is there a way I can put all of the breakpoint information in a file and use it at the start of each debug session? In other words can I provide a script file…
Sachin Khot
  • 1,412
  • 2
  • 14
  • 18
36
votes
5 answers

Program received signal SIGTRAP, Trace/breakpoint trap

I'm debugging a piece of (embedded) software. I've set a breakpoint on a function, and for some reason, once I've reached that breakpoint and continue I always come back to the function (which is an initialisation function which should only be…
Randomblue
  • 112,777
  • 145
  • 353
  • 547
36
votes
4 answers

How to install gdb on MacOS terminal Sierra

I searched online about how to install gdb on macOS Sierra 10.12.2 but failed on the methods I could find. Then I figure out the following way which is easy and works fine on my machine. hope it may help you too:)
aFactoria
  • 917
  • 1
  • 8
  • 7
36
votes
1 answer

How to read and execute GDB commands from a file?

I run GDB on object file (e.g exeFile) and I want to examine it according to several commands . How can I execute these commands according to lines in a file (instead input these each GDN running) ? For example - I want to set break in - break…
URL87
  • 10,667
  • 35
  • 107
  • 174
36
votes
9 answers

What is a good unix alternative to DDD (Data Display Debugger)?

I am developing c on linux using vim and debugging using ddd. However I find that ddd performs very poorly at scrolling on this machine so its sometimes very frustrating to use. I like the way that ddd maps fairly closely to the gdb command set as…
frankster
  • 1,529
  • 2
  • 16
  • 20