Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Mar 2011 08:35:18 +0400
From:      Joel Brobecker <brobecker@adacore.com>
To:        Robert Millan <rmh@gnu.org>
Cc:        freebsd-mips@freebsd.org, gdb-patches@sourceware.org
Subject:   Re: [PATCH] gdb for GNU/kFreeBSD on MIPS
Message-ID:  <20110307043518.GA28588@adacore.com>
In-Reply-To: <AANLkTi=W1aKUiDtn_cQ5UHqzZvJfigviHBMCTexirSQk@mail.gmail.com>
References:  <AANLkTi=W1aKUiDtn_cQ5UHqzZvJfigviHBMCTexirSQk@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--3V7upXqbjpZ4EhLz
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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@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
> +#endif

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.

-- 
Joel

--3V7upXqbjpZ4EhLz--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110307043518.GA28588>