User Tools

Site Tools



Getting GCC & GDB


After installation the Windows search path must be extended with the path where the binaries of MinGW are installed, for example: "C:\MinGW\bin"
Needed packages:

  • mingw32-base


  • sudo apt-get install gcc
  • sudo apt-get install gdb



 1 #include <stdlib.h>
 2 #include <stdio.h>
 4 int main(int argc, char** argv) {
 5   char* x = NULL;
 6   printf("Let it crash with option (%s)...\n", argc > 1 ? argv[1]:"none");
 7   if( x[0] == '1' )
 8     printf("Should have crashed before...\n");
 9   return 0;
10 }


C:\crash> gcc -g crash.c -o crash.exe

The -g option is for adding debug information.


Start the debugger

C:\crash> gdb crash.exe

Start the debugger with application option(s)

C:\crash> gdb --args crash.exe docrash

Debugger welcome message

GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
Reading symbols from C:\crash/crash.exe...done.

Run the application

(gdb) run

The application crash

Starting program: C:\crash/crash.exe
[New Thread 2800.0xaf4]
Let it crash with option (none)...

Program received signal SIGSEGV, Segmentation fault.
0x004013e6 in main (argc=1, argv=0x3e3ea8) at crash.c:7
7         if( x[0] == '1' )

Show the back trace after the crash

(gdb) bt
#0  0x004013ff in main (argc=1, argv=0x3e24c8) at crash.c:7

The crash is reported at line 7 of crash.c:
0x004013e6 in main (argc=1, argv=0x3e3ea8) at crash.c:7
7 if( x[0] == '1' )
The application did try to read memory at address zero which does not belong to the process and is protected by the Operating System.

This information is used by developers to fix the crash.

Please post the complete backtrace in case of a reproducible crash to


:!: Do not use the "-console" parameter in case the rocrail.exe has to be debugged with gdb, because this will disable backtracing.


C:\Rocrail\meinAbeitsBereich>C:\MinGW\bin\gdb.exe --args "C:\Rocrail\Rocrail.exe" -l C:\Rocrail run
develop/debugging-tutorial.txt · Last modified: 2022/12/15 16:39 by rjversluis