{"id":5425,"date":"2014-03-30T21:51:04","date_gmt":"2014-03-30T21:51:04","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/find-info-from-address-in-debugging-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:51:04","modified_gmt":"2014-03-30T21:51:04","slug":"find-info-from-address-in-debugging-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/find-info-from-address-in-debugging-collection-of-common-programming-errors\/","title":{"rendered":"Find info from address in debugging-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<p>Usually yes. Assuming your program crashed outside GDB due to <code>SIGSEGV<\/code> and left a core dump, you can:<br \/>\nA: find out which instruction actually caused the access violation:<\/p>\n<pre><code>    (gdb) x\/i $pc\n<\/code><\/pre>\n<p>This will usually be a memory access instruction, e.g. <code>\"movl $1,8(%eax)\"<\/code>. What&#8217;s important is then what value does the register which is supposed to point to valid memory have.<br \/>\nB. find out value of that register:<\/p>\n<pre><code>   (gdb) p\/x $eax\n<\/code><\/pre>\n<p>Often this would be 0 (you are writing through a <code>NULL<\/code> pointer), or some nonsense value, e.g. <code>0x32314043<\/code> (you&#8217;ve corrupted the pointer, or overwrote it with an <code>ASCII<\/code> string).<\/p>\n<\/li>\n<li>\n<p>The <code>GDB<\/code> <code>\"info symbol\"<\/code> command will tell you which symbol (if any) is near the given address.<\/p>\n<\/li>\n<li>\n<p>Use the same <code>\"info symbol\"<\/code> command for addresses slightly smaller and slightly larger the address of your &#8220;target&#8221; variable.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Usually yes. Assuming your program crashed outside GDB due to SIGSEGV and left a core dump, you can: A: find out which instruction actually caused the access violation: (gdb) x\/i $pc This will usually be a memory access instruction, e.g. &#8220;movl $1,8(%eax)&#8221;. What&#8217;s important is then what value does the register which is supposed to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5425","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5425"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5425\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}