Main
GDB PRACTICAL COMMANDS



// *** EXAMPLE program.cpp ***
enum { MAX = 100 };
int gfun() {
  //...
}
class CType {
   public:
   int fun();
};
int CType :: fun() {
   //...
}
int main( int argc, char **argv ) {
   CType o1;
   for( int i = 0; i < MAX; i++ ) {
     gfun();
   //...
   }
   o1.fun();
   //...
}

Setting breakpoints

on global function:
(gdb) b gfun

on class function:
(gdb) b CType::fun

on line number in source file:
(gdb) b program.cpp:14

Running program

without arguments:
(gdb) r

with some example arguments:
(gdb) r +s "abc 123" -p 55

continuation after break:
(gdb) c

one step forward:
(gdb) n

one source line forward (going over loops):
(gdb) u

going inside current line function:
(gdb) s

stopping program:
(gdb) k

Checking

variable 'i' value:
(gdb) p i

backtrace of all stack frames:
(gdb) bt

actual frame:
(gdb) f

current line surroundings:
(gdb) l

current function arguments:
(gdb) info args

current function local variables:
(gdb) info local

watching changes of variable 'i':
(gdb) wa i

watching expression:
(gdb) wa i < 10

automatic printing variable 'i' value:
(gdb) disp i

removing automatic printing (with index 2):
(gdb) und 2

Removing breakpoints

on current line:
(gdb) cl

on some specific line:
(gdb) cl program.cpp:15

deleting specific (14) breakpoint:
(gdb) d 14

deleting all breakpoints:
(gdb) d

Hosted by www.Geocities.ws

1