gdb

Debugging a core produced by valgrind

Valgrind produced a vgcore.NNNN file -- how do I debug the core using GDB? Do I need to use the original executable and supply the core, or is there some other way to do it? Using valgrind as the root executable doesn't seem to work, and using the executable that was being run under valgrind directly in GDB with the core seems to produ...

GNU gdb 6.4 on SunOS 5.10, recognized executable formats.

Hi! Below details are from a session in a sun machine. $ file devli devli: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped $ file a a: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped $ gdb GNU gdb 6.4 Copyright 2005 Free Software Foundation, Inc. GDB is free software, covered by the ...

How do I set a breakpoint for operator() in gdb for C++?

I have 2 methods in C++ class as follows: class myClass { public: void operator()( string myString ) { // Some code } void myMethod() { ... } } For a regular method, I can simply set the breakpoint in GDB as: b myClass::myMethod But how do I set the breakpoint for the first method? UP...

How to make gdb show the orignal non-mangling function name on diassembly model?

void outputString(const char *str) { cout << "outputString(const char *str) : " << str << endl; } turns out to be Dump of assembler code for function _Z12outputStringPKc: 0x004013ee <_Z12outputStringPKc+0>: push ebp 0x004013ef <_Z12outputStringPKc+1>: mov ebp,esp 0x004013f1 <_Z12outputStringPKc+3>: sub esp,0x8 0x004...

running gdb on a web server

Using gdb, I am trying to trace the function calls of a web server. I set breakpoints on every function call and when I tell gdb to 'run' it breaks at all the right places while the server starts up. Then gdb says 'Program ended with code 01' and doesn't stop at breakpoints anymore (obviously). However, the web server is still running. ...

Objective-C: variable optimized away by compiler

I am trying to run the following code: 1. NSURL *checkLicenseURL = [NSURL URLWithString:@"check_license.php?accesskey=&license_key="]; // call server API 2. NSError *err = nil; 3. NSXMLDocument *xmlResult = [[NSXMLDocument alloc] initWithContentsOfURL:checkLicenseURL options:NSXMLDocumentTidyXML error:&err]; But when looking at variab...

Does anybody know if someone had integrated libsegfault.so and gdbserver in order to get gdb attached on the fly to a crashed program?

It's mentioned in http://sourceware.org/ml/gdb/2007-06/msg00360.html before. But no one seemed to have actually implemented this kind of idea. Is there any obstacles for realizing this? My requirements are the following: Being able to plugin to any elf binary executable (ex. by using LD_PRELOAD) The binary may be a multithreaded ex...

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. ...

Linux thread performance very fast under GDB but extremely slow otherwise

I'm working on an embedded C++ application running on Linux. I've recently encountered some really strange performance problems with pthreads. My system has 8 threads passing information back and forth protected using a pthread mutex lock. When running my application stand-alone, thread performance is abysmally slow when taking a mute...

Is GDB in Xcode just flakey?

I'm developing an iPhone application using mixed Obj-C and C++. It seems that sometimes the values of various fields are totally bogus as reported by gdb when stepping from an Obj-C file to a C++ file. For instance, in a method: int count = 1; for (int i = 0; i < count; ++i) { int x = 0; // put a breakpoint here to see how many ti...

gcc not generating debug files

Hi. I want to compile an application with debug information using gcc and gdb. When I do the following, the debug (.dSYM) files are generated correctly: gcc -ggdb src/test.c -o build/test If I, however, split this into a compile step and a link step, like this: gcc -ggdb -c src/test.c -o build/test.o gcc -ggdb build/test.o -o dist/b...

gdb causes sem_wait() to fail with EINTR error

After switching from Ubuntu to CentOS 5.4 we came across a strange GDB behavior. Running application in debugger causes sem_wait() to return several (5-10) times with EINTR error. I installed the latest GDB version but it did not solve the problem. I suppose this is cause by some signal sent by GDB but I could not get any info in signal ...

Segmentation fault while using ferror() in a simple program. Why?

Why is the following code giving segmentation fault? #include <stdio.h> #include <stdlib.h> int main() { FILE *file; file = fopen("text","r"); if (file == NULL) printf("Error READING FILE"); if (ferror(file)) printf("error reading file"); //line 9 return 0; } Doing backtrace in gdb gives:- > #0 0x00007ffff7...

ddd display long list

When tab or !ls in command window in ddd, there're always a long list to display in the command window. However, unlike other pager behavior, ddd will not stop and let you hit enter or something to continue the list, it just display the whole list straight to the end. I wonder is there any setting related to this to control this noisy be...

Debugging Thunderbird on Mac OS X with GDB

Hi guys! I tried today to find a bug in Thunderbird, or more specifically - the location where it crashes ( the Crash reporter jumps in ). However when I try to run it in gdb, the program immediately exits with code 06. And then the Crash reporter springs into action again. This way, I can never get to the actual point where it dies. I...

gdb: set a breakpoint for a SIGBUS handler

I'm trying to debug a simple stop-and-copy garbage collector (written in C) using GDB. The GC works by handling SIGBUS. I've set a breakpoint at the top of my SIGBUS signal handler. I've told GDB to pass SIGBUS to my program. However, it doesn't appear to work. The following program (explained inline) shows the essence of my problem: #...

How to save settings in gdb?

Hello, Does anyone know how to save gdb settings (like "set print pretty on" or "set print elements 0", both from here)? I don't want to set my configuration every time that I will use gdb :/ I searched in google and SO, but I found nothing. Thanks. ...

help for gdb's stepi command

I need to trace all instrutions of a program using gdb. After every execution of a instruction, I want gdb invokes a specified function. Is it a possiable work? How to achieve this? I searched internet and found "stepi arg" command in gdb could step arg instructions. But how to find total number of instructions? After e...

How to debug an App on Android with GDBSERVER?

I'm trying to debug a native shared library that my App uses through JNI. I can attach to a running app just fine with "gdbserver --attach pid" but i need to actually launch my app when i launch the gdbserver command. There's a million blog hits on this topic but none of them seem to be clear as to how you launch your app. They all say ...

how to set a threadname in MacOSX

In Windows, it is possible to set the threadname via this code. The threadname is then shown in debuggers. Under Linux, see this question. In MacOSX, I have seen several hints which indicates that there are threadnames. I think the class NSThread also has a name-attribute. My goal is that I can set the threadname in my C++ application ...