BLog

ImprintImpressum
PrivacyDatenschutz
DisclaimerHaftung
Downloads 

Debugging a core dump with LLDB on FreeBSD

Just yesterday it occurred again to me. I was in need to debug a core dump of one of my daemon programs on FreeBSD. So, what again were the command line options? A quick web search did not give a conclusive answer, only some hints. And of course, after some trials and errors, I got it. Here comes now how, and as well how to make use of the GUI feature of LLDB for examination of the variables at the point in time of the crash.

1. Preparations

The executable must have been compiled with the options -g -O0, otherwise the core dump won’t have sufficient informations for doing symbolic debugging, and we only might find out the name of the function inside which the crash occurred. Actually, the initial crash occurred on a released product, that’s one without debugging infos compiled into, options -g0 -O3. So, I compiled the executable again, using -g -O0, and in the deployment environment, I repeated all the steps until the crash. Then I transferred the core dump to the development machine.

2. Invoking LLDB

The actual command for LLDB loading the core dump and linking it to the sources in order to allow symbolic debugging is:

# lldb --core-dump CyControl.core CyControl

This command shall be issued from inside the sources’ base directory. The last argument is the name of the executable to be examined, i.e. that one which has been compiled using -g -O0.

(lldb) target create "CyControl" --core "CyControl.core"
Core file '/root/install/CyControl.devel/CyControl.core' (x86_64) was loaded.
(lldb)​

Now all the commands or its equivalents known from GDB like bt full (gdb) = bt all (lldb) would work. However, we want to forget all this hard core’st folklore and all the other GDB cultural techniques just as well. They became forgotten anyway, didn't they? I simply type gui and Enter at the (lldb) prompt and then tock on the space bar once:

This gives me the whole story all in one view, and I marked the culprits with orange ovals.

3. Conclusion

Stupid me. I subtracted 8 from an unsigned int which was not checked before being >= 8, and then the result was used as an array index.

Copyright © Dr. Rolf Jansen - 2019-08-22 08:27:24

PROMOTION