Show current assembly instruction in GDB

You can switch to assembly layout in GDB: (gdb) layout asm See here for more information. The current assembly instruction will be shown in assembler window. ┌───────────────────────────────────────────────────────────────────────────┐ │0x7ffff740d756 <__libc_start_main+214> mov 0x39670b(%rip),%rax #│ │0x7ffff740d75d <__libc_start_main+221> mov 0x8(%rsp),%rsi │ │0x7ffff740d762 <__libc_start_main+226> mov 0x14(%rsp),%edi │ │0x7ffff740d766 <__libc_start_main+230> mov (%rax),%rdx │ │0x7ffff740d769 <__libc_start_main+233> callq *0x18(%rsp) │ >│0x7ffff740d76d <__libc_start_main+237> mov … Read more

How do I print the elements of a C++ vector in GDB?

With GCC 4.1.2, to print the whole of a std::vector<int> called myVector, do the following: print *(myVector._M_impl._M_start)@myVector.size() To print only the first N elements, do: print *(myVector._M_impl._M_start)@N Explanation This is probably heavily dependent on your compiler version, but for GCC 4.1.2, the pointer to the internal array is: myVector._M_impl._M_start And the GDB command to print … Read more

How can I make gdb save the command history?

Short answer: mkdir -p ~/.config/gdb echo ‘set history save on’ >> ~/.config/gdb/gdbinit Long answer: Command history is covered in the GDB manual, 22.3 Command History. Create a file $HOME/.config/gdb/gdbinit, and add the following line: set history save on You can set the number of past commands saved with the following. The command is described as … 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

Can I set a breakpoint on ‘memory access’ in GDB?

watch only breaks on write, rwatch let you break on read, and awatch let you break on read/write. You can set read watchpoints on memory locations: gdb$ rwatch *0xfeedface Hardware read watchpoint 2: *0xfeedface but one limitation applies to the rwatch and awatch commands; you can’t use gdb variables in expressions: gdb$ rwatch $ebx+0xec1a04f Expression … Read more

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