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
6
votes
1 answer

Tips or resources for learning advanced debugging techniques GDB in xcode

Can someone recommend some good tips or resources to learn how to learn intermediate to advanced debugging tips and tricks using GDB in Xcode.
Bruce McLeod
  • 1,362
  • 15
  • 21
6
votes
2 answers

Emacs gdb - display arrow when debugging assembly

I'm trying to debug an assembly program using gdb and Emacs. My problem is that, when I try to debug step-by-step, it doesn't show a pointer arrow at the current executing line. The code I'm trying to debug is: SECTION .data ; Section…
Luigi Tiburzi
  • 4,265
  • 7
  • 32
  • 43
6
votes
1 answer

Emacs, GDB, and multiple X windows

I use gdb-many-windows in emacs for my debugging. Recently, I discovered how to move a buffer to another X window using C-x 5 2. I find it convenient: since I use multiple displays, I can have one window with source and variables, and gdb's command…
piwi
  • 5,136
  • 2
  • 24
  • 48
6
votes
2 answers

gdb disassemble one line

I want to disassemble only one particular line of code in gdb; to do this, I need the memory address of said line. How can I get the address of a particular line of code in gdb? Or better yet, is there a command in gdb to disassemble by line number?
Bhubhu Hbuhdbus
  • 1,489
  • 6
  • 24
  • 31
6
votes
1 answer

gdb: Cannot find new threads: generic error after system update

I am running an OpenEmbedded based Linux on an ARM board, where my application is running. I used to run kernel 2.6.35, gdb 6.8 and gcc 4.3. Lately I've updated the system to kernel 2.6.37, gdb 7.4 (also tried 7.3) and gcc 4.6. Now, my application…
dseifert
  • 1,318
  • 9
  • 22
6
votes
2 answers

C++ thread not stopping in gdb async mode using user-defined or python command sequence

I'm using gdb 7.4.1 on embedded powerpc target to perform some analysis on my multi-threaded C++ program that uses pthreads. My end goal is to script gdb with python to automate some common analysis functions. The problem is that I am finding some…
timblaktu
  • 375
  • 3
  • 11
6
votes
1 answer

How to read frames from a core dump (without GDB)?

I would like to access the frames stored in a core dump of a program that doesn't has debug symbols (I want to do this in C). When I open up the program and the core dump inside GDB I get a stack trace including the names of the functions. For…
Uhlo
  • 415
  • 1
  • 7
  • 14
6
votes
3 answers

Linux heap structure and the behaviour with malloc() and free()

I have a Debian with a Linux 2.6 Kernel, and I try to understand how the heap works/behaves with malloc() and free(). I tried to search for malloc() and free() algorithm and heap structure, but I couldn't find anything helpful. And unfortunately, I…
samuirai
  • 762
  • 1
  • 9
  • 25
6
votes
1 answer

GDB: Watch a variable in a given scope

With GDB I can watch i, to break whenever i changes. The problem is that I have multiple functions using the name i, so GDB breaks inside of all those functions. Is it possible to break whenever i changes, but only inside a given function?
Randomblue
  • 112,777
  • 145
  • 353
  • 547
6
votes
2 answers

Remove all hardware watchpoints in Linux kernel 3.0.0

After setting the first (and only possible) hardware watchpoint via watch varname in GDB, it's not possible to remove it via delete. Even if I just exit GDB, this watchpoint seems to be enabled till the next reboot. When I try to set another…
Sven
  • 7,335
  • 4
  • 15
  • 14
6
votes
2 answers

Cannot call function with reference parameter in gdb

For this function: void foo_ref(const int& i) { cout << i << endl; } It's failed when I call it in gdb: (gdb) call foo_ref(5) Attempt to take address of value not located in memory. Of course, in this simple example there's no need to use…
vicshen
  • 129
  • 2
  • 7
6
votes
3 answers

GDB: Force through an if statement

This is the structure of my code if(someFunction()) { // Some code } where someFunction() evaluates to 0 most of the time When GDB is at line 1 above, if I do next then // Some code will not be executed. Is there a way to tell GDB to execute the…
Randomblue
  • 112,777
  • 145
  • 353
  • 547
6
votes
2 answers

Assembly jmp memory expression

Im dissasembling something for a project, and I encountered with the following line jmp *0x80498c0(,%eax,4) What exactly is that jump instruction trying to do? This is in a gdb environment. Thanks
leonsas
  • 4,718
  • 6
  • 43
  • 70
6
votes
1 answer

Self modifying code, copy/jump in the heap failed

First I am sorry about the length of this post, but I wanted to explain the problem clearly. I try to write a kind of small self modifying program in C but I have some troubles and I don't know exactly why. Plateform is : Ubuntu/Linux 2.6.32-40…
hodj
  • 73
  • 3
6
votes
3 answers

gdb debug with more than one argument

I have a program that reads one image file, makes some changes on that image and then stores it. The program runs like this: ./main file1.pgm file2.pgm I'm using the -g flag so I can use GDB. Now when I try to run GDB like this # gdb main file1.pgm…
Favolas
  • 6,963
  • 29
  • 75
  • 127