
{"id":14250,"date":"2013-09-24T16:47:18","date_gmt":"2013-09-24T16:47:18","guid":{"rendered":"http:\/\/www.beautifulwork.org\/?p=14250"},"modified":"2013-09-24T16:47:18","modified_gmt":"2013-09-24T16:47:18","slug":"binary-tree-debug","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2013\/09\/24\/binary-tree-debug\/","title":{"rendered":"Binary Tree Debug"},"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 1\nBreakpoint 1 at 0x4005db: file btree-c.c, line 1.\n(gdb) l\n92\t    }\n93\t}\n94\n95\tvoid main()\n96\t{\n97\t  node *root;\n98\t  node *tmp;\n99\t  \/\/int i;\n100\n101\t  root = NULL;\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, insert (tree=0x7fffffffe830, val=9) at btree-c.c:12\n12\t  node *temp = NULL;\n(gdb) next\n13\t  if(!(*tree))\n(gdb) next\n15\t      temp = (node *)malloc(sizeof(node));\n(gdb) l\n10\tvoid insert(node ** tree, int val)\n11\t{\n12\t  node *temp = NULL;\n13\t  if(!(*tree))\n14\t    {\n15\t      temp = (node *)malloc(sizeof(node));\n16\t      temp-&gt;left = temp-&gt;right = NULL;\n17\t      temp-&gt;data = val;\n18\t      *tree = temp;\n19\t      return;\n(gdb) next\n16\t      temp-&gt;left = temp-&gt;right = NULL;\n(gdb) print temp\n$1 = (node *) 0x601010\n(gdb) print temp-left\nNo symbol \"left\" in current context.\n(gdb) print temp-&gt;left\n$2 = (struct bin_tree *) 0x0\n(gdb) print temp-&gt;left\n$3 = (struct bin_tree *) 0x0\n(gdb) pwd\nWorking directory \/home\/jeffrin.\n(gdb) ls\nUndefined command: \"ls\".  Try \"help\".\n(gdb) break 1\nNote: breakpoint 1 also set at pc 0x4005db.\nBreakpoint 2 at 0x4005db: file btree-c.c, line 1.\n(gdb) watch *temp\nHardware watchpoint 3: *temp\n(gdb) start\nThe program being debugged has been started already.\nStart it from the beginning? (y or n) y\n\nTemporary breakpoint 4 at 0x400839: file btree-c.c, line 101.\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\nTemporary breakpoint 4, main () at btree-c.c:101\n101\t  root = NULL;\n(gdb) info watchpoints\nNo watchpoints.\n(gdb) info watchpoint\nNo watchpoints.\n(gdb) watch *temp\nNo symbol \"temp\" in current context.\n(gdb) watch root\nHardware watchpoint 5: root\n(gdb) info watchpoints\nNum     Type           Disp Enb Address            What\n5       hw watchpoint  keep y                      root\n(gdb) next\nHardware watchpoint 5: root\n\nOld value = (node *) 0x7fffffffe920\nNew value = (node *) 0x0\nmain () at btree-c.c:103\n103\t  insert(&amp;root, 9);\n(gdb) next\n\nBreakpoint 1, insert (tree=0x7fffffffe830, val=9) at btree-c.c:12\n12\t  node *temp = NULL;\n(gdb) next\n13\t  if(!(*tree))\n(gdb) print !(*tree)\n$4 = 1\n(gdb) next\n15\t      temp = (node *)malloc(sizeof(node));\n(gdb) print temp\n$5 = (node *) 0x0\n(gdb) next\n16\t      temp-&gt;left = temp-&gt;right = NULL;\n(gdb) print temp\n$6 = (node *) 0x601010\n(gdb) print temp-&gt;left\n$7 = (struct bin_tree *) 0x0\n(gdb) next\n17\t      temp-&gt;data = val;\n(gdb) print temp-&gt;left\n$8 = (struct bin_tree *) 0x0\n(gdb) print temp-&gt;left\n$9 = (struct bin_tree *) 0x0\n(gdb) next\n18\t      *tree = temp;\n(gdb) print temp-&gt;left\n$10 = (struct bin_tree *) 0x0\n(gdb) print *tree\n$11 = (node *) 0x0\n(gdb) next\nHardware watchpoint 5: root\n\nOld value = (node *) 0x0\nNew value = (node *) 0x601010\ninsert (tree=0x7fffffffe830, val=9) at btree-c.c:19\n19\t      return;\n(gdb) next\n31\t}\n(gdb) print *tree\n$12 = (node *) 0x601010\n(gdb) info watchpoints\nNum     Type           Disp Enb Address            What\n5       hw watchpoint  keep y                      root\n\tbreakpoint already hit 2 times\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\/24\/binary-tree-debug\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Binary Tree Debug&#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":[474,639,811,832],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/14250"}],"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=14250"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/14250\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=14250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=14250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=14250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}