Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Fix building on x86 OpenBSD 4.3
@ 2008-08-06 15:11 Pedro Alves
  2008-08-06 15:23 ` Mark Kettenis
  2008-08-06 15:28 ` Mark Kettenis
  0 siblings, 2 replies; 6+ messages in thread
From: Pedro Alves @ 2008-08-06 15:11 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

Hi,

In my testing on several targets, I noticed that GDB isn't
building on x86 OpenBSD 4.3, due to the fact that struct
switchframe got its sf_ppl member removed, and GDB is trying
to access it.

I can't claim I know a think about this, but,

The patch that seems to have removed it, shows that is was always
0 just before removal:

 http://archive.netbsd.se/?ml=openbsd-tech&a=2007-09&m=5239543

And I can see it being set to != 0 in that files' history at:
 http://opengrok.creo.hu/openbsd/history/src/sys/arch/i386/i386/vm_machdep.c

So, I guess that the attached is the best to do, and I didn't
notice any breakage.  Of course, I don't even know what
triggers this code path.  :-)

Mark, perhaps you have a better fix in your local trees?

OK?

-- 
Pedro Alves

[-- Attachment #2: obsd_build_4.3.diff --]
[-- Type: text/x-diff, Size: 1775 bytes --]

2008-08-06  Pedro Alves  <pedro@codesourcery.com>

	* i386obsd-nat.c (i386obsd_supply_pcb): Remove handling of
	switchframe.sf_ppl != 0.

---
 gdb/i386obsd-nat.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

Index: src/gdb/i386obsd-nat.c
===================================================================
--- src.orig/gdb/i386obsd-nat.c	2008-01-01 22:53:11.000000000 +0000
+++ src/gdb/i386obsd-nat.c	2008-08-06 16:00:41.000000000 +0100
@@ -61,21 +61,12 @@ i386obsd_supply_pcb (struct regcache *re
      checking if the saved interrupt priority level in the stack frame
      looks reasonable..  */
   read_memory (pcb->pcb_esp, (char *) &sf, sizeof sf);
-  if ((unsigned int) sf.sf_ppl < 0x100 && (sf.sf_ppl & 0xf) == 0)
-    {
-      /* Yes, we have a frame that matches cpu_switch().  */
-      pcb->pcb_esp += sizeof (struct switchframe);
-      regcache_raw_supply (regcache, I386_EDI_REGNUM, &sf.sf_edi);
-      regcache_raw_supply (regcache, I386_ESI_REGNUM, &sf.sf_esi);
-      regcache_raw_supply (regcache, I386_EBX_REGNUM, &sf.sf_ebx);
-      regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
-    }
-  else
-    {
-      /* No, the pcb must have been last updated by savectx().  */
-      pcb->pcb_esp += 4;
-      regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf);
-    }
+
+  pcb->pcb_esp += sizeof (struct switchframe);
+  regcache_raw_supply (regcache, I386_EDI_REGNUM, &sf.sf_edi);
+  regcache_raw_supply (regcache, I386_ESI_REGNUM, &sf.sf_esi);
+  regcache_raw_supply (regcache, I386_EBX_REGNUM, &sf.sf_ebx);
+  regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
 
   regcache_raw_supply (regcache, I386_EBP_REGNUM, &pcb->pcb_ebp);
   regcache_raw_supply (regcache, I386_ESP_REGNUM, &pcb->pcb_esp);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix building on x86 OpenBSD 4.3
  2008-08-06 15:11 Fix building on x86 OpenBSD 4.3 Pedro Alves
@ 2008-08-06 15:23 ` Mark Kettenis
  2008-08-06 15:28 ` Mark Kettenis
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2008-08-06 15:23 UTC (permalink / raw)
  To: pedro; +Cc: gdb-patches

> From: Pedro Alves <pedro@codesourcery.com>
> Date: Wed, 6 Aug 2008 16:10:44 +0100
> 
> Hi,
> 
> In my testing on several targets, I noticed that GDB isn't
> building on x86 OpenBSD 4.3, due to the fact that struct
> switchframe got its sf_ppl member removed, and GDB is trying
> to access it.
> 
> I can't claim I know a think about this, but,
> 
> The patch that seems to have removed it, shows that is was always
> 0 just before removal:
> 
>  http://archive.netbsd.se/?ml=openbsd-tech&a=2007-09&m=5239543
> 
> And I can see it being set to != 0 in that files' history at:
>  http://opengrok.creo.hu/openbsd/history/src/sys/arch/i386/i386/vm_machdep.c
> 
> So, I guess that the attached is the best to do, and I didn't
> notice any breakage.  Of course, I don't even know what
> triggers this code path.  :-)
> 
> Mark, perhaps you have a better fix in your local trees?

Oops, yes I have.  Fixed this and never seemed to have committed the
fix when OpenBSD 4.3 was officially released.  Need to tweak it such
that the file compiles on older OpenBSD releases though.

Thanks for pointing this out.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix building on x86 OpenBSD 4.3
  2008-08-06 15:11 Fix building on x86 OpenBSD 4.3 Pedro Alves
  2008-08-06 15:23 ` Mark Kettenis
@ 2008-08-06 15:28 ` Mark Kettenis
  2008-08-06 15:33   ` Pedro Alves
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Kettenis @ 2008-08-06 15:28 UTC (permalink / raw)
  To: pedro; +Cc: gdb-patches

> From: Pedro Alves <pedro@codesourcery.com>
> Date: Wed, 6 Aug 2008 16:10:44 +0100
> 
> Hi,
> 
> In my testing on several targets, I noticed that GDB isn't
> building on x86 OpenBSD 4.3, due to the fact that struct
> switchframe got its sf_ppl member removed, and GDB is trying
> to access it.
> 
> I can't claim I know a think about this, but,
> 
> The patch that seems to have removed it, shows that is was always
> 0 just before removal:
> 
>  http://archive.netbsd.se/?ml=openbsd-tech&a=2007-09&m=5239543
> 
> And I can see it being set to != 0 in that files' history at:
>  http://opengrok.creo.hu/openbsd/history/src/sys/arch/i386/i386/vm_machdep.c
> 
> So, I guess that the attached is the best to do, and I didn't
> notice any breakage.  Of course, I don't even know what
> triggers this code path.  :-)
> 
> Mark, perhaps you have a better fix in your local trees?

Oops, yes I have.  Fixed this and never seemed to have committed the
fix when OpenBSD 4.3 was officially released.  Need to tweak it such
that the file compiles on older OpenBSD releases though.  I guess
that's what kept me from committing this.

Thanks for pointing this out, I'll fix it ASAP.

Mark



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix building on x86 OpenBSD 4.3
  2008-08-06 15:28 ` Mark Kettenis
@ 2008-08-06 15:33   ` Pedro Alves
  2008-08-06 15:52     ` Mark Kettenis
  2008-08-06 20:04     ` Mark Kettenis
  0 siblings, 2 replies; 6+ messages in thread
From: Pedro Alves @ 2008-08-06 15:33 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

> > And I can see it being set to != 0 in that files' history at:

         ^^^ Of course, I meant *can't* here.  :-)

> http://opengrok.creo.hu/openbsd/history/src/sys/arch/i386/i386/vm_machdep.c

> Thanks for pointing this out, I'll fix it ASAP.

Thanks!

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix building on x86 OpenBSD 4.3
  2008-08-06 15:33   ` Pedro Alves
@ 2008-08-06 15:52     ` Mark Kettenis
  2008-08-06 20:04     ` Mark Kettenis
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2008-08-06 15:52 UTC (permalink / raw)
  To: pedro; +Cc: gdb-patches

> From: Pedro Alves <pedro@codesourcery.com>
> Date: Wed, 6 Aug 2008 16:32:57 +0100
> 
> > > And I can see it being set to != 0 in that files' history at:
> 
>          ^^^ Of course, I meant *can't* here.  :-)
> 
> > http://opengrok.creo.hu/openbsd/history/src/sys/arch/i386/i386/vm_machdep.c

Oh, it's well hidden.  It happens in assembly code in locore.s ;).


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Fix building on x86 OpenBSD 4.3
  2008-08-06 15:33   ` Pedro Alves
  2008-08-06 15:52     ` Mark Kettenis
@ 2008-08-06 20:04     ` Mark Kettenis
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2008-08-06 20:04 UTC (permalink / raw)
  To: pedro; +Cc: gdb-patches

> From: Pedro Alves <pedro@codesourcery.com>
> Date: Wed, 6 Aug 2008 16:32:57 +0100
> 
> > > And I can see it being set to != 0 in that files' history at:
> 
>          ^^^ Of course, I meant *can't* here.  :-)
> 
> > http://opengrok.creo.hu/openbsd/history/src/sys/arch/i386/i386/vm_machdep.c
> 
> > Thanks for pointing this out, I'll fix it ASAP.
> 
> Thanks!

I just comitted the attached patch.


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i386obsd-nat.c (i386obsd_supply_pcb): Adjust for changes in
	OpenBSD 4.3.

Index: i386obsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386obsd-nat.c,v
retrieving revision 1.11
diff -u -p -r1.11 i386obsd-nat.c
--- i386obsd-nat.c 1 Jan 2008 22:53:11 -0000 1.11
+++ i386obsd-nat.c 6 Aug 2008 19:34:38 -0000
@@ -60,10 +60,11 @@ i386obsd_supply_pcb (struct regcache *re
   /* Read the stack frame, and check its validity.  We do this by
      checking if the saved interrupt priority level in the stack frame
      looks reasonable..  */
-  read_memory (pcb->pcb_esp, (char *) &sf, sizeof sf);
-  if ((unsigned int) sf.sf_ppl < 0x100 && (sf.sf_ppl & 0xf) == 0)
+#ifdef PCB_SAVECTX
+  if ((pcb->pcb_flags & PCB_SAVECTX) == 0)
     {
       /* Yes, we have a frame that matches cpu_switch().  */
+      read_memory (pcb->pcb_esp, (char *) &sf, sizeof sf);
       pcb->pcb_esp += sizeof (struct switchframe);
       regcache_raw_supply (regcache, I386_EDI_REGNUM, &sf.sf_edi);
       regcache_raw_supply (regcache, I386_ESI_REGNUM, &sf.sf_esi);
@@ -71,9 +72,12 @@ i386obsd_supply_pcb (struct regcache *re
       regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
     }
   else
+#endif
     {
       /* No, the pcb must have been last updated by savectx().  */
-      pcb->pcb_esp += 4;
+      pcb->pcb_esp = pcb->pcb_ebp;
+      pcb->pcb_ebp = read_memory_integer(pcb->pcb_esp, 4);
+      sf.sf_eip = read_memory_integer(pcb->pcb_esp + 4, 4);
       regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf);
     }
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-06 20:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-06 15:11 Fix building on x86 OpenBSD 4.3 Pedro Alves
2008-08-06 15:23 ` Mark Kettenis
2008-08-06 15:28 ` Mark Kettenis
2008-08-06 15:33   ` Pedro Alves
2008-08-06 15:52     ` Mark Kettenis
2008-08-06 20:04     ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox