gdb split view with code

It’s called the TUI (no kidding). Start for example with gdbtui or gdb -tui … Please also see this answer by Ciro Santilli. It wasn’t available in 2012 to the best of my knowledge, but definitely worth a look.

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

Stopping at the first machine code instruction in GDB

Starting with GDB 8.1, there’s a special command for this: starti. Example GDB session: $ gdb /bin/true Reading symbols from /bin/true…(no debugging symbols found)…done. (gdb) starti Starting program: /bin/true Program stopped. 0xf7fdd800 in _start () from /lib/ld-linux.so.2 (gdb) x/5i $pc => 0xf7fdd800 <_start>: mov eax,esp 0xf7fdd802 <_start+2>: call 0xf7fe2160 <_dl_start> 0xf7fdd807 <_dl_start_user>: mov edi,eax 0xf7fdd809 … Read more

Core dump file analysis [duplicate]

You just need a binary (with debugging symbols included) that is identical to the one that generated the core dump file. Then you can run gdb path/to/the/binary path/to/the/core/dump/file to debug it. When it starts up, you can use bt (for backtrace) to get a stack trace from the time of the crash. In the backtrace, … Read more