GDB can be your friend

Maintenance and bug fixing is a usual part of every project. We, developers, would like to code all the time, but unfortunately it is not possible in commercial projects.

Based on my own experience, the most common way of analysing the bugs is checking (or adding) the logs to find out the root cause of the issue. Such an approach often works, but there are cases where logs are not giving any useful hint and the only way to proceed is trying to reproduce the issue and debugging the code. Another common case in large software projects is getting the core dump generated by software component in target environment, which should be properly analysed.

In such cases tools like gdb (GNU debugger) or lldb (debugger for LLVM) can be your friends! If you have any IDE integrated with debugger, then you can use it quite easily. If you do not like IDEs or you are limited to console, then knowing how to use gdb or lldb may be beneficial. You should see my genuine joy once in the past, when I realized that gdb is available in DUT when investigating a nasty bug!

Some time ago I did some simple C++ code examples with instructions on how to use basic gdb commands in Linux environment with gcc. Maybe you’ll find it useful for starting adventure with gdb or just recall some commands:

I encourage to get familiar with lldb or gdb, you can never know when it might save your day.

Finally, a curiosity that a colleague from the project once shared: have you ever tried the TUI mode in gdb (i.e.: wh command or Ctrl + x, Ctrl + a)?

GDB can be your friend

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top