2004-06-07 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / i386-nto-tdep.c
index b35dd2a13b77710a9293593633c652c6c4aea7e1..8538db7acf7c76630615f6d50260f825518cc349 100644 (file)
@@ -1,6 +1,6 @@
-/* i386-nto-tdep.c - i386 specific functionality for QNX Neutrino.
+/* Target-dependent code for QNX Neutrino x86.
 
-   Copyright 2003 Free Software Foundation, Inc.
+   Copyright 2003, 2004 Free Software Foundation, Inc.
 
    Contributed by QNX Software Systems Ltd.
 
@@ -87,9 +87,9 @@ static void
 i386nto_supply_fpregset (char *fpregs)
 {
   if (nto_cpuinfo_valid && nto_cpuinfo_flags | X86_CPU_FXSR)
-    i387_supply_fxsave (fpregs);
+    i387_supply_fxsave (current_regcache, -1, fpregs);
   else
-    i387_supply_fsave (fpregs);
+    i387_supply_fsave (current_regcache, -1, fpregs);
 }
 
 static void
@@ -225,20 +225,34 @@ i386nto_svr4_fetch_link_map_offsets (void)
   return lmp;
 }
 
+/* Return whether the frame preceding NEXT_FRAME corresponds to a QNX
+   Neutrino sigtramp routine.  */
+
 static int
-i386nto_pc_in_sigtramp (CORE_ADDR pc, char *name)
+i386nto_sigtramp_p (struct frame_info *next_frame)
 {
+  CORE_ADDR pc = frame_pc_unwind (next_frame);
+  char *name;
+
+  find_pc_partial_function (pc, &name, NULL, NULL);
   return name && strcmp ("__signalstub", name) == 0;
 }
 
-#define SIGCONTEXT_OFFSET 136
+#define I386_NTO_SIGCONTEXT_OFFSET 136
+
+/* Assuming NEXT_FRAME is a frame following a QNX Neutrino sigtramp
+   routine, return the address of the associated sigcontext structure.  */
+
 static CORE_ADDR
-i386nto_sigcontext_addr (struct frame_info *frame)
+i386nto_sigcontext_addr (struct frame_info *next_frame)
 {
-  if (get_next_frame (frame))
-    return get_frame_base (get_next_frame (frame)) + SIGCONTEXT_OFFSET;
+  char buf[4];
+  CORE_ADDR sp;
+
+  frame_unwind_register (next_frame, I386_ESP_REGNUM, buf);
+  sp = extract_unsigned_integer (buf, 4);
 
-  return read_register (SP_REGNUM) + SIGCONTEXT_OFFSET;
+  return sp + I386_NTO_SIGCONTEXT_OFFSET;
 }
 
 static void
@@ -263,14 +277,15 @@ i386nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* NTO uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
 
-  /* Neutrino rewinds to look more normal.  */
+  /* Neutrino rewinds to look more normal.  Need to override the i386
+     default which is [unfortunately] to decrement the PC.  */
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
 
   /* NTO has shared libraries.  */
   set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
   set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
 
-  set_gdbarch_pc_in_sigtramp (gdbarch, i386nto_pc_in_sigtramp);
+  tdep->sigtramp_p = i386nto_sigtramp_p;
   tdep->sigcontext_addr = i386nto_sigcontext_addr;
   tdep->sc_pc_offset = 56;
   tdep->sc_sp_offset = 68;
This page took 0.024166 seconds and 4 git commands to generate.