[commit] print minimal symbol's address correctly...

Joel Brobecker brobecker@adacore.com
Mon Jun 2 03:28:00 GMT 2008


As it turns out, AIX was using the same technique as ia64 to identify
function descriptors (namely: If the address doesn't point to an
executable section, then it must be a function descriptor). See:

   http://www.sourceware.org/ml/gdb-patches/2008-05/msg00740.html

for a description of why this heuristic needs to be improved a bit.

For now, I applied the same change as on ia64. The comment above
the function doing the conversion mentions OPD sections, but it
doesn't apply at all to the actual implementation, and I couldn't
find confirmation of such sections in the few AIX documents that
I have. Perhaps Ulrich could confirm or infirm whether the comment
is accurate? Depending on the outcome, we might want to further
enhance the function.

2008-06-01  Joel Brobecker  <brobecker@adacore.com>

        * rs6000-aix-tdep.c (rs6000_convert_from_func_ptr_addr): Do not
        treat pointers in data space as function descriptors if the
        target address is also in the data space.

Tested on ppc-aix. One test actually transitions from PASS to FAIL,
but I think the PASS was an accident: It's ptype.exp:ptype int.
For some reason, when doing "ptype v_int" (v_int is a global variable
defined as an int), GDB doesn't seem to find any debugging info for
this variable (it should because the file was compiled with -g!).
Because of that, and because rs6000_convert_from_func_ptr_addr used
to treat the address as a function descriptor, GDB would end up
thinking that this is a function pointer, and thus return "type =
int ()". This output satisfies the test because it matches "int.*",
but it's actually not correct.  Now, it prints "<data variable, no
debug info>", which is actually more appropriate for the situation.

Checked in.

-- 
Joel
-------------- next part --------------
Modified: rs6000-aix-tdep.c
===================================================================
--- rs6000-aix-tdep.c	2008-06-01 02:11:07 UTC (rev 131984)
+++ rs6000-aix-tdep.c	2008-06-01 04:45:49 UTC (rev 131985)
@@ -570,11 +570,22 @@
   struct obj_section *s;
 
   s = find_pc_section (addr);
-  if (s && s->the_bfd_section->flags & SEC_CODE)
-    return addr;
 
-  /* ADDR is in the data space, so it's a special function pointer. */
-  return read_memory_unsigned_integer (addr, gdbarch_tdep (gdbarch)->wordsize);
+  /* Normally, functions live inside a section that is executable.
+     So, if ADDR points to a non-executable section, then treat it
+     as a function descriptor and return the target address iff
+     the target address itself points to a section that is executable.  */
+  if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
+    {
+      CORE_ADDR pc =
+        read_memory_unsigned_integer (addr, gdbarch_tdep (gdbarch)->wordsize);
+      struct obj_section *pc_section = find_pc_section (pc);
+
+      if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
+        return pc;
+    }
+
+  return addr;
 }
 
 


More information about the Gdb-patches mailing list