From owner-freebsd-mips@FreeBSD.ORG Mon Mar 7 04:45:57 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35A07106564A for ; Mon, 7 Mar 2011 04:45:57 +0000 (UTC) (envelope-from brobecker@adacore.com) Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by mx1.freebsd.org (Postfix) with ESMTP id DE83B8FC0C for ; Mon, 7 Mar 2011 04:45:56 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 45AA92BAFA1; Sun, 6 Mar 2011 23:35:41 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id oPH-wvD7mzhT; Sun, 6 Mar 2011 23:35:41 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 934682BAF9D; Sun, 6 Mar 2011 23:35:40 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 2C4971459AD; Mon, 7 Mar 2011 08:35:18 +0400 (RET) Date: Mon, 7 Mar 2011 08:35:18 +0400 From: Joel Brobecker To: Robert Millan Message-ID: <20110307043518.GA28588@adacore.com> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-mips@freebsd.org, gdb-patches@sourceware.org Subject: Re: [PATCH] gdb for GNU/kFreeBSD on MIPS X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2011 04:45:57 -0000 --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 > > * 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 . */ > +#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--