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
74
votes
15 answers

Core dump file is not generated

Every time, my application crash a core dump file is not generated. I remember that few days ago, on another server it was generated. I'm running the app using screen in bash like this: #!/bin/bash ulimit -c unlimited while true; do ./server;…
Cyclone
  • 14,839
  • 23
  • 82
  • 114
74
votes
5 answers

segfault only when NOT using debugger

I have a multithreaded C program, which consistently generates a segmentation fault at a specific point in the program. When I run it with gdb, no fault is shown. Can you think of any reason why the fault might occur only when not using the…
Benubird
  • 18,551
  • 27
  • 90
  • 141
73
votes
2 answers

How to print in binary mode in gdb?

I tried b but seem not: (gdb) p/b 0x0000000000400398 Size letters are meaningless in "print" command. Is there such a switch?
compiler
  • 4,143
  • 9
  • 36
  • 40
73
votes
5 answers

How to use the GDB (Gnu Debugger) and OpenOCD for microcontroller debugging - from the terminal?

The standard (low-cost) way to program ARM microcontrollers is using Eclipse with a complex toolchain plugged into it. Eclipse has definitely its merits, but I'd like to feel independent from this IDE. I'd like to discover what happens behind the…
K.Mulier
  • 8,069
  • 15
  • 79
  • 141
73
votes
2 answers

How to use debug version of libc

Short version of question: How can I get gdb to use the debugging symbols for libc? Longer version: I am debugging a program with gdb and I want to see information about a futex used by libc. However, at some point during debugging I get output such…
Gabriel Southern
  • 9,602
  • 12
  • 56
  • 95
72
votes
4 answers

gdb: show typeinfo of some data

Basically, I want to get typeid(*this).name(), i.e. the real type of this. I want to get this in GDB (without modifying the source code). I tried print typeid(*this) but it says that typeid is unknown (because I didn't included it there in the…
Albert
  • 65,406
  • 61
  • 242
  • 386
72
votes
3 answers

Can I use gdb to skip a line without having to type line numbers?

I know I can use jump to set the program counter to a specific line and so I can skip one or more lines (or execute some lines again). Can I easily just skip the next line without having to enter line numbers? This would be very convenient to…
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
72
votes
8 answers

How to detect if the current process is being run by GDB

The standard way would be the following: if (ptrace(PTRACE_TRACEME, 0, NULL, 0) == -1) printf("traced!\n"); In this case, ptrace returns an error if the current process is traced (e.g., running it with GDB or attaching to it). But there is a…
terminus
  • 13,745
  • 8
  • 34
  • 37
72
votes
6 answers

How to use gdb with LD_PRELOAD

I run a program with LD_PRELOADing a specific library. Like this. LD_PRELOAD=./my.so ./my_program How do I run this program with gdb?
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
71
votes
6 answers

Better variable exploring when debugging C++ code with Eclipse/CDT

Using Eclipse and CDT to debug C++ code the variable windows is cumbersome and not very informative for types defined in the standard template library or in boost (e.g. shared_ptr). Just an example how this may look like for an std::vector: bar {…} …
Danvil
  • 22,240
  • 19
  • 65
  • 88
71
votes
11 answers

How to disassemble a memory range with GDB?

I'm trying to disassemble a program to see a syscall assembly instruction (the INT instruction, I believe) and the handler with GDB and have written a little program (see below) for it that opens and closes a file. I was able to follow the call to…
Patrick
  • 4,720
  • 4
  • 41
  • 71
69
votes
4 answers

Xcode evaluating expressions while debugging

I am working on an iPhone app. I am a full-time Java developer and I am used to using Eclipse where I can put a breakpoint in and stop the process. Then, I can type in any expression that I want and Eclipse will evaluate it using the values from…
Christopher Martin
  • 927
  • 1
  • 7
  • 9
68
votes
2 answers

GDB Vs LLDB debuggers

What is the difference between GDB & LLDB debuggers? I recently upgraded my Xcode version from 4.2 to 4.3 & started getting warning to upgrade my debugger from GDB to LLDB.
Abhinav
  • 37,684
  • 43
  • 191
  • 309
68
votes
2 answers

How can I rerun a program with gdb until a segmentation fault occurs?

My program has a segmentation fault problem, but it faults rarely(once in 20 times or more), and to debug it in GDB, I need to manually rerun the program until the segmentation fault occurs (during a half day of reruns only once it fails :( ). So…
MKo
  • 4,768
  • 8
  • 32
  • 35
66
votes
1 answer

Permanently Change Disassembly Flavor in GDB

How can I permanently change the disassembly flavor in GDB. I tried:set disassembly-flavor intel in GDB, but when I fire up GDB later it still has the att flavor.
HighLife
  • 4,218
  • 7
  • 40
  • 56