gdb

Using gdb stop the program when it is using any function from file X

Hello I am using GDB, and I would like to know if there is any way to stop a program when is using a function from a certain file. Ideally what I am looking for is something like: GDB Stop when use a function from file foo.cpp The reason to do this is because I am debugging a code that is not mine and I do not know exactly what functi...

Using gdb, display multiple vars in one line?

Sorry in advanced gdb gurus, but how can I ask to display multiple vars in one line? So I want to get output like: 30 if(s[i] != '\0') 5: s[i] = 101 'e' 4: exp = 14 3: val = 123.45 2: sign = 1 1: i = 6 I've been typing in disp s[i] ENTER disp exp ENTER (etc, etc) and I just know there's got to be a better way to do this in one line ...

Viewing a dynamically-allocated array with the Xcode debugger?

Let's say I have an array in C++: double* velocity = new double[100]; Using the GDB command line, I can view this array with the command: > print *velocity @ 100 and it will print a nicely-formatted list of all the double values inside the array. However, when using the Xcode debugger, the most it will do is treat this as a pointe...

GDB breakpoints

Hi, I have a list of breakpoints which I want to add each time I debug a particular program. Is there a way I can put all these breakpoint information in a file and use it at the starting of each debug session? In other words can I provide a script file with breakpoint information to GDB before I give the 'run' command. Thanks in Advan...

Getting gdb to save a list of breakpoints?

OK, info break lists the breakpoints, but not in a format that would work well with reusing them using the --command as in this question. Does gdb have a method for dumping them into a file acceptable for input again? Sometimes in a debugging session, it is necessary to restart gdb after building up a set of breakpoints for testing. E...

Bidirectional (or reverse) debugging

Has anyone actually used a reversable debugger? The only product that Google turns up is UndoDB. It is for apparently for Linux only. ...

How to get Eclipse to give Cygwin's GDB a posix path to the executable?

I'm using Eclipse on Windows to program C++ using Cygwin's toolchain. I would like to use it for debugging as well, but my problem is the following: The executable to debug is in a sub-folder of the workspace (pretty standard, I guess) but not of the actual Project from which the executable is built. Eclipse and GDB have different path...

Using gdb with inlined functions

I'm trying to use gdb in postmortem mode with the core dump of a crashed process. I can get a stack trace, but instead of showing me the actual location in the offending function, gdb shows me the line number of a two-line inlined function that the offending function calls. The inlined function is called many, many places; how do I fin...

Any way to tell if my iPhone app is running under the debugger at runtime?

I would like to have my error handling code behave differently if it is running under the debugger. Specifically, if I am running on a handset, not attached to a debugger and fail an assertion I want to send the error to my server. When I am under gdb, I want to break into the debugger. Although I can imagine how Apple would write the c...

Debugging a segmentation fault when I do ctrl c

I get a segmentation fault when I cancel my program. I am using gdb for debugging, the problem is that when I press Ctrl-C while I am debugging gdb does not cancel the program and do what it is supposed to do that is stop it. What I want is do the Ctrl-C and do not allow gdb to stop it. Is there any way to do this? Any other recommendat...

Tracing write access to class instance/memory range in gdb

Hi, I am trying to debug a small operating system I have written in an university course in C++. At runtime somewhere one of my objects is getting corrupted. It seems like this happens due to accidentally writing to the wrong memory address. As I am unable to find the place where this happens from pure looking at the code, I need anothe...

Debugging Bison generated code with GDB

I am trying to step into my yyparse function, which is defined in Bison generated code, but I get a message from GDB saying Reading file "foo.tab.c"...No such file or directory. The file generated by Bison is called foo.cc. Why is it looking for foo.tab.c, instead? ...

How to do string concatenation in gdb/ada

According to the manual, string concatenation isn't implemented in gdb. I need it however, so is there a way to achieve this, perhaps using array functions? ...

Switching to assembly in gdb

Is there is any way to switch to assembly when debugging a C or C++ program in gdb ? (Given that all source files and their corresponding assembly files are available) ...

GCC debugger stack trace displays wrong file name and line number

Hi, I am trying to port a fairly large C++ project to using g++ 4.0 on MacOS X. My project compiles without errors, but I can't get gdb to work properly. When I look at the stack by typing "bt" on the gdb command line, all file names and line numbers displayed are wrong. For example, according to the gdb stack trace, my main() functio...

Tab completion interrupt for large binaries

If I accidentally launch tab completion when debugging large binary, gdb will freeze for some time scanning symbol table (up to 1 minute in my case). So I have to wait until whole symbol table is scanned. Is there any way to interrupt this process in gdb? ...

How do I find my program's main(...) function?

Hi, I am currently porting a project with a few hundred code files and dependencies onto several third-party libraries to Mac Os. I've finally gotten to the point where the program compiles without warnings or errors, but it does not seem to execute my own main function. Instead it seems to execute some other main function which seems...

Solaris GDB: Howto pause execution?

Hello I am using GDB to debug a closed source program on Solaris 10 x86. I attach gdb to the program and continue execution, however when I want to pause execution later to examine some memory I cant. When I press CTRL-C it only prints ^C instead of pausing the program and dropping me to a (gdb) prompt. bash-3.00# gdb --pid=1521 GNU g...

How do you pass arguments (I.E. the binarys name) to the Emacs gdb command?

Right now, I have F5 set to start gdb in emacs for me: (global-set-key [f5] 'gdb) This switches to the mini-buffer, which I then type a path to an executable... I'd like to find a way to bypass this path typing... I wrote an executable that looks at the Makefile, parses it and figures out the full path of the executable and prints it ...

iPhone debugging: variables are not up to date?

I've only recently began using the debugger extensively, so I'm not sure if this is a limitation. When I debug on the iPhone, the variables aren't up to date unless I explicitly view it (ctrl click -> view variable as expression). Is there a way to view actual variables without viewing explicitly? ...