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

Saving core file in gdb

Issue the ‘generate-core-file’ command in gdb. (gdb) help generate-core-file Save a core file with the current state of the debugged process. Argument is optional filename. Default filename is ‘core.<process_id>’. (gdb) break main Breakpoint 1 at 0x400e0b: file utils/udec.c, line 36. (gdb) r Starting program: /home/nos/build/utils/udec Breakpoint 1, main (argc=1, argv=0x7fffffffe9a8) at utils/udec.c:36 36 int fileargc … Read more

How to automatically run the executable in GDB?

gdb -ex run ./a.out If you need to pass arguments to a.out: gdb -ex run –args ./a.out arg1 arg2 … EDIT: Orion says this doesn’t work on Mac OSX. The -ex flag has been available since GDB-6.4 (released in 2005), but OSX uses Apple’s fork of GDB, and the latest XCode for Leopard contains GDB … Read more

What does mean in gdb?

It means you compiled with e.g. gcc -O3 and the gcc optimiser found that some of your variables were redundant in some way that allowed them to be optimised away. In this particular case you appear to have three variables a, b, c with the same value and presumably they can all be aliassed to … Read more

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.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)