commandline session
$gdb a.out
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /home/jeffrin/a.out...done.
(gdb) break 1
Breakpoint 1 at 0x4005db: file btree-c.c, line 1.
(gdb) l
92 }
93 }
94
95 void main()
96 {
97 node *root;
98 node *tmp;
99 //int i;
100
101 root = NULL;
(gdb) r
Starting program: /home/jeffrin/a.out
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Breakpoint 1, insert (tree=0x7fffffffe830, val=9) at btree-c.c:12
12 node *temp = NULL;
(gdb) next
13 if(!(*tree))
(gdb) next
15 temp = (node *)malloc(sizeof(node));
(gdb) l
10 void insert(node ** tree, int val)
11 {
12 node *temp = NULL;
13 if(!(*tree))
14 {
15 temp = (node *)malloc(sizeof(node));
16 temp->left = temp->right = NULL;
17 temp->data = val;
18 *tree = temp;
19 return;
(gdb) next
16 temp->left = temp->right = NULL;
(gdb) print temp
$1 = (node *) 0x601010
(gdb) print temp-left
No symbol "left" in current context.
(gdb) print temp->left
$2 = (struct bin_tree *) 0x0
(gdb) print temp->left
$3 = (struct bin_tree *) 0x0
(gdb) pwd
Working directory /home/jeffrin.
(gdb) ls
Undefined command: "ls". Try "help".
(gdb) break 1
Note: breakpoint 1 also set at pc 0x4005db.
Breakpoint 2 at 0x4005db: file btree-c.c, line 1.
(gdb) watch *temp
Hardware watchpoint 3: *temp
(gdb) start
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Temporary breakpoint 4 at 0x400839: file btree-c.c, line 101.
Starting program: /home/jeffrin/a.out
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Temporary breakpoint 4, main () at btree-c.c:101
101 root = NULL;
(gdb) info watchpoints
No watchpoints.
(gdb) info watchpoint
No watchpoints.
(gdb) watch *temp
No symbol "temp" in current context.
(gdb) watch root
Hardware watchpoint 5: root
(gdb) info watchpoints
Num Type Disp Enb Address What
5 hw watchpoint keep y root
(gdb) next
Hardware watchpoint 5: root
Old value = (node *) 0x7fffffffe920
New value = (node *) 0x0
main () at btree-c.c:103
103 insert(&root, 9);
(gdb) next
Breakpoint 1, insert (tree=0x7fffffffe830, val=9) at btree-c.c:12
12 node *temp = NULL;
(gdb) next
13 if(!(*tree))
(gdb) print !(*tree)
$4 = 1
(gdb) next
15 temp = (node *)malloc(sizeof(node));
(gdb) print temp
$5 = (node *) 0x0
(gdb) next
16 temp->left = temp->right = NULL;
(gdb) print temp
$6 = (node *) 0x601010
(gdb) print temp->left
$7 = (struct bin_tree *) 0x0
(gdb) next
17 temp->data = val;
(gdb) print temp->left
$8 = (struct bin_tree *) 0x0
(gdb) print temp->left
$9 = (struct bin_tree *) 0x0
(gdb) next
18 *tree = temp;
(gdb) print temp->left
$10 = (struct bin_tree *) 0x0
(gdb) print *tree
$11 = (node *) 0x0
(gdb) next
Hardware watchpoint 5: root
Old value = (node *) 0x0
New value = (node *) 0x601010
insert (tree=0x7fffffffe830, val=9) at btree-c.c:19
19 return;
(gdb) next
31 }
(gdb) print *tree
$12 = (node *) 0x601010
(gdb) info watchpoints
Num Type Disp Enb Address What
5 hw watchpoint keep y root
breakpoint already hit 2 times
(gdb)