Binary Tree Debug (Pre-order Related)

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 111
Breakpoint 1 at 0x4008b8: file btree-c.c, line 111.
(gdb) break 34
Breakpoint 2 at 0x40068b: file btree-c.c, line 34.
(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, main () at btree-c.c:112
112	  printf("Pre Order Displayn");
(gdb) next
Pre Order Display
113	  print_preorder(root);
(gdb) next

Breakpoint 2, print_preorder (tree=0x601010) at btree-c.c:35
35	  if (tree)
(gdb) bt
#0  print_preorder (tree=0x601010) at btree-c.c:35
#1  0x00000000004008ce in main () at btree-c.c:113
(gdb) print tree
$1 = (node *) 0x601010
(gdb) print *tree
$2 = {data = 9, right = 0x601050, left = 0x601030}
(gdb) next
37	      printf("%dn",tree->data);
(gdb) next
9
38	      print_preorder(tree->left);
(gdb) print tree-left
No symbol "left" in current context.
(gdb) print tree->left
$3 = (struct bin_tree *) 0x601030
(gdb) print *(tree->left)
$4 = {data = 4, right = 0x601070, left = 0x6010d0}
(gdb) next

Breakpoint 2, print_preorder (tree=0x601030) at btree-c.c:35
35	  if (tree)
(gdb) print tree
$5 = (node *) 0x601030
(gdb) next
37	      printf("%dn",tree->data);
(gdb) next
4
38	      print_preorder(tree->left);
(gdb) next

Breakpoint 2, print_preorder (tree=0x6010d0) at btree-c.c:35
35	  if (tree)
(gdb) next
37	      printf("%dn",tree->data);
(gdb) next
2
38	      print_preorder(tree->left);
(gdb) print tree->left
$6 = (struct bin_tree *) 0x0
(gdb) print *(tree->left)
Cannot access memory at address 0x0
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x6010d0) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) print tree->data
$7 = 2
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x601030) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) print tree->right
$8 = (struct bin_tree *) 0x601070
(gdb) next

Breakpoint 2, print_preorder (tree=0x601070) at btree-c.c:35
35	  if (tree)
(gdb) next
37	      printf("%dn",tree->data);
(gdb) next
6
38	      print_preorder(tree->left);
(gdb) print tree->left
$9 = (struct bin_tree *) 0x0
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x601070) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x601010) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) next

Breakpoint 2, print_preorder (tree=0x601050) at btree-c.c:35
35	  if (tree)
(gdb) next
37	      printf("%dn",tree->data);
(gdb) next
15
38	      print_preorder(tree->left);
(gdb) print tree->left
$10 = (struct bin_tree *) 0x601090
(gdb) next

Breakpoint 2, print_preorder (tree=0x601090) at btree-c.c:35
35	  if (tree)
(gdb) next
37	      printf("%dn",tree->data);
(gdb) print *(tree->left)
Cannot access memory at address 0x0
(gdb) print *(tree->right)
Cannot access memory at address 0x0
(gdb) next
12
38	      print_preorder(tree->left);
(gdb) print *(tree->left)
Cannot access memory at address 0x0
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x601090) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) print *(tree->right)
Cannot access memory at address 0x0
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x601050) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) print *(tree->right)
$11 = {data = 17, right = 0x0, left = 0x0}
(gdb) next

Breakpoint 2, print_preorder (tree=0x6010b0) at btree-c.c:35
35	  if (tree)
(gdb) next
37	      printf("%dn",tree->data);
(gdb) next
17
38	      print_preorder(tree->left);
(gdb) print *(tree->left)
Cannot access memory at address 0x0
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
print_preorder (tree=0x6010b0) at btree-c.c:39
39	      print_preorder(tree->right);
(gdb) next

Breakpoint 2, print_preorder (tree=0x0) at btree-c.c:35
35	  if (tree)
(gdb) next
42	}
(gdb) next
main () at btree-c.c:115
115	  printf("In Order Displayn");
(gdb)