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
137
votes
16 answers

How to solve "ptrace operation not permitted" when trying to attach GDB to a process?

I'm trying to attach to a program with GDB but it returns: Attaching to process 29139 Could not attach to process. If your uid matches the uid of the target process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try again as the root…
bbaytemir
  • 1,471
  • 2
  • 10
  • 5
136
votes
1 answer

Print variables in hexadecimal or decimal format

Currently, when I print the value of a variable v in GDB (print v) I get an integer. Is it possible to have GDB print such integer variables in hexadecimal or binary?
Randomblue
  • 112,777
  • 145
  • 353
  • 547
132
votes
11 answers

"please check gdb is codesigned - see taskgated(8)" - How to get gdb installed with homebrew code signed?

I'm under osx 10.8.4 and have installed gdb 7.5.1 with homebrew (motivation get a new gdb with new features such as --with-python etc... ) Long story short when I run debug within a c++ Eclipse project I get : Error in final launch sequence Failed…
pellekrogholt
  • 1,895
  • 2
  • 16
  • 18
129
votes
6 answers

GDB corrupted stack frame - How to debug?

I have the following stack trace. Is it possible to make out anything useful from this for debugging? Program received signal SIGSEGV, Segmentation fault. 0x00000002 in ?? () (gdb) bt #0 0x00000002 in ?? () #1 0x00000001 in ?? () #2 0xbffff284 in…
Sangeeth Saravanaraj
  • 16,027
  • 21
  • 69
  • 98
124
votes
8 answers

How can I tell if a library was compiled with -g?

I have some compiled libraries on x86 Linux and I want to quickly determine whether they were compiled with debugging symbols.
Dan Hook
  • 6,769
  • 7
  • 35
  • 52
123
votes
5 answers

What is the difference between gcc -ggdb and gcc -g

When I use gcc to compile C programs I usually use -g to get some debug information into the elf file so that gdb can help me if needed. However, I noticed that some programs use -ggdb, since it's supposed to make the debug info more gdb friendly.…
Johan
  • 20,067
  • 28
  • 92
  • 110
123
votes
4 answers

Run an Application in GDB Until an Exception Occurs

I'm working on a multithreaded application, and I want to debug it using GDB. Problem is, one of my threads keeps dying with the message: pure virtual method called terminate called without an active exception Abort I know the cause of that…
Ankur Sethi
  • 3,508
  • 5
  • 23
  • 17
121
votes
12 answers

Is there a way to change the environment variables of another process in Unix?

On Unix, is there any way that one process can change another's environment variables (assuming they're all being run by the same user)? A general solution would be best, but if not, what about the specific case where one is a child of the…
raldi
  • 21,344
  • 33
  • 76
  • 86
120
votes
6 answers

What does mean in gdb?

(gdb) n 134 a = b = c = 0xdeadbeef + ((uint32_t)length) + initval; (gdb) n (gdb) p a $30 = (gdb) p b $31 = (gdb) p c $32 = 3735928563 How can gdb optimize out my value??
gdb
  • 7,189
  • 12
  • 38
  • 36
120
votes
6 answers

How to load program reading stdin and taking parameters in gdb?

I have a program that takes input from stdin and also takes some parameters from command line. It looks like this: cat input.txt > myprogram -path "/home/user/work" I try to debug the code with gdb inside emacs, by M-x gdb, I try to load…
vinc456
  • 2,862
  • 5
  • 23
  • 30
119
votes
2 answers

How to break on assembly instruction at a given address in gdb?

0x0000000000400448 : push %rbp 0x0000000000400449 : mov %rsp,%rbp 0x000000000040044c : mov $0x6,%eax 0x0000000000400451 : leaveq 0x0000000000400452 : retq I tried: breaki…
compile-fan
  • 16,885
  • 22
  • 59
  • 73
118
votes
1 answer

Ask GDB to list all functions in a program

How can you list all functions in a program with GDB?
pythonic
  • 20,589
  • 43
  • 136
  • 219
116
votes
3 answers

How to inspect the return value of a function in GDB?

Is it possible to inspect the return value of a function in gdb assuming the return value is not assigned to a variable?
fuad
  • 4,265
  • 9
  • 34
  • 32
112
votes
5 answers

gdb: "No symbol table is loaded"

I keep getting this error mesage when trying to add a breakpoint in gdb. I've used these commands to compile: gcc -g main.c utmpib2.c -o main.o and: cc -g main.c utmpib2.c -o main.o and also: g++ -g main.c utmpib2.c -o main.o I also tried "-ggdb"…
user994165
  • 9,146
  • 30
  • 98
  • 165
110
votes
5 answers

How to automatically run the executable in GDB?

I'd like to have gdb immediately run the executable, as if I'd typed "run" (motivation: I dislike typing "run"). One way is to pipe the command to gdb like this: $ echo run | gdb myApp But the problem with this approach is that you lose…
orion elenzil
  • 4,484
  • 3
  • 37
  • 49