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]
Other format: [Raw text]

RFA: patch to display ia64 function pointers


The following patch fixes the problem when displaying structs or function
pointers that actually point to a function descriptor per the ia64 ABI.
Currently, the function descriptor pointer is erroneously interpreted as
pointing to a function and so gdb spits out some meaningless information.

With the patch, you get to see the actual function that the pointer
is referencing via the function descriptor.

Ok to commit?

2003-07-31 Jeff Johnston <jjohnstn@redhat.com>

	* ia64-tdep.c (ia64_convert_from_func_addr): New function.
	(ia64_gdbarch_init): Call set_gdbarch_convert_from_func_addr().
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.92
diff -u -p -r1.92 ia64-tdep.c
--- ia64-tdep.c	23 Jul 2003 18:32:19 -0000	1.92
+++ ia64-tdep.c	31 Jul 2003 21:55:46 -0000
@@ -1852,6 +1852,23 @@ find_func_descr (CORE_ADDR faddr, CORE_A
   return fdesc; 
 }
 
+/* Use the following routine when printing out function pointers
+   so the user can see the function address rather than just the
+   function descriptor.  */
+static CORE_ADDR
+ia64_convert_from_func_ptr_addr (CORE_ADDR addr)
+{
+  struct obj_section *s;
+
+  s = find_pc_section (addr);
+
+  /* check if ADDR points to a function descriptor.  */
+  if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
+    return read_memory_unsigned_integer (addr, 8);
+
+  return addr;
+}
+
 static CORE_ADDR
 ia64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
 		      struct regcache *regcache, CORE_ADDR bp_addr,
@@ -2277,6 +2294,7 @@ ia64_gdbarch_init (struct gdbarch_info i
   set_gdbarch_deprecated_register_convertible (gdbarch, ia64_register_convertible);
   set_gdbarch_deprecated_register_convert_to_virtual (gdbarch, ia64_register_convert_to_virtual);
   set_gdbarch_deprecated_register_convert_to_raw (gdbarch, ia64_register_convert_to_raw);
+  set_gdbarch_convert_from_func_ptr_addr (gdbarch, ia64_convert_from_func_ptr_addr);
 
   set_gdbarch_use_struct_convention (gdbarch, ia64_use_struct_convention);
   set_gdbarch_deprecated_extract_return_value (gdbarch, ia64_extract_return_value);

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