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
41
votes
3 answers

What causes a Sigtrap in a Debug Session

In my c++ program I'm using a library which will "send?" a Sigtrap on a certain operations when I'm debugging it (using gdb as a debugger). I can then choose whether I wish to Continue or Stop the program. If I choose to continue the program works…
zitroneneis
  • 1,037
  • 1
  • 12
  • 21
41
votes
8 answers

How to install gdb (debugger) in Mac OSX El Capitan?

How to install gdb (debugger) in Mac OSX El Capitan ? I have tried installing gdb but failed couple of time. I was following this URL : http://ntraft.com/installing-gdb-on-os-x-mavericks/ , MAC doesnot allow to install MacPorts. Could anyone please…
Tauheed Khan Mohd
  • 513
  • 1
  • 4
  • 6
41
votes
6 answers

How to debug the Linux kernel with GDB and QEMU?

I'm new to kernel development and I would like to know how to run/debug the linux kernel using QEMU and gdb. I'm actually reading Robert Love's book but unfortunately it doesn't help the reader on how to install proper tools to run or debug the…
E-Kami
  • 2,529
  • 5
  • 30
  • 50
40
votes
4 answers

Debugging: stepping through Python script using gdb?

Let's say we have the following mega-simple Python script: print "Initializing".... a=10 print "Variable value is %d" % (a) print "All done!" ... and say, I'd like to debug this script by placing a breakpoint at line a=10, and then stepping…
sdaau
  • 36,975
  • 46
  • 198
  • 278
40
votes
1 answer

How to create special files of type socket?

I need to create serial port socket for kgdb-gdb remote connection. Just as mkfifo creates a FIFO on your system, how can we create socket files?
Sandeep Singh
  • 4,941
  • 8
  • 36
  • 56
40
votes
8 answers

Invoke gdb to automatically pass arguments to the program being debugged

I'd like to write a script that (under certain conditions) will execute gdb and automatically run some program X with some set of arguments Y. Once the program has finished executing the user should remain at gdb's prompt until s/he explicitly…
user41162
  • 403
  • 1
  • 4
  • 4
40
votes
3 answers

How to continue one thread at a time when debugging a multithreaded program in GDB?

I have a program which uses two threads. I have put the break point in both the threads. While running the program under gdb I want to switch between the threads and make them run. (thread t1 is active and running and thread t2; when paused on the…
Arpit
  • 4,259
  • 10
  • 38
  • 43
40
votes
3 answers

Gdb dump memory in specific region, save formatted output into a file

I have a buggy (memory leaked) software. As an evidence, I have 1GB of core.dump file. Heap size is 900MB, so obviously, something allocates, but does not free the memory. So, I have a memory region to examine like this. (gdb) x/50000s…
dragonfry
  • 805
  • 1
  • 7
  • 11
40
votes
2 answers

C++ GDB Python Pretty Printing Tutorial?

I am looking for a solid tutorial on creating a custom printer. There are a few sparse pages on the GDB page however they are far from complete and leave much to the imagination! For instance, I'd love to be able to create a PrettyPrinter for our…
Setheron
  • 3,520
  • 3
  • 34
  • 52
39
votes
9 answers

How do you start running the program over again in gdb with 'target remote'?

When you're doing a usual gdb session on an executable file on the same computer, you can give the run command and it will start the program over again. When you're running gdb on an embedded system, as with the command target localhost:3210, how do…
jfm3
  • 36,964
  • 10
  • 32
  • 35
39
votes
5 answers

Switching to assembly in gdb

Is there is any way to switch to assembly when debugging a C or C++ program in gdb ? (Given that all source files and their corresponding assembly files are available)
Ben
  • 7,372
  • 8
  • 38
  • 46
39
votes
6 answers

GDB: Ctrl+C doesn't interrupt process as it usually does but rather terminates the program

Normally when you run a program through GDB you can press Ctrl+C to interrupt it, e.g. if it gets stuck in an infinite loop and you want to get a backtrace. I'm debugging a program (xmms2d as it happens) but in this program only, when I press Ctrl+C…
Malvineous
  • 25,144
  • 16
  • 116
  • 151
39
votes
4 answers

gdb backtrace with no user input?

I'm wondering if it's possible to launch an application via GDB, on a SegFault write the backtrace to a file (to look at later), and then exit GDB all without any user input. I'm running an application from a shell script in an infinite loop (so if…
Matt Razza
  • 3,524
  • 2
  • 25
  • 29
39
votes
4 answers

Multi-threaded debugging tutorial for GDB and C

Does anybody know of a good GDB (or other Linux debugger) tutorial for debugging multi-threaded C code? I'm looking for one that includes simple examples.
Josh
  • 391
  • 1
  • 3
  • 3
39
votes
0 answers

Difference between gdb, valgrind, strace, ltrace and apport

I'm looking for the difference between the following debugging tools. What are those? E: On the off chance that somebody stumbles in here and was wondering about the same thing the "differences" are (shortened from the man pages): GDB Allows you to…
Det
  • 3,640
  • 5
  • 20
  • 27