* [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd
@ 2009-10-12 21:55 Steve Kargl
[not found] ` <20091014050550.GV5272@adacore.com>
0 siblings, 1 reply; 7+ messages in thread
From: Steve Kargl @ 2009-10-12 21:55 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 211 bytes --]
The attach patch allows gdb-7.0 (and 6.8) to build
on x86_64-*-freebsd. Revision 189903 of FreeBSD's
sys/amd64/include/pcb.h removed the pcb_fs, pcb_gs,
pcb_ds, and pcb_es members of the structure.
--
Steve
[-- Attachment #2: a.diff --]
[-- Type: text/x-diff, Size: 746 bytes --]
--- amd64fbsd-nat.c.orig 2009-10-12 14:38:56.000000000 -0700
+++ amd64fbsd-nat.c 2009-10-12 14:40:13.000000000 -0700
@@ -95,6 +95,7 @@
#include <sys/types.h>
#include <machine/pcb.h>
+#include <osreldate.h>
#include "bsd-kvm.h"
@@ -123,10 +124,12 @@
regcache_raw_supply (regcache, 13, &pcb->pcb_r13);
regcache_raw_supply (regcache, 14, &pcb->pcb_r14);
regcache_raw_supply (regcache, 15, &pcb->pcb_r15);
+#if (__FreeBSD_version < 900000)
regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds);
regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es);
regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs);
regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs);
+#endif
return 1;
}
^ permalink raw reply [flat|nested] 7+ messages in thread[parent not found: <20091014050550.GV5272@adacore.com>]
[parent not found: <1530bbfee75f68f9c32262460f1ec7f9.squirrel@webmail.xs4all.nl>]
[parent not found: <20091015021317.GD5288@adacore.com>]
[parent not found: <20091015230013.GA49371@troutmask.apl.washington.edu>]
* Re: [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd [not found] ` <20091015230013.GA49371@troutmask.apl.washington.edu> @ 2009-10-16 23:22 ` Joel Brobecker 2009-10-17 0:17 ` Steve Kargl 0 siblings, 1 reply; 7+ messages in thread From: Joel Brobecker @ 2009-10-16 23:22 UTC (permalink / raw) To: Steve Kargl, gdb-patches [gdb-patches added back] I sent a private note to Mark asking whether he wanted to review this patch and he approved it. The version number was further refined based on feedback from the FreeBSD developers, I believe. So I checked in this change for Mark (who is currently traveling). What I am not sure I understand completely is whether this patch is required for gdb-7.x or not. On the one hand, you say it should compile fine on FreeBSD 8.0 (which is coming up for release, hopefully soon). But then you say that the fields has been removed from 8.0 and mainline, and so it's needed. I wonder if it was just a typo meaning ix86-*-freebsd instead of x86_64-*-freebsd. If this is the case, then the patch is needed for gdb-7.1 to build on FreeBSD 8.x and later. On Thu, Oct 15, 2009 at 04:00:13PM -0700, Steve Kargl wrote: > On Wed, Oct 14, 2009 at 07:13:17PM -0700, Joel Brobecker wrote: > > > I think this diff is perfectly fine. There is no reason to punish everybody > > > with a configure check that only makes sense on FreeBSD. > > > A comment would be fine though. > > > > Makes sense. And I can commit the patch for you. Steve, can you send > > an updated patch on the gdb-patches list, with the correct version number > > as well as a small comment explaining why this is needed? I'll then > > commit the patch using the "tiny change" rule. > > > > I've attached the updated patch. gdb-7.x should compile > out-of-the-box on FreeBSD 8.0 (when released) and mainline > x86_64-*-freebsd. The reason the patch is needed is that > the members pcb_{fs,ds,es,gs} of the pcb struct in > sys/amd64/include/pcb.h have been removed in mainline and > for the upcoming FreeBSD 8.0 release. > > 2008-10-15 Steven G. Kargl <kargl@gcc.gnu.org> > > * amd64fbsd-nat.c (amd64fbsd_supply_pcb): Conditionally compile in > support for pcb->pcb_{fs,ds,es,gs} on FreeBSD older than 8.0. > > -- > Steve > --- amd64fbsd-nat.c.orig 2009-10-12 14:38:56.000000000 -0700 > +++ amd64fbsd-nat.c 2009-10-12 14:40:13.000000000 -0700 > @@ -95,6 +95,7 @@ > > #include <sys/types.h> > #include <machine/pcb.h> > +#include <osreldate.h> > > #include "bsd-kvm.h" > > @@ -123,10 +124,12 @@ > regcache_raw_supply (regcache, 13, &pcb->pcb_r13); > regcache_raw_supply (regcache, 14, &pcb->pcb_r14); > regcache_raw_supply (regcache, 15, &pcb->pcb_r15); > +#if (__FreeBSD_version < 800075) > regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds); > regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es); > regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs); > regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs); > +#endif > > return 1; > } -- Joel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd 2009-10-16 23:22 ` Joel Brobecker @ 2009-10-17 0:17 ` Steve Kargl 2009-10-17 4:19 ` Joel Brobecker 2009-10-17 5:06 ` Sérgio Durigan Júnior 0 siblings, 2 replies; 7+ messages in thread From: Steve Kargl @ 2009-10-17 0:17 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches On Fri, Oct 16, 2009 at 04:22:38PM -0700, Joel Brobecker wrote: > [gdb-patches added back] > > I sent a private note to Mark asking whether he wanted to review > this patch and he approved it. The version number was further > refined based on feedback from the FreeBSD developers, I believe. > > So I checked in this change for Mark (who is currently traveling). > > What I am not sure I understand completely is whether this patch > is required for gdb-7.x or not. On the one hand, you say it should > compile fine on FreeBSD 8.0 (which is coming up for release, hopefully > soon). But then you say that the fields has been removed from > 8.0 and mainline, and so it's needed. I wonder if it was just a typo > meaning ix86-*-freebsd instead of x86_64-*-freebsd. If this is the > case, then the patch is needed for gdb-7.1 to build on FreeBSD 8.x > and later. The patch is required for x86_64-*-freebsd. I'm deleting a bunch of context to get to the relevant portion of the diff. > > +#if (__FreeBSD_version < 800075) > > regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds); > > regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es); > > regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs); > > regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs); > > +#endif The above number 800075 means that any version of FreeBSD with __FreeBSD_version less than 800075 will have a struct pcb with the pcb_{fged} members. Any version with __FreeBSD_version greater than or equal to 800075 will have these structure members removed. The '8' in 800075 signifies the FreeBSD 8-branch. The '75' signifies that 75 changes have occurred on the FreeBSD 8-branch that might need special handling. The removal of the struct members occurred on 2009-04-01 while the version number was bumped to 800075 on 2009-04-06. It's the closest version number that will work in the '#if (...)' that will allow the gdb-7.x branch to build on all versions of FreeBSD on the amd64 architecture including the 8.0-Release Candidates (ie., the beta releases). -- Steve ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd 2009-10-17 0:17 ` Steve Kargl @ 2009-10-17 4:19 ` Joel Brobecker 2009-10-17 5:06 ` Sérgio Durigan Júnior 1 sibling, 0 replies; 7+ messages in thread From: Joel Brobecker @ 2009-10-17 4:19 UTC (permalink / raw) To: Steve Kargl; +Cc: gdb-patches > The patch is required for x86_64-*-freebsd. Applied to the gdb-7.0 branch. -- Joel ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd 2009-10-17 0:17 ` Steve Kargl 2009-10-17 4:19 ` Joel Brobecker @ 2009-10-17 5:06 ` Sérgio Durigan Júnior 2009-10-19 19:53 ` Joel Brobecker 1 sibling, 1 reply; 7+ messages in thread From: Sérgio Durigan Júnior @ 2009-10-17 5:06 UTC (permalink / raw) To: gdb-patches; +Cc: Steve Kargl, Joel Brobecker On Friday 16 October 2009, Steve Kargl wrote: > > > +#if (__FreeBSD_version < 800075) > > > regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds); > > > regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es); > > > regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs); > > > regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs); > > > +#endif > > The above number 800075 means that any version of FreeBSD > with __FreeBSD_version less than 800075 will have a struct pcb > with the pcb_{fged} members. Any version with __FreeBSD_version > greater than or equal to 800075 will have these structure members > removed. The '8' in 800075 signifies the FreeBSD 8-branch. > The '75' signifies that 75 changes have occurred on the FreeBSD > 8-branch that might need special handling. The removal of the > struct members occurred on 2009-04-01 while the version number > was bumped to 800075 on 2009-04-06. It's the closest version > number that will work in the '#if (...)' that will allow the > gdb-7.x branch to build on all versions of FreeBSD on the amd64 > architecture including the 8.0-Release Candidates (ie., the > beta releases). Hi Steve, Thank you for this patch. I believe you could add a comment explaining what this number means (just like you did above). What do you think? Just my two cents, as usual :-). Regards, -- Sérgio Durigan Júnior Linux on Power Toolchain - Software Engineer Linux Technology Center - LTC IBM Brazil ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd 2009-10-17 5:06 ` Sérgio Durigan Júnior @ 2009-10-19 19:53 ` Joel Brobecker 2009-10-19 20:34 ` Steve Kargl 0 siblings, 1 reply; 7+ messages in thread From: Joel Brobecker @ 2009-10-19 19:53 UTC (permalink / raw) To: S?rgio Durigan J?nior; +Cc: gdb-patches, Steve Kargl [-- Attachment #1: Type: text/plain, Size: 1229 bytes --] Hi Sergio, > Thank you for this patch. I believe you could add a comment explaining what > this number means (just like you did above). What do you think? > Just my two cents, as usual :-). I just applied the following patch (head only) 2009-10-19 Joel Brobecker <brobecker@adacore.com> * amd64fbsd-nat.c (amd64fbsd_supply_pcb): Add comment. Writing the comment made me think that we may have chosen the wrong version number, depending on the angle we look at things from: If we want to always be able to build, then we should have chosen version 74, since there are a few days where version 74 is missing the field and yet the GDB code still tries to access it for that versio number. However, if we're trying to have our code always use these fields whenver possible, then 75 is the right choice. Although we'll fail to build for any sources that's in between the moment the fields were removed and the moment the version was bumped to 75 (a time period of about a few days), we'll be able use these fields for the rest of version 74 of the sources. Based on the number of days this window is open, I would say that this situation is highly unlikely, and so we don't really need to worry about it. -- Joel [-- Attachment #2: comment.diff --] [-- Type: text/x-diff, Size: 1041 bytes --] Index: amd64fbsd-nat.c =================================================================== RCS file: /cvs/src/src/gdb/amd64fbsd-nat.c,v retrieving revision 1.23 diff -u -p -r1.23 amd64fbsd-nat.c --- amd64fbsd-nat.c 16 Oct 2009 23:18:27 -0000 1.23 +++ amd64fbsd-nat.c 19 Oct 2009 19:47:18 -0000 @@ -125,6 +125,11 @@ amd64fbsd_supply_pcb (struct regcache *r regcache_raw_supply (regcache, 14, &pcb->pcb_r14); regcache_raw_supply (regcache, 15, &pcb->pcb_r15); #if (__FreeBSD_version < 800075) + /* struct pcb provides the pcb_ds/pcb_es/pcb_fs/pcb_gs fields only + up until __FreeBSD_version 800074: The removal of these fields + occurred on 2009-04-01 while the __FreeBSD_version number was + bumped to 800075 on 2009-04-06. So 800075 is the closest version + number where we should not try to access these fields. */ regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds); regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es); regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd 2009-10-19 19:53 ` Joel Brobecker @ 2009-10-19 20:34 ` Steve Kargl 0 siblings, 0 replies; 7+ messages in thread From: Steve Kargl @ 2009-10-19 20:34 UTC (permalink / raw) To: Joel Brobecker; +Cc: S?rgio Durigan J?nior, gdb-patches On Mon, Oct 19, 2009 at 09:53:07PM +0200, Joel Brobecker wrote: > Hi Sergio, > > > Thank you for this patch. I believe you could add a comment explaining what > > this number means (just like you did above). What do you think? > > Just my two cents, as usual :-). > > I just applied the following patch (head only) > > 2009-10-19 Joel Brobecker <brobecker@adacore.com> > > * amd64fbsd-nat.c (amd64fbsd_supply_pcb): Add comment. > > Writing the comment made me think that we may have chosen the wrong > version number, depending on the angle we look at things from: If we > want to always be able to build, then we should have chosen version > 74, since there are a few days where version 74 is missing the field > and yet the GDB code still tries to access it for that versio number. > However, if we're trying to have our code always use these fields > whenver possible, then 75 is the right choice. Although we'll fail > to build for any sources that's in between the moment the fields were > removed and the moment the version was bumped to 75 (a time period > of about a few days), we'll be able use these fields for the rest > of version 74 of the sources. > > Based on the number of days this window is open, I would say that this > situation is highly unlikely, and so we don't really need to worry about > it. > You may be correct that a different version should have been used. OTOH, gdb-6.8 was released on 2008-02-29 and the problematic code is present in 6.8. I haven't seen anyone complain on the FreeBSD mailing lists that they can't build 6.8. In looking at FreeBSD's Port Collection, I find /usr/ports/devel/gdb6. This still uses the gdb 6.6 tarball. In looking at the port, I find troutmask:sgk[228] cd /usr/ports/devel/gdb6 troutmask:sgk[229] more files/patch-gdb-amd64fbsd-nat.c --- gdb/amd64fbsd-nat.c.orig 2005-12-17 17:33:59.000000000 -0500 +++ gdb/amd64fbsd-nat.c 2009-09-10 02:29:33.000000000 -0400 @@ -125,10 +125,12 @@ regcache_raw_supply (regcache, 13, &pcb->pcb_r13); regcache_raw_supply (regcache, 14, &pcb->pcb_r14); regcache_raw_supply (regcache, 15, &pcb->pcb_r15); +#if defined(__FreeBSD_version) && __FreeBSD_version < 800000 regcache_raw_supply (regcache, AMD64_DS_REGNUM, &pcb->pcb_ds); regcache_raw_supply (regcache, AMD64_ES_REGNUM, &pcb->pcb_es); regcache_raw_supply (regcache, AMD64_FS_REGNUM, &pcb->pcb_fs); regcache_raw_supply (regcache, AMD64_GS_REGNUM, &pcb->pcb_gs); +#endif return 1; } Apparently, whoever is responsible for this port never forwarded their patch upstream to the gdb developers. Oh well. -- Steve ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-10-19 20:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-12 21:55 [PATCH] Fix building gdb-7.0 on x86_64-*-freebsd Steve Kargl
[not found] ` <20091014050550.GV5272@adacore.com>
[not found] ` <1530bbfee75f68f9c32262460f1ec7f9.squirrel@webmail.xs4all.nl>
[not found] ` <20091015021317.GD5288@adacore.com>
[not found] ` <20091015230013.GA49371@troutmask.apl.washington.edu>
2009-10-16 23:22 ` Joel Brobecker
2009-10-17 0:17 ` Steve Kargl
2009-10-17 4:19 ` Joel Brobecker
2009-10-17 5:06 ` Sérgio Durigan Júnior
2009-10-19 19:53 ` Joel Brobecker
2009-10-19 20:34 ` Steve Kargl
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox