make inferior calls work on ia64 even when syscall is pending

Mark Kettenis
Wed Dec 31 23:37:00 GMT 2003

   From: David Mosberger <>
   Date: Wed, 31 Dec 2003 12:19:20 -0800

   If the gdb patch looks OK, please check it in.

David, there are two issues with the patch:

* I suspect that this approach is Linux-specific.  If so, you really
  shouldn't be adding this bit of code to the generic ia64_write_pc().
  Instead you should create a Linux-specific ia64_linux_write_pc() and
  put it in ia64-linux-tdep.c; you'll probably want to call the
  generic ia64_write_pc() from there.  Then you must hook in the
  Linux-specific version if the OSABI is GDB_OSABI_LINUX.

* You should use write_register_pid() instead of write_register().




   2003-12-31  David Mosberger  <>

	   * ia64-tdep.c (ia64_write_pc): Clear r10 after writing the
	   instruction-pointer (PC) to prevent the kernel from attempting to
	   restart an interrupt system call.

   Index: ia64-tdep.c
   RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
   retrieving revision 1.106
   diff -u -r1.106 ia64-tdep.c
   --- ia64-tdep.c	13 Dec 2003 03:51:56 -0000	1.106
   +++ ia64-tdep.c	31 Dec 2003 19:49:49 -0000
   @@ -683,6 +683,17 @@

      write_register_pid (IA64_PSR_REGNUM, psr_value, ptid);
      write_register_pid (IA64_IP_REGNUM, new_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_write_pc() is only
   +     called as part of setting up an inferior call.  */
   +  write_register (IA64_GR10_REGNUM, 0);

    #define IS_NaT_COLLECTION_ADDR(addr) ((((addr) >> 3) & 0x3f) == 0x3f)

More information about the Gdb-patches mailing list