GDB trial (1)
cutepig @ Ubuntu:/mnt/HGFS/share/testvalgrind $ GDB. /test
gnu gdb (GDB) 7.0-ubuntu
copyright (c) 2009 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"
This GDB was configured as "i486-linux-gnu ".
for Bug reporting instructions, please see:
...
reading symbols from/mnt/HGFS/share/testvalgrind/test... done.
(GDB) List
1 # include <string. h>
2 # include <stdlib. h>
3
4
5 Int main (INT argc, char * argv [])
6 {
7 char * PTR;
8
9 PTR = (char *) malloc (10 );
Ten strcpy (PTR, "01234567890 ");
(GDB) B 9
Breakpoint 1 at 0x804850d: file test. cpp, line 9.
(GDB) r
Starting program:/mnt/HGFS/share/testvalgrind/test
Breakpoint 1, main (argc = 1, argv = 0xbffff524) at test. cpp: 9
9 PTR = (char *) malloc (10 );
(GDB) info break
Num type disp ENB address what
1 breakpoint keep y 0x0804850d in main at test. cpp: 9
Breakpoint already hit 1 time
Variables visible to the current frame
(GDB) info Frame
Stack level 0, frame at 0xbffff.pdf:
EIP = 0x804850d in main (test. cpp: 9); saved EIP 0x3bdb56
Source Language C ++.
Arglist at 0xbffff478, argS: argc = 1, argv = 0xbffff524
Locals at 0xbffff478, previous frame's SP is 0xbffff478
Saved registers:
EBP at 0xbffff478, EIP at 0xbffff47c
View a variable
(GDB) print argv
$1 = (char **) 0xbffff524
(GDB) whatis argv
Type = char **
(GDB)
Reference
Http://www.study-area.org/cyril/opentools/opentools/x1253.html