Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
Marvin Frick edited this page May 28, 2013 · 1 revision

If an error occurrs somewhere in your application, you typically use a debugger that supports you in finding the bug. When using the GCC, the GNU Project debugger (GDB) is the naturally used tool. Make sure that the GDB is installed on your system. Using Windows, see Section XXX how to set up Cygwin correctly. For Unix users, use the packet manager of your distribution, or go to http://sourceware.org/gdb/ alternatively and follow the installation instructions.

Running Shawn in GDB requires some specific compilation settings, and then a complete recompilation of your code. To prepare Shawn, execute the following steps:

  • Change to shawn/buildfiles using your preferred Shell.
  • Type ccmake ../src
  • Change CMAKE_BUILD_TYPE to either RelWithDebInfo or Debug as shown in Figure XXX.
    shawn_gdb01.png
  • Press c to take the actual configuration.
  • Press g to generate makefiles.
  • Finally, type make to recompile Shawn, so that it can be used in GDB.

As you may notice, Shawn executable is considerably bigger than the release version. However, now you can start debugging your application. Make sure that the simple configuration file from Section XXX is available in the current directory. Located in shawn/buildfiles, type

  gdb shawn

to start GDB (alternatively, type gdb shawn.exe for Windows users in Cygwin shell). Then the screen should look like Figure XXX.

shawn_gdb02.png

Now that GDB has been started with the Shawn binary as argument, Shawn must be executed. There are two possibilities of doing so. Either Shawn can be run by typing r or run, or a configuration file can be given additionally by typing r -f file.conf.

Additionally, you can use the parameter "-jshawn" to load a config file but let shawn react as if it would be loading a jshawn file (i.e. using the same SimulationController that is used when processing a jshawn file) which may produce slightly different output. Your statement should look like this:

  r -jshawn -f trace_history.conf

If you're using JShawn to run your application, simply add a line that says:
shawn.traceHistory("trace_history.conf"); to Generate a .conf file first.

The former allows for passing commands line by line, whereas the latter uses the given configuration file for execution. However, both options are shown in Figure XXX.

shawn_gdb03.png shawn_gdb04.png 'Starting Shawn in GDB.'

If something abnormal happens, for example if the program crashes, one can call bt for backtracing what happened just before the crash. Also, breakpoints can be set via break before starting Shawn. When finished, one can call q for exiting GDB.

However, it is highly recommended to consult the GDB documentation available under http://sourceware.org/gdb/download/onlinedocs/gdb.html, or at least typing help in the GDB command line interface.