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
646
votes
9 answers

How do I run a program with commandline arguments using GDB within a Bash script?

When running a program on GDB, usually, the arguments for the program are given at the run command. Is there a way to run the program using GDB and as well as give arguments within a shell script? I saw an answer in a related question, mentioning…
drox
  • 7,523
  • 4
  • 23
  • 34
449
votes
6 answers

How do I print the full value of a long string in gdb?

I want to print the full length of a C-string in GDB. By default it's being abbreviated, how do I force GDB to print the whole string?
John Carter
  • 53,924
  • 26
  • 111
  • 144
423
votes
3 answers

Printing all global variables/local variables?

How can I print all global variables/local variables? Is that possible in gdb?
cpuer
  • 7,413
  • 14
  • 35
  • 39
276
votes
2 answers

Core dump file analysis

What are all the things I will need to check while analyzing a core dump file? Please tell me from scratch.
Dew
  • 2,993
  • 5
  • 17
  • 7
268
votes
6 answers

Can I set a breakpoint on 'memory access' in GDB?

I am running an application through gdb and I want to set a breakpoint for any time a specific variable is accessed / changed. Is there a good method for doing this? I would also be interested in other ways to monitor a variable in C/C++ to see…
TJ Seabrooks
  • 20,203
  • 6
  • 33
  • 30
247
votes
3 answers

How can I make gdb save the command history?

How can I set up gdb so that it saves the command history? When starting a new gdb session I'd like to use the arrow up keys to access the commands of the previous sessions.
Frank
  • 64,140
  • 93
  • 237
  • 324
239
votes
7 answers

How to print register values in GDB?

How do I print the value of %eax and %ebp? (gdb) p $eax $1 = void
assem
  • 3,023
  • 4
  • 20
  • 20
238
votes
5 answers

How do I print the elements of a C++ vector in GDB?

I want to examine the contents of a std::vector in GDB, how do I do it? Let's say it's a std::vector for the sake of simplicity.
John Carter
  • 53,924
  • 26
  • 111
  • 144
227
votes
8 answers

Show current assembly instruction in GDB

I'm doing some assembly-level debugging in GDB. Is there a way to get GDB to show me the current assembly instruction in the same way that it shows the current source line? The default output after every command looks like this: 0x0001433f 990 …
JSBձոգչ
  • 40,684
  • 18
  • 101
  • 169
225
votes
4 answers

How do I get the backtrace for all the threads in GDB?

Is there an equivalent command in GDB to that of WinDbg's !process 0 7? I want to extract all the threads in a dump file along with their backtraces in GDB. info threads doesn't output the stack traces. So, is there a command that does?
srikantha ks
  • 2,251
  • 2
  • 13
  • 3
223
votes
28 answers

Is there a C++ gdb GUI for Linux?

Briefly: Does anyone know of a GUI for gdb that brings it on par or close to the feature set you get in the more recent version of Visual C++? In detail: As someone who has spent a lot of time programming in Windows, one of the larger stumbling…
HappyDude
  • 2,566
  • 3
  • 18
  • 14
220
votes
5 answers

How to pass arguments and redirect stdin from a file to program run in gdb?

I usually run a program as : ./a.out arg1 arg2
user277465
216
votes
1 answer

Step out of current function with GDB

Those who use Visual Studio will be familiar with the Shift + F11 hotkey, which steps out of a function, meaning it continues execution of the current function until it returns to its caller, at which point it stops. Is there an equivalent in GDB?
sashoalm
  • 75,001
  • 122
  • 434
  • 781
212
votes
9 answers

How do I analyze a program's core dump file with GDB when it has command-line parameters?

My program operates like this: exe -p param1 -i param2 -o param3 It crashed and generated a core dump file, core.pid. I want to analyze the core dump file by gdb ./exe -p param1 -i param2 -o param3 core.pid But GDB recognizes the parameters of the…
Treper
  • 3,539
  • 2
  • 26
  • 48
207
votes
5 answers

How do I remove a single breakpoint with GDB?

I can add a breakpoint in GDB with: b : How can I remove an existing breakpoint at a particular location?
Chris Smith
  • 18,244
  • 13
  • 59
  • 81
1
2 3
99 100