Can we define a new data type in a GDB session

Yes, here is how to make this work: // sample.h struct sample { int i; struct sample *less; struct sample *more; }; // main.c #include <stdio.h> #include <assert.h> #include “sample.h” int main() { struct sample sm; sm.i = 42; sm.less = sm.more = &sm; printf(“&sm = %p\n”, &sm); assert(sm.i == 0); // will fail } … Read more

Include source code of malloc.c in gdb?

The following worked for me. Not sure whether there is a better way. Install libc6-dbg (which you have already done): sudo apt-get install libc6-dbg Install the eglibc-source package (ubuntu actually uses eglibc): sudo apt-get install eglibc-source. Unpack the tar file that was installed in /usr/src/glibc: /usr/src/glibc $ sudo tar xvf eglibc-2.19.tar.xz Crank up gdb and … Read more

gdb doesn’t work on macos High Sierra 10.13.3

This is caused by latest gdb 8.1, downgrade gdb to 8.0.1 could solve this problem. How to downgrade to gdb 8.0.1 Unlink current gdb: brew unlink gdb Install gdb 8.0.1: brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/9ec9fb27a33698fc7636afce5c1c16787e9ce3f3/Formula/gdb.rb Optional: avoid upgrade gdb with brew pin gdb

How can I tell if a library was compiled with -g?

If you’re running on Linux, use objdump –debugging. There should be an entry for each object file in the library. For object files without debugging symbols, you’ll see something like: objdump –debugging libvoidincr.a In archive libvoidincr.a: voidincr.o: file format elf64-x86-64 If there are debugging symbols, the output will be much more verbose.