Debugging HPX applications¶
Using a debugger with HPX applications¶
Using a debugger such as
gdb with HPX applications is no problem. However,
there are some things to keep in mind to make the experience somewhat more
Call stacks in HPX can often be quite unwieldy as the library is heavily
templated and the call stacks can be very deep. For this reason it is sometimes
a good idea compile HPX in
RelWithDebInfo mode which applies some
optimizations but keeps debugging symbols. This can often compress call stacks
significantly. On the other hand, stepping through the code can also be more
difficult because of statements being reordered and variables being optimized
away. Also note that because HPX implements user-space threads and context
switching, call stacks may not always be complete in a debugger.
HPX launches not only worker threads but also a few helper threads. The first thread is the main thread which typically does no work in an HPX application, except at startup and shutdown. If using the default settings, HPX will spawn six additional threads (used for service thread pools). The first worker thread is usually the eighth thread, and most user code will be run on these worker threads. The last thread is a helper thread used for HPX shutdown.
Finally, since HPX is a multi-threaded runtime, the following
can be helpful:
set pagination off set non-stop on
Non-stop mode allows you to have a single thread stop on a breakpoint without stopping all other threads as well.
Using sanitizers with HPX applications¶
Not all parts of HPX are sanitizer-clean. This means that you may end up with false positives from HPX itself when using sanitizers for your application.
To use sanitizers with HPX you should turn on
HPX_WITH_SANITIZERS and turn
HPX_WITH_STACK_OVERFLOW_DETECTION during CMake configuration. It’s
recommended to also build Boost with the same sanitizers that you will be
using for HPX. The appropriate sanitizers can then be enabled using CMake by
-fsanitize=address -fno-omit-frame-pointer to
with the sanitizer that you want to use.