{"id":2863,"date":"2014-08-29T10:31:49","date_gmt":"2014-08-29T10:31:49","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=2863"},"modified":"2014-08-29T11:14:48","modified_gmt":"2014-08-29T11:14:48","slug":"cross-debugging-with-gdb","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=2863","title":{"rendered":"Cross Debugging with GDB"},"content":{"rendered":"<h3>FreeBSD under Linux<\/h3>\n<h4>Build<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ni386fbsd-tdep.c:48:12: error: static declaration of \u2018i386fbsd_sc_reg_offset\u2019 follows non-static declaration\r\nIn file included from i386fbsd-tdep.c:26:0:\r\ni386-tdep.h:228:12: note: previous declaration of \u2018i386fbsd_sc_reg_offset\u2019 was here\r\nmake&#x5B;1]: *** &#x5B;i386fbsd-tdep.o] Error 1\r\nmake&#x5B;1]: *** Waiting for unfinished jobs....\r\nmake&#x5B;1]: Leaving directory `\/usr\/x86_64-freebsd\/src\/gdb-6.1.1\/gdb'\r\nmake: *** &#x5B;all-gdb] Error 2\r\n\r\n# grep -r i386fbsd_sc_reg_offset .\r\n.\/gdb\/i386bsd-nat.c:#define SC_REG_OFFSET i386fbsd_sc_reg_offset\r\n.\/gdb\/i386fbsd-tdep.c:static int i386fbsd_sc_reg_offset&#x5B;] =\r\n.\/gdb\/i386fbsd-tdep.c:  tdep-&gt;sc_reg_offset = i386fbsd_sc_reg_offset;\r\n.\/gdb\/i386fbsd-tdep.c:  tdep-&gt;sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);\r\n.\/gdb\/i386-tdep.h:extern int i386fbsd_sc_reg_offset&#x5B;];\r\n<\/pre>\n<h4>Execute<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n(gdb) file apu\/src\/dns-amplification-defender\/dnsdefend\r\nReading symbols from apu\/src\/dns-amplification-defender\/dnsdefend...Dwarf Error: Cannot handle DW_FORM_&lt;unknown&gt; in DWARF reader &#x5B;in module \/home\/andreas\/apu\/src\/dns-amplification-defender\/dnsdefend]\r\n(gdb) target remote 10.41.10.20:2345\r\nRemote debugging using 10.41.10.20:2345\r\n0x000000080060c070 in ?? ()\r\nwarning: Unable to find dynamic linker breakpoint function.\r\nGDB will be unable to debug shared library initializers\r\nand track explicitly loaded dynamic code.\r\nwarning: shared library handler failed to enable breakpoint\r\n<\/pre>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/17958650\/receiving-gdb-error-dwarf-error-cannot-handle-dw-form-flag-present-in-dwarf-re\">Receiving GDB error \u201cDwarf Error: Cannot handle DW_FORM_flag_present in DWARF reader [in module \/xxx\/yyy\/executable]\u201d<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nGNU gdb (GDB) 7.6\r\nCopyright (C) 2013 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot;\r\nand &quot;show warranty&quot; for details.\r\nThis GDB was configured as &quot;--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0&quot;.\r\nFor bug reporting instructions, please see:\r\n&lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/&gt;.\r\nNo symbol table is loaded.  Use the &quot;file&quot; command.\r\nMake breakpoint pending on future shared library load? (y or &#x5B;n]) &#x5B;answered N; input not from terminal]\r\n(gdb) file apu\/src\/dns-amplification-defender\/dnsdefend\r\nReading symbols from \/home\/andreas\/apu\/src\/dns-amplification-defender\/dnsdefend...done.\r\n(gdb) target remote 10.41.10.20:2345\r\nRemote debugging using 10.41.10.20:2345\r\nwarning: Unable to find dynamic linker breakpoint function.\r\nGDB will be unable to debug shared library initializers\r\nand track explicitly loaded dynamic code.\r\n0x000000080060c070 in ?? ()\r\n(gdb) b dns_header_decode_label\r\nBreakpoint 1 at 0x406bf4: file src\/packet\/dns_header.c, line 159.\r\n(gdb) r\r\nThe &quot;remote&quot; target does not support &quot;run&quot;.  Try &quot;help target&quot; or &quot;continue&quot;.\r\n(gdb) help target\r\nConnect to a target machine or process.\r\nThe first argument is the type or protocol of the target machine.\r\nRemaining arguments are interpreted by the target protocol.  For more\r\ninformation on the arguments for a particular protocol, type\r\n`help target ' followed by the protocol name.\r\n\r\nList of target subcommands:\r\n\r\ntarget bsd-uthreads -- BSD user-level threads\r\ntarget core -- Use a core file as a target\r\ntarget exec -- Use an executable file as a target\r\ntarget extended-remote -- Use a remote computer via a serial line\r\ntarget record -- Log program while executing and replay execution from log\r\ntarget record-btrace -- Collect control-flow trace and provide the execution history\r\ntarget record-core -- Log program while executing and replay execution from log\r\ntarget record-full -- Log program while executing and replay execution from log\r\ntarget remote -- Use a remote computer via a serial line\r\ntarget tfile -- Use a trace file as a target\r\n\r\nType &quot;help target&quot; followed by target subcommand name for full documentation.\r\nType &quot;apropos word&quot; to search for commands related to &quot;word&quot;.\r\nCommand name abbreviations are allowed if unambiguous.\r\n(gdb) set sysroot \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/\r\nbin\/     include\/ lib\/     usr\/     \r\n(gdb) set sysroot \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/lib\r\nwarning: Unable to find dynamic linker breakpoint function.\r\nGDB will be unable to debug shared library initializers\r\nand track explicitly loaded dynamic code.\r\n(gdb) bt\r\n#0  0x000000080060c070 in ?? ()\r\n#1  0x0000000000000001 in ?? ()\r\n#2  0x00007fffffffdd58 in ?? ()\r\n#3  0x0000000000000000 in ?? ()\r\n(gdb) set sysroot \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\r\nwarning: Unable to find dynamic linker breakpoint function.\r\nGDB will be unable to debug shared library initializers\r\nand track explicitly loaded dynamic code.\r\n(gdb) bt\r\n#0  0x000000080060c070 in ?? ()\r\n#1  0x0000000000000001 in ?? ()\r\n#2  0x00007fffffffdd58 in ?? ()\r\n#3  0x0000000000000000 in ?? ()\r\n(gdb) c\r\nContinuing.\r\nwarning: Could not load shared library symbols for \/libexec\/ld-elf.so.1.\r\nDo you need &quot;set solib-search-path&quot; or &quot;set sysroot&quot;?\r\n\r\nProgram received signal SIGBUS, Bus error.\r\n0x0000000800949f8a in ?? () from \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/lib\/libc.so.7\r\n(gdb) set sysroot \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/lib\r\nwarning: Unable to find dynamic linker breakpoint function.\r\nGDB will be unable to debug shared library initializers\r\nand track explicitly loaded dynamic code.\r\n(gdb) c\r\nContinuing.\r\n\r\nProgram terminated with signal SIGBUS, Bus error.\r\nThe program no longer exists.\r\n(gdb) quit\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nGNU gdb (GDB) 7.6\r\nCopyright (C) 2013 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot;\r\nand &quot;show warranty&quot; for details.\r\nThis GDB was configured as &quot;--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0&quot;.\r\nFor bug reporting instructions, please see:\r\n&lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/&gt;.\r\nNo symbol table is loaded.  Use the &quot;file&quot; command.\r\nMake breakpoint pending on future shared library load? (y or &#x5B;n]) &#x5B;answered N; input not from terminal]\r\n(gdb) ffile apu\/src\/dns-amplification-defender\/dnsdefend\r\nUndefined command: &quot;ffile&quot;.  Try &quot;help&quot;.\r\n(gdb) file apu\/src\/dns-amplification-defender\/dnsdefend\r\nReading symbols from \/home\/andreas\/apu\/src\/dns-amplification-defender\/dnsdefend...done.\r\n(gdb) target remote 10.41.10.20:2345\r\nRemote debugging using 10.41.10.20:2345\r\nwarning: Unable to find dynamic linker breakpoint function.\r\nGDB will be unable to debug shared library initializers\r\nand track explicitly loaded dynamic code.\r\n0x000000080060c070 in ?? ()\r\n(gdb) c\r\nContinuing.\r\nwarning: Could not load shared library symbols for 2 libraries, e.g. \/lib\/libc.so.7.\r\nUse the &quot;info sharedlibrary&quot; command to see the complete listing.\r\nDo you need &quot;set solib-search-path&quot; or &quot;set sysroot&quot;?\r\n\r\nProgram received signal SIGBUS, Bus error.\r\n0x0000000800949f8a in ?? ()\r\n<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nGNU gdb (GDB) 7.6\r\nCopyright (C) 2013 Free Software Foundation, Inc.\r\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot;\r\nand &quot;show warranty&quot; for details.\r\nThis GDB was configured as &quot;--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0&quot;.\r\nFor bug reporting instructions, please see:\r\n&lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/&gt;.\r\nNo symbol table is loaded.  Use the &quot;file&quot; command.\r\nMake breakpoint pending on future shared library load? (y or &#x5B;n]) &#x5B;answered N; input not from terminal]\r\n(gdb) set sysroot \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\r\n(gdb) file apu\/src\/dns-amplification-defender\/dnsdefend\r\nReading symbols from \/home\/andreas\/apu\/src\/dns-amplification-defender\/dnsdefend...done.\r\n(gdb) target remote 10.41.10.20:2345\r\nRemote debugging using 10.41.10.20:2345\r\nReading symbols from \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/libexec\/ld-elf.so.1...(no debugging symbols found)...done.\r\nLoaded symbols for \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/libexec\/ld-elf.so.1\r\n0x000000080060c070 in ?? () from \/usr\/x86_64-freebsd\/x86_64-pc-freebsd10.0\/libexec\/ld-elf.so.1\r\n(gdb) b dns_header_decode_label\r\nBreakpoint 1 at 0x406bf4: file src\/packet\/dns_header.c, line 159.\r\n(gdb) c\r\nContinuing.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n0x0000000000400c21 in _start ()\r\n(gdb) bt\r\n#0  0x0000000000400c21 in _start ()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>FreeBSD under Linux Build i386fbsd-tdep.c:48:12: error: static declaration of \u2018i386fbsd_sc_reg_offset\u2019 follows non-static declaration In file included from i386fbsd-tdep.c:26:0: i386-tdep.h:228:12: note: previous declaration of \u2018i386fbsd_sc_reg_offset\u2019 was here make&#x5B;1]: *** &#x5B;i386fbsd-tdep.o] Error 1 make&#x5B;1]: *** Waiting for unfinished jobs&#8230;. make&#x5B;1]: Leaving directory `\/usr\/x86_64-freebsd\/src\/gdb-6.1.1\/gdb&#8217; make: *** &#x5B;all-gdb] Error 2 # grep -r i386fbsd_sc_reg_offset . .\/gdb\/i386bsd-nat.c:#define SC_REG_OFFSET i386fbsd_sc_reg_offset .\/gdb\/i386fbsd-tdep.c:static [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2863","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/2863","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2863"}],"version-history":[{"count":6,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/2863\/revisions"}],"predecessor-version":[{"id":2870,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/2863\/revisions\/2870"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2863"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2863"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2863"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}