This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: make inferior calls work on ia64 even when syscall is pending
- From: David Mosberger <davidm at napali dot hpl dot hp dot com>
- To: Mark Kettenis <kettenis at chello dot nl>
- Cc: davidm at hpl dot hp dot com, kevinb at redhat dot com, jjohnstn at redhat dot com,gdb-patches at sources dot redhat dot com
- Date: Thu, 12 Feb 2004 17:14:10 -0800
- Subject: Re: make inferior calls work on ia64 even when syscall is pending
- References: <16371.12104.503371.251351@napali.hpl.hp.com><200312312333.hBVNXNvg016633@elgar.kettenis.dyndns.org>
- Reply-to: davidm at hpl dot hp dot com
>>>>> On Thu, 1 Jan 2004 00:33:23 +0100 (CET), Mark Kettenis <kettenis@chello.nl> said:
Mark> From: David Mosberger <davidm@napali.hpl.hp.com> Date: Wed,
Mark> 31 Dec 2003 12:19:20 -0800
Mark> If the gdb patch looks OK, please check it in.
Mark> David, there are two issues with the patch:
Mark> * I suspect that this approach is Linux-specific. If so, you
Mark> really shouldn't be adding this bit of code to the generic
Mark> ia64_write_pc(). Instead you should create a Linux-specific
Mark> ia64_linux_write_pc() and put it in ia64-linux-tdep.c; you'll
Mark> probably want to call the generic ia64_write_pc() from there.
Mark> Then you must hook in the Linux-specific version if the OSABI
Mark> is GDB_OSABI_LINUX.
Mark> * You should use write_register_pid() instead of
Mark> write_register().
How about the attached patch?
--david
ChangeLog
2004-02-12 David Mosberger <davidm@hpl.hp.com>
* ia64-tdep.c (ia64_linux_write_pc): Declare as extern.
(ia64_write_pc): Make it a global function.
(ia64_gdbarch_init): For Linux targets, use ia64_linux_write_pc()
instead of ia64_write_pc().
* ia64-linux-tdep.c (ia64_write_pc): Declare as extern.
(ia64_linux_write_pc): New function. Works like ia64_write_pc(),
except that it also clears r10 afterwards to prevent the kernel
from attempting to restart an interrupt system call.
Index: ia64-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-linux-tdep.c,v
retrieving revision 1.5
diff -u -r1.5 ia64-linux-tdep.c
--- ia64-linux-tdep.c 8 Jan 2004 16:46:27 -0000 1.5
+++ ia64-linux-tdep.c 13 Feb 2004 01:12:11 -0000
@@ -34,6 +34,8 @@
/* Offset to sigcontext structure from frame of handler */
#define IA64_LINUX_SIGCONTEXT_OFFSET 192
+extern void ia64_write_pc (CORE_ADDR, ptid_t);
+
int
ia64_linux_in_sigtramp (CORE_ADDR pc, char *func_name)
{
@@ -92,4 +94,21 @@
default :
return 0;
}
+}
+
+void
+ia64_linux_write_pc (CORE_ADDR pc, ptid_t ptid)
+{
+ ia64_write_pc (pc, ptid);
+
+ /* We must be careful with modifying the instruction-pointer: if we
+ just interrupt a system call, the kernel would ordinarily try to
+ restart it when we resume the inferior, which typically results
+ in SIGSEGV or SIGILL. We prevent this by clearing r10, which
+ will tell the kernel that r8 does NOT contain a valid error code
+ and hence it will skip system-call restart.
+
+ The clearing of r10 is safe as long as ia64_linux_write_pc() is only
+ called as part of setting up an inferior call. */
+ write_register_pid (IA64_GR10_REGNUM, 0, ptid);
}
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.112
diff -u -r1.112 ia64-tdep.c
--- ia64-tdep.c 10 Feb 2004 19:35:59 -0000 1.112
+++ ia64-tdep.c 13 Feb 2004 01:12:11 -0000
@@ -94,6 +94,7 @@
extern CORE_ADDR ia64_linux_sigcontext_register_address (CORE_ADDR, int);
extern CORE_ADDR ia64_aix_sigcontext_register_address (CORE_ADDR, int);
extern unsigned long ia64_linux_getunwind_table (void *, size_t);
+extern void ia64_linux_write_pc (CORE_ADDR, ptid_t);
static gdbarch_init_ftype ia64_gdbarch_init;
@@ -632,7 +633,7 @@
return pc_value | (slot_num * SLOT_MULTIPLIER);
}
-static void
+void
ia64_write_pc (CORE_ADDR new_pc, ptid_t ptid)
{
int slot_num = (int) (new_pc & 0xf) / SLOT_MULTIPLIER;
@@ -3339,7 +3348,10 @@
set_gdbarch_memory_remove_breakpoint (gdbarch, ia64_memory_remove_breakpoint);
set_gdbarch_breakpoint_from_pc (gdbarch, ia64_breakpoint_from_pc);
set_gdbarch_read_pc (gdbarch, ia64_read_pc);
- set_gdbarch_write_pc (gdbarch, ia64_write_pc);
+ if (info.osabi == GDB_OSABI_LINUX)
+ set_gdbarch_write_pc (gdbarch, ia64_linux_write_pc);
+ else
+ set_gdbarch_write_pc (gdbarch, ia64_write_pc);
/* Settings for calling functions in the inferior. */
set_gdbarch_push_dummy_call (gdbarch, ia64_push_dummy_call);