gdb

Can GDB display a list of pthread mutexes held by each thread?

I have GDB attached to a deadlocked application written with pthreads. There are ~10 threads that are all blocked, and I'd like to know which locks are held by which threads. This is possible in WinDbg using SOS.dll; is this possible in GDB? ...

Process terminated by signal 6, core shows kind of loop in libc

Hi On analysis of the core of a process (terminated by signal 6), on LINUX, stack bt shows : Core was generated by `/opt/namsam/pac_rrc_qx_e1/bin/rrcprb'. Program terminated with signal 6, Aborted. #0 0x0000005555ffb004 in epoll_wait () from /lib64/libc.so.6 (gdb) bt #0 0x0000005555ffb004 in epoll_wait () from /lib64/libc.so.6 #1...

How to make gdb get stacktrace repeatably?

Like in for((;;)) { gdb -batch -n -ex 'set pagination off' -ex 'thread apply all bt' ffplay_g `pidof ffplay_g` >> /tmp/qq; } , but faster, without reloading GDB and symbols every time? Backtraces need to be taken by timer, not by triggering some breakpoints. ...

How can save breakpoint setting in linux consol while debugging a c++ program

I am now using linux developing c++ program. the workbench is windows connecting linux workstation console through putty. I set lot of breakpoint in the program, using gdb to debug program is very powerful:) But I do not no how to save breakpoint, so the next time when "gdb ./MyProg" the breakpoint information is lost,“info breakpoint...

how to resolve segment:offset adres in GDB

(gdb) info registers ds ds 0x7b 123 (gdb) disassemble Dump of assembler code for function printf@plt: 0x0804831c <+0>: jmp DWORD PTR ds:0x804a008 => 0x08048322 <+6>: push 0x10 0x08048327 <+11>: jmp 0x80482ec End of assembler dump. Can someone describe me how to map ds:0x804a008 address into linear ad...

Disassembling Interactively in GDB

Is it possible to get gdb to disassemble machine code interactively. For example: (gdb) [disassemble command] 0x58 0xef 0x22 If I give the above command gdb should interpret the hex values as machine code and give me back the disassembly. The commands which I know of only disassemble a portion of the memory of the loaded program. ...

Using GDB to inspect the Machine Stack

Is there any way to get GDB to print the last "n" values pushed on the machine's stack. For example, currently if I want to inspect the contents of the stack I do the following (assuming x86 architecture): (gdb) # get last value pushed on stack (gdb) p *(int *)($esp) (gdb) # get 2nd to last value pushed on stack (gdb) p *(int *)($esp + ...

How do I change my gdb path in Unix?

My professor posted this online for a lab this week, but I missed the tutorial and didn't find how to do this. Does anyone know? It is just a simple command line thing, but I have been hunting around and can't seem to figure it out... Hi everyone, A new version of gdb (version 6.8) has been installed on the servers csb and csg (but not...

issue with debugged application output in gdb

HI All I am doing my first steps with GDB in TUI mode. During the debug session I see that each line outputted to console occurs in a single line (in the picture you see 222222 highlighted in red ). It is like having an output pane of one single line. On top of that each \n doesn't cleanup that line so all the strings do overwrite eac...

Allocating memory to pointer structures inside structures

If I have a structure such as typedef struct _people { char *name; bool *exists; struct _people **citizens; } PEOPLE; How do I go about allocating memory so that people->citizens[0]->name is accessible? I've tried info->citizens = malloc(sizeof(PEOPLE *)*numbPeople); However when I try to access info->citizens->name I get th...

Unable to find stack smashing function using GDB

I have the following C application: #include <stdio.h> void smash() { int i; char buffer[16]; for(i = 0; i < 17; i++) // <-- exceeds the limit of the buffer { buffer[i] = i; } } int main() { printf("Starting\n"); smash(); return 0; } I cross-compiled using the following version of gcc: armv5...

How do I debug a CUDA library with only 1 graphics card running X11

I'm running a CUDA library that I need to debug for memory problems and other issues. But when I attach cuda-gdb to the process I get the error error: All CUDA devices are used for X11 and cannot be used while debugging. I understand the error, but there has to be a way that I can debug the issues. Since I only have 1 GPU, it real...

Debugging C applications in MonoDevelop fails

Hi, debugging in MonoDevelop does not work for me. First of all, I have installed MonoDevelop, GNU Debugger plugin and ctags through Ubuntu software center and I'm using Ubuntu 10.10. When I press "Debug" it goes into debug mode but very quickly returns to "normal mode". My simple application contains some scanf so it should wait for i...

CUDA: Debug with -deiceemu and gdb

Hello, I wrote a CUDA application that has some hardcoded parameters in it (via #defines). Everything seemed to work right, so I tried some other parameters. Now, the program doesn't work correctly anymore. So, I want to debug it. I compile the application with -deviceemu -g -O0 options, because I read that I can then use gdb to debug...

GDB question: Pretty-Printing a 2D Array?

I have a 2d array matrix[10][10] that I'd like to inspect at debug time. I understand that I can do this in GDB using p *matrix@10 But it outputs this in one line, making it difficult to read. Is there a way to have this output formatted in any way, lets say as a matrix? ...

Can I use gdb to skip a line?

I know I can use jump to set the program counter to a specific line and so I can skip one ore 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 "comment out" something at run time. ...

how to analysys the coredump that crash in the share library loaded by dlopen?

Gdb only show the function name in the share library that load by system library loader. How to get the crash address in the share library load by dl_open? Thanks. ...

Set a breakpoint condition for self pointer in Mac OS X

I'm trying to figure out when [NSView setNeedsDisplay] is called for a particular object. I want to set a breakpoint on it that fires only when the self pointer refers to the object I care about. The method is called probably hundreds of times around the time it's called for my object, so something like a breakpoint condition is necessar...

How to script gdb? Example add breakpoints, run, what breakpoint did we hit?

Hi I'm trying to create a little unit test with gdb, for a embedded mcu that is controlled by OpenOCD (that gives me control over my target via a gdb server). So I would like to automate this with some basic scripting of gdb, but it is not really working. I would like to write some kind of script for gdb that more or less does this...