From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2066 invoked by alias); 13 Feb 2004 01:14:14 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 2054 invoked from network); 13 Feb 2004 01:14:13 -0000 Received: from unknown (HELO palrel13.hp.com) (156.153.255.238) by sources.redhat.com with SMTP; 13 Feb 2004 01:14:13 -0000 Received: from hplms2.hpl.hp.com (hplms2.hpl.hp.com [15.0.152.33]) by palrel13.hp.com (Postfix) with ESMTP id 9CB641C00102; Thu, 12 Feb 2004 17:14:12 -0800 (PST) Received: from napali.hpl.hp.com (napali.hpl.hp.com [15.4.89.123]) by hplms2.hpl.hp.com (8.12.10/8.12.10/HPL-PA Hub) with ESMTP id i1D1EAD6020149; Thu, 12 Feb 2004 17:14:11 -0800 (PST) Received: from napali.hpl.hp.com (napali [127.0.0.1]) by napali.hpl.hp.com (8.12.11/8.12.11/Debian-1) with ESMTP id i1D1EAUx019962; Thu, 12 Feb 2004 17:14:10 -0800 Received: (from davidm@localhost) by napali.hpl.hp.com (8.12.11/8.12.11/Debian-1) id i1D1EA4v019958; Thu, 12 Feb 2004 17:14:10 -0800 From: David Mosberger MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16428.9442.113820.725379@napali.hpl.hp.com> Date: Fri, 13 Feb 2004 01:14:00 -0000 To: Mark Kettenis Cc: davidm@hpl.hp.com, kevinb@redhat.com, jjohnstn@redhat.com, gdb-patches@sources.redhat.com Subject: Re: make inferior calls work on ia64 even when syscall is pending In-Reply-To: <200312312333.hBVNXNvg016633@elgar.kettenis.dyndns.org> References: <16371.12104.503371.251351@napali.hpl.hp.com> <200312312333.hBVNXNvg016633@elgar.kettenis.dyndns.org> Reply-To: davidm@hpl.hp.com X-URL: http://www.hpl.hp.com/personal/David_Mosberger/ X-SW-Source: 2004-02/txt/msg00335.txt.bz2 >>>>> On Thu, 1 Jan 2004 00:33:23 +0100 (CET), Mark Kettenis said: Mark> From: David Mosberger 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 * 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);