Using Debugger

  1. GNU Debugger (gdb) is a powerful terminal debugger for Unix-like systems. GDB offers tracing and altering how computer programs are working. Below are some commands:
  2. An example gdb execution; http://siber.cankaya.edu.tr/OperatingSystems/cfiles/code1.ccode1.c
    $ gcc  -O0 -g -o code1 code1.c
    $ gdb code1
    GNU gdb (GDB) 7.0-ubuntu
    Copyright (C) 2009 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    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 "x86_64-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /home/ceng328/code1...done.
    (gdb) list
    1       #include <stdio.h>
    2
    3       int
    4       main(int argc, char* argv[])
    5       {
    6           printf ("hello world\n");
    7
    8           return 0;
    9       }
    (gdb) run
    Starting program: /home/ceng328/code1
    hello world
    
    Program exited normally.
    (gdb) break 6
    Breakpoint 1 at 0x400533: file code1.c, line 6.
    (gdb) run
    Starting program: /home/ceng328/code1
    
    Breakpoint 1, main (argc=1, argv=0x7fffffffe308) at code1.c:6
    6           printf ("hello world\n");
    (gdb)
    


Cem Ozdogan 2010-03-04