gdb

How to debug a remote linux binary ?

Here is the situation: I've got a linux binary that is crashing. No log files, trace files, etc. I need to be able to attach a debugger to it (I have the source locally) and track down the error. Whats the easiest, best way to approach this problem? ...

Examining mmaped addresses using GDB

I'm using the driver I posted at http://stackoverflow.com/questions/647783/direct-memory-access-in-linux/ to mmap some physical ram into a userspace address. However, I can't use GDB to look at any of the address; i.e., x 0x12345678 (where 0x12345678 is the return value of mmap) fails with an error "Cannot access memory at address 0x1234...

What is the difference between gcc -ggdb and gcc -g

Hi When I use gcc under Linux to compile some c programs, I usually use -g to get some debug information into the elf file so that gdb can help me when that is needed. However I noticed that some use -ggdb, since it is supposed to make the debug info more gdb friendly. (And I guess that it is correct to use -ggdb since I debug wi...

Remote debug error with GDB

Hi, I tried to remote debug an 32-bit application on x86_64 suse linux, but get this "remote register badly formatted" error. I start up the gdbserver as listening on port 12345 (gdbserver localhost:12345 my_prog) And this is the error: $ gdb GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered b...

How do I do source level debug of library

I have a following setup. Although my working setup deals with ARM compiler Real View Developer Suite (RVDS) 3.2 on a Windows host, the situation could be generic for any other C compiler on any host. I build a ARM library (static library - .a file) of C code using RVDS 3.2 compiler toolchain on Windows host. Then I link this library w...

In GDB on MinGW, how to make Ctrl-C stop the program?

I'm on Windows, running GDB on an executable built under MinGW. The program has an infinite loop. I want to find it by hitting Ctrl-C. When I do, both the program and GDB exit. All the help on this subject seems to assume I'm on Linux. ...

How to get GDB not to print function parameter values when "stepping into"?

When hitting breakpoints and stepping into functions, gdb version 6.8 prints the name of the function followed by the function arguments. It just so happens, in the program I'm debugging, one of the parameter values is a HUGE record being passed by reference. gdb prints the variable name followed by ALL of its member variables. It liter...

How do you automate the launching/debugging of large scale projects?

Scenario: There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach gdb for debugging. The process launching script: ensures an environment variable is set. ensures a local build directory gets added to the environment's LD_LIBRARY_PATH var...

How to detect the point of a stack overflow.

I have the following problem with my C program: Somewhere is a stack overflow. Despite compiling without optimization and with debugger symbols, the program exits with this output (within or outside of gdb on Linux): Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists. The only way I could detect ...

How to print string value from breakpoint action?

I have a breakpoint action and am using the Log option from the drop down. I'd like to print out the string (summary) value. I'm doing this: the person name is: @p.name@ but that prints the memory address. I can switch to the Debugger Command option and do po f.name but then I loose my description, as used in the first option. ...

How can I print type attributes in GDB?

Is there a way to print a type attribute from inside GDB? E.g. Integer'Size. ...

How do I use gdbmacros.cpp in QtCreator?

I'm trying to debug in QtCreator on Linux and I get the message: The debugged binary does not contain information needed for nice display of Qt data types. You might want to try including the file .../share/qtcreator/gdbmacros/gdbmacros.cpp into your project directly. Adding ~/qtcreator/gdbmacros/gdbmacros.cpp to my ...

GDB: Getting a symbol name from a memory address

I'm not sure if the following is possible, but can one retrieve the name of a symbol that a memory address points to in GDB? For instance, I know that 0x46767f0 belongs to an NSString*, is there any way I can find out what NSString it is to help me find some bugs I'm after? Thanks! ...

Print complete control flow through gdb

The idea is that given a specific input to the program, somehow I want to automatically step-in through the complete program and dump its control flow along with all the data being used like classes and their variables. Is their a straightforward way to do this? Or can this be done by some scripting over gdb or does it require modificati...

Automate tracing in GDB

Hi, I have been trying to find a way for some time to automate the progress in GDB of tracing the control flow of a program. Even just a simple way of automating the 'n' command so you can see what order routines are called. I realise that you can issues 'n x' where x is the number of times GDB steps through, but the trouble with that...

propagation of "-g" in shared libraries with gcc

I have the a program abc. abc uses the library def and def in turn includes a library ghi. Now, libghi.so is compiled and linked using gcc -g. libdef.so is also compiled and linked using gcc -g. However, abc isn't linked with -g. The question is, if I debug abc with gdb should I be able to see the symbols in def and ghi? The projec...

gdb won't accept stdin redirection in emacs

I'm trying to debug a program using gdb mode in emacs. It was compiled with g++, and I'm using cygwin. My program takes one command line argument, and also takes input from stdin, which I redirect from a file, like this: program.exe inputFile.dat <otherInput.dat The problem is, gdb is sending the string "<otherInput.dat" as a comma...

stack not workingin gdb

Exact duplicate: http://stackoverflow.com/questions/780961/gdb-gnu-debugger #include <pthread.h> #include <stdio.h> #define NTHREADS 4 #define N 1000 #define MEGEXTRA 1000000 pthread_attr_t attr; void *dowork(void *threadid) { double A[N][N]; int i,j; long tid; size_t mystacksize; tid = (long)threadid; pthread_...

Debugging using gdb - Best practices

I am a beginner in GDB and I got it working correctly. However, I am wondering how this is used in big projects. I have a project where build is done using makefile and g++. For GDB to work, we need to compile with debug symbols on, right (g++ -g files)? Question Do I need to create a new target in makefile something like "debug", so...

How can I use "watch" GDB?

I tried to watch the change of the "int a" by the command "watch a". However, the program does not stop, when it changes to 12. Why? /* FILE: test.c */ #include <stdio.h> #include <stdlib.h> int main(int argc, char** argv){ printf("Hello world\n"); int a = 12; a = 10; ...