Debugging LibreOffice with GDB

Getting started

To debug LibreOffice with GDB you need to build LibreOffice with debug symbols. You can either choose to build LO with symbols for the entire project or for selected modules.

For building with symbols for the entire project you can use

./autogen.sh --enable-debug

For building  with symbols for specific modules

./autogen.sh --enable-debug --enable-selective-debuginfo="sc/"

 More information for setting up GDB can be found here How to debug.

Setting up pretty printers

Basics

Debugging boils down to the following set of actions:
  1. Set up a break point
  2. Run the program
  3. Step through the code
  4. Analyze the variables as you go

Handling Crashes while debugging

The most common reasons for crashes are either an exception occurred or an assertion failures.
In case of Exceptions, you can stop GDB at the point where the exception occurred by setting up a breakpoint using catch throw and then analyze the backtrace (generated using bt). But since LO is a huge codebase, a numer of exceptions are thrown and gdb will break at each one of them. Hence you should add a breakpoint close to the point where the exception is thrown and then use catch throw. More detailed use of this method can be found on Kohei Yoshida's post.

Comments

Popular posts from this blog

Speeding things up

GSoC Summary