[AIX] Memory error while checking if pointer is descriptor.
authorJoel Brobecker <brobecker@gnat.com>
Tue, 20 Apr 2010 22:38:54 +0000 (22:38 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 20 Apr 2010 22:38:54 +0000 (22:38 +0000)
A long time ago (Oct 2009), I noticed a problem on AIX, where something
failed with an error while the debugger was checking whether an address
was a descriptor or not.  Unfortunately, like an idiot, I forgot to write
notes about the scenario where the problem occured - I am usually pretty
meticulous about that because my memory of these things is really bad.
I hope you'll forgive me for not providing a solid testcase - if it's
any consolation, I've searched for a long time before giving up :-(.

Based on the testsuite reports that I have, I think that this happened
while inserting a breakpoint, as follow:

    (gdb) break x
    Cannot access memory at address 0x200093b4

What happened is that rs6000_convert_from_func_ptr_addr tried to read
the memory at the given address, and fail because of an exception.
It seems pretty clear that, if the address was in fact a descriptor,
GDB would have been able to read the target memory region.

So this patch protects the memory-read against exceptions, and treats
such exceptions as an indication that our address is not a descriptor.

gdb/ChangeLog:

        * rs6000-aix-tdep.c: #include exceptions.h.
        (rs6000_convert_from_func_ptr_addr): If an exception is thrown
        while reading the memory at ADDR, then ADDR cannot be a function
        descriptor.

gdb/ChangeLog
gdb/rs6000-aix-tdep.c

index fe8bcb790c4812c7085be6a71d04b76541199732..e56a6a12d75930366b6fe8dbd99fa5bd77b7e4a7 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-20  Joel Brobecker  <brobecker@adacore.com>
+
+       * rs6000-aix-tdep.c: #include exceptions.h.
+       (rs6000_convert_from_func_ptr_addr): If an exception is thrown
+       while reading the memory at ADDR, then ADDR cannot be a function
+       descriptor.
+
 2010-04-20  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-typeprint.c (ada_print_typedef): New function.
index 530c12e2a65fb2c4753ed0b9ab29de60f5442f45..927cfe2da203932019f0c2e450507d2cf741de63 100644 (file)
@@ -34,6 +34,7 @@
 #include "breakpoint.h"
 #include "rs6000-tdep.h"
 #include "ppc-tdep.h"
+#include "exceptions.h"
 
 /* Hook for determining the TOC address when calling functions in the
    inferior under AIX. The initialization code in rs6000-nat.c sets
@@ -582,9 +583,22 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
      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, tdep->wordsize, byte_order);
-      struct obj_section *pc_section = find_pc_section (pc);
+      CORE_ADDR pc;
+      struct obj_section *pc_section;
+      struct gdb_exception e;
+
+      TRY_CATCH (e, RETURN_MASK_ERROR)
+        {
+          pc = read_memory_unsigned_integer (addr, tdep->wordsize, byte_order);
+        }
+      if (e.reason < 0)
+        {
+          /* An error occured during reading.  Probably a memory error
+             due to the section not being loaded yet.  This address
+             cannot be a function descriptor.  */
+          return addr;
+        }
+      pc_section = find_pc_section (pc);
 
       if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
         return pc;
This page took 0.027908 seconds and 4 git commands to generate.