Discussion:
cross gdb for arm-freebsd
John Hein
2011-10-31 16:29:04 UTC
Permalink
The gdb in the base FreeBSD is quite old (6.1.1) and I'm having
trouble debugging a core file from a threaded application. A newer
gdb (7.2 and 7.3.1) are in FreeBSD's ports system, but getting it to
build for --target=arm-freebsd and read core files is proving
difficult - I could use a few hints.

Since there is no support in the upstream latest gdb for a cross built
arm-freebsd target (that I could see), I tried copying the
architecture files from
http://svnweb.freebsd.org/base/head/gnu/usr.bin/gdb/arch/arm/ and
updating them for 7.3.1

I made the following changes:

--- orig/armfbsd-tdep.c 2007-11-18 10:07:47.000000000 -0700
+++ armfbsd-tdep.c 2011-10-31 10:14:58.000000000 -0600
@@ -26,6 +26,7 @@
#include "arch-utils.h"
#include "arm-tdep.h"
#include "solib-svr4.h"
+#include "target.h"

/* Description of the longjmp buffer. */
#define ARM_FBSD_JB_PC 24
@@ -52,8 +53,7 @@
arm_freebsd_init_abi_common (info, gdbarch);

/* FreeBSD ELF uses SVR4-style shared libraries. */
- set_gdbarch_in_solib_call_trampoline
- (gdbarch, generic_in_solib_call_trampoline);
+ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);

and

--- configure.tgt.orig 2010-04-27 15:01:14.000000000 -0600
+++ configure.tgt 2011-10-31 08:38:12.000000000 -0600
@@ -81,6 +81,10 @@
solib.o solib-svr4.o symfile-mem.o corelow.o linux-tdep.o"
build_gdbserver=yes
;;
+arm*-*-freebsd*)
+ # Target: FreeBSD/arm
+ gdb_target_obs="arm-tdep.o armfbsd-tdep.o corelow.o solib.o solib-svr4.o"
+ ;;
arm*-*-netbsd* | arm*-*-knetbsd*-gnu)
# Target: NetBSD/arm
gdb_target_obs="arm-tdep.o armnbsd-tdep.o solib.o solib-svr4.o"


It compiles, but I'm getting this when I try to debug a core file:

GNU gdb (GDB) 7.2
Copyright (C) 2010 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=i386-portbld-freebsd8.2 --target=arm-freebsd".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
warning: "/tmp/core1.core": no core file handler recognizes format, using default
Can't fetch registers from this type of core file
warning: .dynamic section for "/tmp/crossroot/lib/libthr.so.3" is not at the expected address (wrong library or version mismatch?)
Can't fetch registers from this type of core file
Can't fetch registers from this type of core file
#0 0x00000000 in ?? ()
(gdb)

Does anyone have hints to steer me in the right direction to read the core file?

Oh, also for FreeBSD 8.x, the base version of binutils is at 2.15, but
also a newer version is available in ports also. However, my
application is built using the base version.
Tom Tromey
2011-11-01 19:24:28 UTC
Permalink
John> The gdb in the base FreeBSD is quite old (6.1.1) and I'm having
John> trouble debugging a core file from a threaded application. A newer
John> gdb (7.2 and 7.3.1) are in FreeBSD's ports system, but getting it to
John> build for --target=arm-freebsd and read core files is proving
John> difficult - I could use a few hints.

John> --- orig/armfbsd-tdep.c 2007-11-18 10:07:47.000000000 -0700
John> +++ armfbsd-tdep.c 2011-10-31 10:14:58.000000000 -0600

This file isn't in gdb. I guess it is a FreeBSD addition.

John> It compiles, but I'm getting this when I try to debug a core file:
[...]

John> warning: "/tmp/core1.core": no core file handler recognizes format, using default

I think this is probably the root of your problems. I suggest debugging
gdb and stepping through sniff_core_bfd. I don't know this area well
but I think this function should find the core file reader for your
target.

Tom
John Hein
2011-11-01 19:57:18 UTC
Permalink
Post by Tom Tromey
John> The gdb in the base FreeBSD is quite old (6.1.1) and I'm having
John> trouble debugging a core file from a threaded application. A newer
John> gdb (7.2 and 7.3.1) are in FreeBSD's ports system, but getting it to
John> build for --target=arm-freebsd and read core files is proving
John> difficult - I could use a few hints.
John> --- orig/armfbsd-tdep.c 2007-11-18 10:07:47.000000000 -0700
John> +++ armfbsd-tdep.c 2011-10-31 10:14:58.000000000 -0600
This file isn't in gdb. I guess it is a FreeBSD addition.
Indeed it is a FreeBSD addition. You removed a bit too much context
from my original email in your quote. Notably the svn url which
Post by Tom Tromey
The gdb in the base FreeBSD is quite old (6.1.1) and I'm having
trouble debugging a core file from a threaded application. A newer
gdb (7.2 and 7.3.1) are in FreeBSD's ports system, but getting it to
build for --target=arm-freebsd and read core files is proving
difficult - I could use a few hints.
Since there is no support in the upstream latest gdb for a cross built
arm-freebsd target (that I could see), I tried copying the
architecture files from
http://svnweb.freebsd.org/base/head/gnu/usr.bin/gdb/arch/arm/ and
updating them for 7.3.1
Without using armfbsd-tdep.c and cross compiling the unmodified gdb
for --target=arm-freebsd, I get a different problem:

warning: A handler for the OS ABI "FreeBSD ELF" is not built into this configuration
of GDB. Attempting to continue with the default arm settings.

So, that's why I was looking into pulling in the FreeBSD specific
changes for the architecture files (except they are for gdb 6.1.1,
so some hacking is needed to get them building for gdb 7.2).
Post by Tom Tromey
[...]
John> warning: "/tmp/core1.core": no core file handler recognizes format, using default
I think this is probably the root of your problems. I suggest debugging
gdb and stepping through sniff_core_bfd. I don't know this area well
but I think this function should find the core file reader for your
target.
Thanks. I'll dig in and report back.

"eof_eom_XYZ"
Tom Tromey
2011-11-01 20:23:05 UTC
Permalink
Tom> This file isn't in gdb. I guess it is a FreeBSD addition.

John> Indeed it is a FreeBSD addition. You removed a bit too much context
John> from my original email in your quote. Notably the svn url which
John> points out where armfbsd-tdep.c comes from:

Oops, sorry about that.

Tom

Loading...