Previous: , Up: Developing Applications   [Contents]


4.8 Debugging with gnunet-arm

Even if services are managed by gnunet-arm, you can start them with gdb or valgrind. For example, you could add the following lines to your configuration file to start the DHT service in a gdb session in a fresh xterm:

[dht]
PREFIX=xterm -e gdb --args

Alternatively, you can stop a service that was started via ARM and run it manually:

$ gnunet-arm -k dht
$ gdb --args gnunet-service-dht -L DEBUG
$ valgrind gnunet-service-dht -L DEBUG

Assuming other services are well-written, they will automatically re-integrate the restarted service with the peer.

GNUnet provides a powerful logging mechanism providing log levels ERROR, WARNING, INFO and DEBUG. The current log level is configured using the $GNUNET_FORCE_LOG environmental variable. The DEBUG level is only available if --enable-logging=verbose was used when running configure. More details about logging can be found under https://docs.gnunet.org/#Logging.

You should also probably enable the creation of core files, by setting ulimit, and echo’ing 1 into /proc/sys/kernel/core\_uses\_pid. Then you can investigate the core dumps with gdb, which is often the fastest method to find simple errors.

Exercise: Add a memory leak to your service and obtain a trace pointing to the leak using valgrind while running the service from gnunet-service-arm.