gdb

Under a debugger

How do I detect in my program that it's being run under a debugger? I am aware that this seems to indicate that I try to do something I shouldn't, and that is too messy. I think it is an interesting question tho. Specifically, is there a way to do it in a POSIX environment? For example using sigaction (2) to detect that some handler ...

GDB breakpoint same function appears more times

Hello! Using gdb, I have encountered a strange issue: there is a method which appears three times: (gdb) b Logger::Logger [0] cancel [1] all [2] Logger at src/Logger.cpp:52 [3] Logger at src/Logger.cpp:52 [4] Logger at src/Logger.cpp:52 From the fact that all three instances are on line 552 of the file Logger.cpp, it can be deduced, ...

Is it possible to halt the execution of all other threads when reaching a breakpoint in gdb?

So, as soon as I hit a breakpoint in some thread, is it possible to halt other threads until I continue? ...

How to print and use constants with gdb (through xcode) ?

I am debugging a Cocoa application using xcode-gdb. I am at a break point and I want view the value of some Cocoa constants (ie NSControlKeyMask) and to do some test with the values in the current stackframe. Specifically I am in - (void) keyDown:(NSEvent *) e , and I have done set $mf = (int)[e modifierFlags] on the gdb prompt. Now ...

How to debug an objective-c program (pbcopy supplied by Apple) with gdb?

Hi everyone, I need to debug an objective-c program. When setting a breakpoint on main() function , I've got: Reading symbols from /usr/bin/pbcopy...done. (gdb) break main Function "main" not defined. Invoking "start" from reply the same error. I suspect the way of doing things is different on max os x ? What is the equivalent with o...

I need to find the point in my userland code that crash my kernel.

I have big system that make my system crash hard. When I boot up, I don't even have a coredump. If I log every line that get executed until my system goes down. I will find that evil code. Can I log every source code line in GDB to a file? UPDATE: ok, I found the bug. It was nasty. The application I started did not take the system d...

GDB cheat sheet

Can anyone recommend a good cheat sheet for gbd? I'm experienced with windbg commands, I'm looking for gdb equivalents for lml (list loaded modules), ~*k (all threads stack), ba (break on access), dt (dump type), dv (dump frame variables), sxe (set up SEH handler) etc. I understand there won't be a 1 to 1 equivalent, but I just need a co...

cocoa/apple symbol server

Is there an equivalent in dbg/cocoa/apple word for the Microsoft public symbol server and windbg (http://msdl.microsoft.com/download/symbols)? So basically 1) does gdb support the concept of a symbol server and 2) does apple supply a public URL for their own public symbols? ...

Doubt regarding a tail optimized code under 'gdb'

Consider a tail recursive factorial implementation in C: #include <stdio.h> unsigned long long factorial(unsigned long long fact_so_far, unsigned long long count, unsigned long long max_count){ if (max_count==0 || max_count==1 || count >= max_count) return fact_so_far; else { printf("%llu %p \n", count, &factorial); ...

MacGDBp, but better?

For debugging php code I use MacGDBp but it has its quirks: it shows only the top frame variables of the stack, it sometimes refuses to display any variable at all and last version has decorates the source text with non ascii characters. Is there any alternative that is native OS X? (ie. not Eclipse, I can't stand it). ...

How can I start an interactive program(like gdb) from python?

Hi, I am going to start up gdb from python. For example: prog.shell.py: #do lots of things # # p.subprocess.Popen("gdb --args myprog", shell=True, stdin=sys.stdin, stdout=sys.stdout) But the gdb is not invoked as I expected, the interaction with gdb is broken. I have also tried os.system(), but it still doesnt work....

in c++ gdb core dump, can I see if a pointer is still allocated?

I have a core dump sitting on disk, created by an app that failed an assert and aborted. The app was compiled in debug mode on Linux/g++. I suspect that in the stack frame at the top of the stack, my this object has been delete'd (I think this is no longer a valid ptr). However it could take days or longer to reproduce this abort. Is th...

Anyone succesful in debugging unit tests for iPhone?

I found examples on how to debug your unit test in Cocoa or the ADC page here. But I can't get the debugging to work for an iPhone app target. I can get the tests up and running and they are run during the build, but what I need is to debug the tests for some of the more complex failures. ...

Blank field showing up on iPhone AddressBook, how to debug?

The following code creates me an array of all my contacts in my address book by first name and last name. The problem is, I have one contact that keeps showing up with an empty first name and last name. I can't find that contact in my actual address book. Can anyone suggest how to debug this to figure out the source of the mystery ghost ...

After setting a breakpoint in Qt, gdb says: "Error accessing memory address"

I wrote a very simple Qt program here: int main(int argc, char* argv[]) { QApplication app(argc, argv); QTableView table(&frame); table.resize(100, 100); table.show(); return app.exec(); } And when I try to set a breakpoint where the table gets clicked, I get this error from gdb: (gdb) symbol-file /usr/lib/libQt...

gdb says "cannot open shared object file"

Hello all, I have one binary and one shared library. The shared library is compiled with: all: g++ -g -shared -fpic $(SOURCES) -o libmisc.so the binary is compiled with: LIBS=-L../../misc/src LDFLAGS=-lmisc all: g++ -g -o mainx $(INCLUDE) $(SOURCE) $(LIBS) $(LDFLAGS) I set in ~/.bashrc export LD_LIBRARY_PATH=/mnt/sda5/Programming/m...

How can I insert a time string into a GDB log?

Hey Guys, I recently discovered that you can set breakpoints in Xcode that will print to the console and auto-continue -- meaning you can insert log statements without having to write NSLog() calls and recompile (on-the-fly logging, woot). Only problem is that it seems to be a little limited in what you can display when doing a log. It...

KDE development debugging

In a kde3 game called ksirtet (a tetris clone) when playing against a computer the human player cannot move the tetris piece left/right. I'm trying to fix it but cannot debug in gdb. After the line "kapp->exec()" gdb stops responding, the game runs and I cannot input any command do gdb to see what's going on. So the question is about deb...

How to change the working directory for build/debug in Emacs?

I'm trying to get accustomed to using Emacs for building and debugging, although I'm having some difficulties. My biggest problem right now is that I need to be in (e.g. have a file open in) the root directory to make -k my applications and I need to be in the binaries directory to run gdb MyApp. Is it futile to try to get Ctrl+Shift+B ...

How do I print a UChar* var as a string from inside of gdb?

I've been doing some work on an unfamiliar codebase that uses UChar* as strings. Uchars are defined as follows (at least according to gdb) (gdb) ptype UChar type = short unsigned int However, when I try to print these in gdb, I just get the address. I can also index into the pointer and retrieve the values of each character. Is there...