Cross Debugging with GDB

FreeBSD under Linux

Build

i386fbsd-tdep.c:48:12: error: static declaration of ‘i386fbsd_sc_reg_offset’ follows non-static declaration
In file included from i386fbsd-tdep.c:26:0:
i386-tdep.h:228:12: note: previous declaration of ‘i386fbsd_sc_reg_offset’ was here
make[1]: *** [i386fbsd-tdep.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/usr/x86_64-freebsd/src/gdb-6.1.1/gdb'
make: *** [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 int i386fbsd_sc_reg_offset[] =
./gdb/i386fbsd-tdep.c:  tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
./gdb/i386fbsd-tdep.c:  tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);
./gdb/i386-tdep.h:extern int i386fbsd_sc_reg_offset[];

Execute

(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from apu/src/dns-amplification-defender/dnsdefend...Dwarf Error: Cannot handle DW_FORM_<unknown> in DWARF reader [in module /home/andreas/apu/src/dns-amplification-defender/dnsdefend]
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
0x000000080060c070 in ?? ()
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint

Receiving GDB error “Dwarf Error: Cannot handle DW_FORM_flag_present in DWARF reader [in module /xxx/yyy/executable]”

GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from /home/andreas/apu/src/dns-amplification-defender/dnsdefend...done.
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x000000080060c070 in ?? ()
(gdb) b dns_header_decode_label
Breakpoint 1 at 0x406bf4: file src/packet/dns_header.c, line 159.
(gdb) r
The "remote" target does not support "run".  Try "help target" or "continue".
(gdb) help target
Connect to a target machine or process.
The first argument is the type or protocol of the target machine.
Remaining arguments are interpreted by the target protocol.  For more
information on the arguments for a particular protocol, type
`help target ' followed by the protocol name.

List of target subcommands:

target bsd-uthreads -- BSD user-level threads
target core -- Use a core file as a target
target exec -- Use an executable file as a target
target extended-remote -- Use a remote computer via a serial line
target record -- Log program while executing and replay execution from log
target record-btrace -- Collect control-flow trace and provide the execution history
target record-core -- Log program while executing and replay execution from log
target record-full -- Log program while executing and replay execution from log
target remote -- Use a remote computer via a serial line
target tfile -- Use a trace file as a target

Type "help target" followed by target subcommand name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/
bin/     include/ lib/     usr/     
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/lib
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) bt
#0  0x000000080060c070 in ?? ()
#1  0x0000000000000001 in ?? ()
#2  0x00007fffffffdd58 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) bt
#0  0x000000080060c070 in ?? ()
#1  0x0000000000000001 in ?? ()
#2  0x00007fffffffdd58 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) c
Continuing.
warning: Could not load shared library symbols for /libexec/ld-elf.so.1.
Do you need "set solib-search-path" or "set sysroot"?

Program received signal SIGBUS, Bus error.
0x0000000800949f8a in ?? () from /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/lib/libc.so.7
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/lib
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) c
Continuing.

Program terminated with signal SIGBUS, Bus error.
The program no longer exists.
(gdb) quit
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) ffile apu/src/dns-amplification-defender/dnsdefend
Undefined command: "ffile".  Try "help".
(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from /home/andreas/apu/src/dns-amplification-defender/dnsdefend...done.
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x000000080060c070 in ?? ()
(gdb) c
Continuing.
warning: Could not load shared library symbols for 2 libraries, e.g. /lib/libc.so.7.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?

Program received signal SIGBUS, Bus error.
0x0000000800949f8a in ?? ()
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0
(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from /home/andreas/apu/src/dns-amplification-defender/dnsdefend...done.
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
Reading symbols from /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/libexec/ld-elf.so.1
0x000000080060c070 in ?? () from /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/libexec/ld-elf.so.1
(gdb) b dns_header_decode_label
Breakpoint 1 at 0x406bf4: file src/packet/dns_header.c, line 159.
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400c21 in _start ()
(gdb) bt
#0  0x0000000000400c21 in _start ()

Leave a Reply

Your email address will not be published. Required fields are marked *