This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] ia64-tdep.c: AIX5 changes


The changes below add machinery to ia64-tdep.c so that the AIX5 native
port can find the global pointer.  This machinery is similar to the
find_toc_address stuff in rs6000-{tdep,nat}.c, but is properly
multiarched so that we could (in theory) debug a Linux/IA-64 target
from an AIX/IA-64 host.

The find_toc_address stuff in rs6000-tdep.c should be multiarched in
the same fashion at some point, but it's not as critical since most of
the PPC targets that people want cross debuggers for don't use the ABI
which require the TOC value.  OTOH, on IA-64, both of the OSes with
which I'm familiar purportedly use the same ABI and both need to be
able to find the global pointer.  It is a pity that the same machinery
could not be used for both.  I still feel that the machinery that the
Linux port uses is generic enough to continue living in ia64-tdep.c. 
There may even come a day when AIX5 will be able to use it too.

	* ia64-tdep.c (native_find_global_pointer):  New global variable.
	(struct gdbarch_tdep): Add member find_global_pointer.
	(ia64_gdbarch_init): Initialize find_global_pointer member.  Also,
	tell the gdbarch machinery that we have floating point registers.
	(FIND_GLOBAL_POINTER): New macro.
	(generic_elf_find_global_pointer):  Renamed from find_global_pointer.
	(find_func_descr, ia64_push_return_address):  Call
	FIND_GLOBAL_POINTER instead of find_global_pointer.
	(process_note_abi_tag_sections):  Enable code previously disabled
	by #if 0.

Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.9
diff -u -p -r1.9 ia64-tdep.c
--- ia64-tdep.c	2000/09/06 07:43:37	1.9
+++ ia64-tdep.c	2000/11/08 04:10:21
@@ -30,6 +30,19 @@
 #include "elf/common.h"		/* for DT_PLTGOT value */
 #include "elf-bfd.h"
 
+/* Hook for determining the global pointer when calling functions in
+   the inferior under AIX.  The initialization code in ia64-aix-nat.c
+   sets this hook to the address of a function which will find the
+   global pointer for a given address.  
+   
+   The generic code which uses the dynamic section in the inferior for
+   finding the global pointer is not of much use on AIX since the
+   values obtained from the inferior have not been relocated.  */
+
+CORE_ADDR (*native_find_global_pointer) (CORE_ADDR) = 0;
+
+/* An enumeration of the different IA-64 instruction types.  */
+
 typedef enum instruction_type
 {
   A,			/* Integer ALU ;    I-unit or M-unit */
@@ -219,9 +232,13 @@ struct gdbarch_tdep
     			/* OS specific function which, given a frame address
 			   and register number, returns the offset to the
 			   given register from the start of the frame. */
+    CORE_ADDR (*find_global_pointer) (CORE_ADDR);
   };
 
-#define SIGCONTEXT_REGISTER_ADDRESS (gdbarch_tdep (current_gdbarch)->sigcontext_register_address)
+#define SIGCONTEXT_REGISTER_ADDRESS \
+  (gdbarch_tdep (current_gdbarch)->sigcontext_register_address)
+#define FIND_GLOBAL_POINTER \
+  (gdbarch_tdep (current_gdbarch)->find_global_pointer)
 
 static char *
 ia64_register_name (int reg)
@@ -1470,7 +1487,7 @@ is_float_or_hfa_type (struct type *t)
    d_un.d_ptr value is the global pointer.  */
 
 static CORE_ADDR
-find_global_pointer (CORE_ADDR faddr)
+generic_elf_find_global_pointer (CORE_ADDR faddr)
 {
   struct obj_section *faddr_sect;
      
@@ -1591,7 +1608,7 @@ find_func_descr (CORE_ADDR faddr, CORE_A
       fdesc = *fdaptr;
       *fdaptr += 16;
 
-      global_pointer = find_global_pointer (faddr);
+      global_pointer = FIND_GLOBAL_POINTER (faddr);
 
       if (global_pointer == 0)
 	global_pointer = read_register (IA64_GR1_REGNUM);
@@ -1772,7 +1789,7 @@ ia64_push_arguments (int nargs, value_pt
 CORE_ADDR
 ia64_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
 {
-  CORE_ADDR global_pointer = find_global_pointer (pc);
+  CORE_ADDR global_pointer = FIND_GLOBAL_POINTER (pc);
 
   if (global_pointer != 0)
     write_register (IA64_GR1_REGNUM, global_pointer);
@@ -1898,14 +1915,12 @@ process_note_abi_tag_sections (bfd *abfd
 	    case 0 :
 	      *os_ident_ptr = ELFOSABI_LINUX;
 	      break;
-#if 0	/* FIXME: Enable after internal repository is synced with sourceware */
 	    case 1 :
 	      *os_ident_ptr = ELFOSABI_HURD;
 	      break;
 	    case 2 :
 	      *os_ident_ptr = ELFOSABI_SOLARIS;
 	      break;
-#endif
 	    default :
 	      internal_error (
 		"process_note_abi_sections: unknown OS number %d", os_number);
@@ -1959,6 +1974,19 @@ ia64_gdbarch_init (struct gdbarch_info i
   else
     tdep->sigcontext_register_address = 0;
 
+  /* We know that Linux won't have to resort to the native_find_global_pointer
+     hackery.  But that's the only one we know about so far, so if
+     native_find_global_pointer is set to something non-zero, then use
+     it.  Otherwise fall back to using generic_elf_find_global_pointer.  
+     This arrangement should (in theory) allow us to cross debug Linux
+     binaries from an AIX machine.  */
+  if (os_ident == ELFOSABI_LINUX)
+    tdep->find_global_pointer = generic_elf_find_global_pointer;
+  else if (native_find_global_pointer != 0)
+    tdep->find_global_pointer = native_find_global_pointer;
+  else
+    tdep->find_global_pointer = generic_elf_find_global_pointer;
+
   set_gdbarch_short_bit (gdbarch, 16);
   set_gdbarch_int_bit (gdbarch, 32);
   set_gdbarch_long_bit (gdbarch, 64);
@@ -1972,6 +2000,7 @@ ia64_gdbarch_init (struct gdbarch_info i
   set_gdbarch_sp_regnum (gdbarch, sp_regnum);
   set_gdbarch_fp_regnum (gdbarch, fp_regnum);
   set_gdbarch_pc_regnum (gdbarch, pc_regnum);
+  set_gdbarch_fp0_regnum (gdbarch, IA64_FR0_REGNUM);
 
   set_gdbarch_register_name (gdbarch, ia64_register_name);
   set_gdbarch_register_size (gdbarch, 8);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]