gdb

Use GDB to examine Objective C class from crash (HandleDelegateSource bad access)

I am trying to debug an intermittent error on the iPhone, a crash with a trace that looks like: objc_message_send __invoking__ [NSInvocation invoke] HandleDelegateSource MainRunLoop .... When GDB stops, I'd like to be able to determine details about what selector the system is attempting to be invoked - I've set a break point now arou...

What is a good way to dump a Linux core file from inside a process?

We have a server (written in C and C++) that currently catches a SEGV and dumps some internal info to a file. I would like to generate a core file and write it to disk at the time we catch the SEGV, so our support reps and customers don't have to fuss with ulimit and then wait for the crash to happen again in order to get a core file. We...

Which are your favorite GDB tricks?

Which is your favorite macro/trick in gdb? Have you written any good macros for improving language integration? What's your best way of making the debugging experience inside gdb less painful? ...

Using a stackdump from Cygwin executable

So I wrote buggy code that occasionally crash ... and creates a stackdump file. Using addr2line I can figure out how the program got to the crash point by decoding the addresses on by one. Is there an alternative tool that can ease the debug using stack dumps? Is there a way to to load this information in Insight/Gdb? ...

Debugging an application in Linux

I want to debug an application in Linux. The application is created in C++. The GUI is created using QT. The GUI is linked with a static library that can be treated as the back end of the application. I want to debug the static library but am not sure how to do that. I tried using gdb gdb GUI But how can I attach the library? Has a...

Using GDB without debugging symbols on x86?

How do I use GDB to debug a program which do not have debugging symbols on a 32-bit x86 processor? Inspecting the function arguments, local variables, resolving pointers would be useful to know how to do. The intention is not really to use this for reverse engineering, as I'm sometimes just too lazy to install the debugging symbols and w...

Invoke gdb to automatically pass arguments to the program being debugged

Hi, I'd like to write a script that (under certain conditions) will execute gdb and automatically run some program X with some set of arguments Y. Once the program has finished executing the user should remain at gdb's prompt until s/he explicitly exits it. One way to do this would be to have the script output the run command plus arg...

Displaying dereferenced STL iterators in gdb

I have an iterator to a map element, and I would like gdb to show me the values of the "first" and "second" elements of that iterator. For example: std::map<int,double> aMap; ...fill map... std::map<int,double>::const_iterator p = aMap.begin(); I can use p.first and p.second in the code, but can't see them in gdb. For what it's worth,...

How do I examine the contents of an std::vector in gdb, using the icc compiler?

I want to examine the contents of a std::vector in gdb but I don't have access to _M_impl because I'm using icc, not gcc, how do I do it? Let's say it's a std::vector for the sake of simplicity. There is a very nice answer here but this doesn't work if I use icc, the error message is "There is no member or method named _M_impl". There a...

What is __kernel_vsyscall?

I got a core that looks very different from the ones I usually get - most of the threads are in __kernel_vsyscall() : 9 process 11334 0xffffe410 in __kernel_vsyscall () 8 process 11453 0xffffe410 in __kernel_vsyscall () 7 process 11454 0xffffe410 in __kernel_vsyscall () 6 process 11455 0xffffe410 in __kernel_vsyscall () 5 ...

How do I get gdb to ignore my shell window's size?

This is part of our unit test flow. I run gdb with the --command option to have it execute commands from a text file. The output of gdb is then directed into a file, and that file is compared to a reference file. But the problem is, gdb uses the current shell window's size to place newlines in its output. If the window is smaller, it wil...

How to Learn C Debugging and Best Practices

I've written an Apache module in C. Under certain conditions, I can get it to segfault, but I have no idea as to why. At this point, it could be my code, it could be the way I'm compiling the program, or it could be a bug in the OS library (the segfault happens during a call to dlopen()). I've tried running through GDB and Valgrind with...

How to debug the entry-point of fork-exec process?

I have a C linux application (A) that spawns another process (P) when it is started. When I want to debug P I start A as usual and I connect with ddd/gdb to P. Problems appear when I want to debug the entry-point (start of main) of P. If I follow the usual approach when I connect the debugger to P is already to late. The solution I've f...

when debugging in xcode an app that has cursor hidden, how can I force it to reappear

In debugging a game that is full screen (on one of my two monitors) when it crashes and the debugger (on the other monitor, not captured) displays the crash location, the cursor is still hidden. Is there any way to force the cursor to reappear? I can click around blindly and it works, but it's not terrible accurate. ...

GDB stop command doubt

How do I stop a gdb execution without a breakpoint ? ...

Inspecting standard container (std::map) contents with gdb

Supposing to have something like this: #include <map> int main(){ std::map<int,int> m; m[1] = 2; m[2] = 4; return 0; } I would like to be able to inspect the contents of the map running the program from gdb. If I try using the subscript operator I get: (gdb) p m[1] Attempt to take address of value not located in mem...

Debugging Best Practices for C++ STL/Boost with gdb

Debugging with gdb, any c++ code that uses STL/boost is still a nightmare. Anyone who has used gdb with STL knows this. For example, see sample runs of some debugging sessions in code here. I am trying to reduce the pain by collecting tips. Can you please comment on the tips I have collected below (particularly which ones you have been...

Linux C++ Debugger

I'm looking for the perfect Linux C++ debugger. I don't expect success, but the search should be informative. I am a quite capable gdb user but STL and Boost easily crush my debugging skills. It not that I can't get into the internals of a data structure, it's that it takes so long I usually find another way( "when in doubt, print it ...

How can I use GDB from inside Visual Studio C++ (Express) to debug my GCC Makefile projects?

I've a couple of Makefile projects on my visual studio (express) 2005/2008 (doesn't matter for now) to compile some application using the MinGW GCC compiler. I don't want to use the MS compiler because there are features that only are available on GCC. Now I'd like to debug from inside VS since I'm coding from it but this requires me to...

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 the program with the command: gdb cat input.txt > myprogram -path "/hom...