[PATCH] gdb for GNU/kFreeBSD on MIPS
brobecker at adacore.com
Mon Mar 7 04:45:57 UTC 2011
For the record, the copyright assignment paperwork just came through,
and Robert asked me to look at this patch.
> 2011-01-09 Robert Millan <rmh at gnu.org>
> * configure.host: Detect mips-freebsd and mips-kfreebsd-gnu, and set
> `gdb_host' appropiately.
> * configure.tgt: Detect mips-freebsd and mips-kfreebsd-gnu, and use
> the same definitions as with mips-netbsd.
> * config/mips/fbsd.mh: New file.
> * config/mips/nbsd.mh (MH_CFLAGS): New variable (defines BSD_OSABI
> C macro).
> * mipsnbsd-tdep.c [BSD_OSABI == GDB_OSABI_FREEBSD_ELF]
> (MIPSNBSD_NUM_GREGS): Define as `40'.
> (MIPSNBSD_NUM_FPREGS): Define as `34'.
> (NBSD_MIPS_JB_PC): Define as `12'.
> * mipsnbsd-tdep.c (_initialize_mipsnbsd_tdep): Replace
> `GDB_OSABI_NETBSD_ELF' with `BSD_OSABI'.
I think that Mark Kettenis would be a better reviewer for this patch,
as he knows the BSDs better than I do. However, I can comment on
a few things...
For Mark's benefit, I'll attach a copy of the patch, so that he does
not have to go fish it back.
> +# Host: FreeBSD/mips
> +MH_CFLAGS= -DBSD_OSABI=GDB_OSABI_FREEBSD_ELF
This looked very suspicious, and indeed:
> --- gdb/mipsnbsd-tdep.c 2011-01-01 15:32:52 +0000
> +++ gdb/mipsnbsd-tdep.c 2011-01-09 09:08:54 +0000
> @@ -45,10 +45,18 @@
> /* Core file support. */
> /* Number of registers in `struct reg' from <machine/reg.h>. */
> +#if BSD_OSABI == GDB_OSABI_NETBSD_ELF
> #define MIPSNBSD_NUM_GREGS 38
> +#elif BSD_OSABI == GDB_OSABI_FREEBSD_ELF
> +#define MIPSNBSD_NUM_GREGS 40
This is not the way to go. GDB is supposed to be able to support
multiple architectures at the same time (within the same binary).
What you need to do is to make this process dynamic. This can be
achieved via a couple of things: Register the GDB_OSABI_FREEBSD_ELF
osabi, attaching an ABI-init routine, and turning the various macros
into struct gdbarch_tdep field. I'm having a hard time being more
precise, because the exact work will depend on whether you need to
create your own -tdep file for fbsd or not (I would imagine that
you will - except that it seems that the nbsd and fbsd tdep files
would otherwise share a lot of code). I hope that Mark will be
able to give you additional guidance.
More information about the freebsd-mips