Skip to content

Compiling debug binaries in cmake

Stefan A. Brannfjell edited this page Nov 5, 2019 · 5 revisions

Compiling debug binaries for your server allows you to inspect the stacktrace with symbols when the server crashes, etc if a segmentation fault occurs.

When compiling with cmake in the other compiling tutorials, instead of:

$ cmake ..

Enable debug mode with:

$ cmake -DCMAKE_BUILD_TYPE=Debug ..

This does impact your server performance. If you wish to enable symbols debugging, but need better performance, you can use this:

$ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

Note that compiling with RelWithDebInfo comes at the risk of loosing debug information. It is still much better than compiling without any build type (if you need to inspect a crash).

Run the server in gdb When it crashes, do bt full to reveal stacktrace.

Start gdb: gdb

Load in the tfs binary into gdb (after you have compiled it with symbols) file tfs

Run the file through gdb: run

When the server crashes, reveal the full stacktrace: bt full

Clone this wiki locally