0.8
Debugging

There are many resources and, as always, tricks to debug an EGT application.

Environment Variables

See Environment Variables for information about environment variables that may be useful for debugging. Specifically, configuring logging internal to EGT.

GDB Tips

EGT uses asserts internally. Be sure to compile the library without -DNDEBUG and then you can break on any assert using GDB to examine the callstack and the state of the application. EGT will compile with asserts enabled by default. See Configure Options for more information on compile time options.

Issue the following in a GDB session to break on an assert before the program aborts:

break __assert_fail
r
...assert...
bt

To catch when a C++ exception is thrown, before the stack starts unwinding, you can issue the following in a GDB session:

catch throw
r
...exception thrown...
bt

Using GDB Without Installing Examples

Running GDB right in the build directory without having to install the examples takes some special consideration.

When libtool is used, it creates wrapper scripts that appear to be the executable. It does this so that any built libraries can be automatically found. However, when you want to run GDB, you can't exactly run them on the wrapper scripts. However, libtool provides a way to do it.

libtool --mode=execute gdb basic

Libplanes

libplanes has an environment variable that can be useful for dumping information specifically about libplanes, which EGT can use for display setup and kernel mode setting. To see what libplanes has to say:

export LIBPLANES_DEBUG=1

Debugging Cairo

Cairo comes with a nifty trace tool that will allow you to log any cairo library calls to a file. It works sort of like strace or ftrace, but more like a tape recorder where you can record the cairo commands and then play them back.

sudo apt install cairo-perf-utils

Then, run any application with the tool and it will log to a trace file in the same directory by default.

cairo-trace ./basic

Additionally, you can replay the trace against several backends to see which one performs better.

cairo-perf-trace thermostat.26611.trace

Dump Widget Tree

In code, Application::dump() can be called to print the widget tree to an ostream. However, the default application instance installs a signal handler to do the same thing. So, you can send the signal SIGUSR1 to an EGT process and it will automatically print the widget tree.

killall -SIGUSR1 binary-name
Note
This is Linux only.

Save Screenshot

In code, Application::paint_to_file() can be called to save a screenshot to a PNG file. However, the default application instance installs a signal handler to do the same thing. So, you can send the signal SIGUSR2 to an EGT process and it will automatically save a screenshot file.

killall -SIGUSR2 binary-name
Note
This is Linux only.