
{"id":14258,"date":"2013-09-27T14:48:27","date_gmt":"2013-09-27T14:48:27","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=14258"},"modified":"2013-09-27T14:48:27","modified_gmt":"2013-09-27T14:48:27","slug":"binary-tree-debug-in-order-and-post-order-related","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2013\/09\/27\/binary-tree-debug-in-order-and-post-order-related\/","title":{"rendered":"Binary Tree Debug (Pre-order Related)"},"content":{"rendered":"<h4><u>commandline session<\/u><\/h4>\n<pre>\n$gdb a.out\nGNU gdb (GDB) 7.4.1-debian\nCopyright (C) 2012 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later \nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\nThis GDB was configured as \"x86_64-linux-gnu\".\nFor bug reporting instructions, please see:\n...\nReading symbols from \/home\/jeffrin\/a.out...done.\n(gdb) break 111\nBreakpoint 1 at 0x4008b8: file btree-c.c, line 111.\n(gdb) break 34\nBreakpoint 2 at 0x40068b: file btree-c.c, line 34.\n(gdb) r\nStarting program: \/home\/jeffrin\/a.out\nwarning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000\nwarning: Could not load shared library symbols for linux-vdso.so.1.\nDo you need \"set solib-search-path\" or \"set sysroot\"?\n\nBreakpoint 1, main () at btree-c.c:112\n112\t  printf(\"Pre Order Displayn\");\n(gdb) next\nPre Order Display\n113\t  print_preorder(root);\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x601010) at btree-c.c:35\n35\t  if (tree)\n(gdb) bt\n#0  print_preorder (tree=0x601010) at btree-c.c:35\n#1  0x00000000004008ce in main () at btree-c.c:113\n(gdb) print tree\n$1 = (node *) 0x601010\n(gdb) print *tree\n$2 = {data = 9, right = 0x601050, left = 0x601030}\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) next\n9\n38\t      print_preorder(tree-&gt;left);\n(gdb) print tree-left\nNo symbol \"left\" in current context.\n(gdb) print tree-&gt;left\n$3 = (struct bin_tree *) 0x601030\n(gdb) print *(tree-&gt;left)\n$4 = {data = 4, right = 0x601070, left = 0x6010d0}\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x601030) at btree-c.c:35\n35\t  if (tree)\n(gdb) print tree\n$5 = (node *) 0x601030\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) next\n4\n38\t      print_preorder(tree-&gt;left);\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x6010d0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) next\n2\n38\t      print_preorder(tree-&gt;left);\n(gdb) print tree-&gt;left\n$6 = (struct bin_tree *) 0x0\n(gdb) print *(tree-&gt;left)\nCannot access memory at address 0x0\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x6010d0) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) print tree-&gt;data\n$7 = 2\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x601030) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) print tree-&gt;right\n$8 = (struct bin_tree *) 0x601070\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x601070) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) next\n6\n38\t      print_preorder(tree-&gt;left);\n(gdb) print tree-&gt;left\n$9 = (struct bin_tree *) 0x0\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x601070) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x601010) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x601050) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) next\n15\n38\t      print_preorder(tree-&gt;left);\n(gdb) print tree-&gt;left\n$10 = (struct bin_tree *) 0x601090\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x601090) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) print *(tree-&gt;left)\nCannot access memory at address 0x0\n(gdb) print *(tree-&gt;right)\nCannot access memory at address 0x0\n(gdb) next\n12\n38\t      print_preorder(tree-&gt;left);\n(gdb) print *(tree-&gt;left)\nCannot access memory at address 0x0\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x601090) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) print *(tree-&gt;right)\nCannot access memory at address 0x0\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x601050) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) print *(tree-&gt;right)\n$11 = {data = 17, right = 0x0, left = 0x0}\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x6010b0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n37\t      printf(\"%dn\",tree-&gt;data);\n(gdb) next\n17\n38\t      print_preorder(tree-&gt;left);\n(gdb) print *(tree-&gt;left)\nCannot access memory at address 0x0\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nprint_preorder (tree=0x6010b0) at btree-c.c:39\n39\t      print_preorder(tree-&gt;right);\n(gdb) next\n\nBreakpoint 2, print_preorder (tree=0x0) at btree-c.c:35\n35\t  if (tree)\n(gdb) next\n42\t}\n(gdb) next\nmain () at btree-c.c:115\n115\t  printf(\"In Order Displayn\");\n(gdb)\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;show copying&#8221; and &#8220;show warranty&#8221; for details. This GDB &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2013\/09\/27\/binary-tree-debug-in-order-and-post-order-related\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Binary Tree Debug (Pre-order Related)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[929,1284,1600],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/14258"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=14258"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/14258\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=14258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=14258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=14258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}