Blame SOURCES/gdb-rhbz1085906-coredump_filter-2of2.patch

0b42f8
commit 416f679e68468ea6dd7384213994ce74201f82e7
0b42f8
Author: Sergio Durigan Junior <sergiodj@redhat.com>
0b42f8
Date:   Tue Mar 31 19:17:23 2015 -0400
0b42f8
0b42f8
    Catch exception on solib_svr4_r_ldsomap
0b42f8
    
0b42f8
    When loading a corefile that has some inaccessible memory region(s),
0b42f8
    GDB complains about it:
0b42f8
    
0b42f8
       (gdb) core /my/corefile
0b42f8
       [New LWP 28468]
0b42f8
       Cannot access memory at address 0x355fc21148
0b42f8
       Cannot access memory at address 0x355fc21140
0b42f8
       (gdb)
0b42f8
    
0b42f8
    However, despite not seeing the message "Core was generated by...", it
0b42f8
    is still possible to inspect the corefile using regular GDB commands.
0b42f8
    The reason for that is because read_memory_unsigned_integer throws an
0b42f8
    exception when it cannot read the memory region, but
0b42f8
    solib_svr4_r_ldsomap was not catching it.  The fix is to catch the
0b42f8
    exception and act accordingly.
0b42f8
    
0b42f8
    Tested on Fedora 20 x86_64, no regressions found.
0b42f8
    
0b42f8
    gdb/ChangeLog:
0b42f8
    2015-03-31  Sergio Durigan Junior  <sergiodj@redhat.com>
0b42f8
    
0b42f8
    	* solib-svr4.c (solib_svr4_r_ldsomap): Catch possible exception by
0b42f8
    	read_memory_unsigned_integer.
0b42f8
0b42f8
### a/gdb/ChangeLog
0b42f8
### b/gdb/ChangeLog
0b42f8
## -1,3 +1,8 @@
0b42f8
+2015-03-31  Sergio Durigan Junior  <sergiodj@redhat.com>
0b42f8
+
0b42f8
+	* solib-svr4.c (solib_svr4_r_ldsomap): Catch possible exception by
0b42f8
+	read_memory_unsigned_integer.
0b42f8
+
0b42f8
 2015-03-31  H.J. Lu  <hongjiu.lu@intel.com>
0b42f8
 
0b42f8
 	* Makefile.in (ZLIB): New.
0b42f8
Index: gdb-7.6.1/gdb/solib-svr4.c
0b42f8
===================================================================
0b42f8
--- gdb-7.6.1.orig/gdb/solib-svr4.c	2015-11-27 22:31:12.059831214 +0100
0b42f8
+++ gdb-7.6.1/gdb/solib-svr4.c	2015-11-27 22:35:17.641182004 +0100
0b42f8
@@ -912,13 +912,22 @@
0b42f8
   struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
0b42f8
   struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
0b42f8
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
0b42f8
-  ULONGEST version;
0b42f8
+  ULONGEST version = 0;
0b42f8
+  volatile struct gdb_exception ex;
0b42f8
+
0b42f8
+  TRY_CATCH (ex, RETURN_MASK_ERROR)
0b42f8
+    {
0b42f8
+      /* Check version, and return zero if `struct r_debug' doesn't have
0b42f8
+	 the r_ldsomap member.  */
0b42f8
+      version
0b42f8
+	= read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
0b42f8
+					lmo->r_version_size, byte_order);
0b42f8
+    }
0b42f8
+  if (ex.reason < 0)
0b42f8
+    {
0b42f8
+      exception_print (gdb_stderr, ex);
0b42f8
+    }
0b42f8
 
0b42f8
-  /* Check version, and return zero if `struct r_debug' doesn't have
0b42f8
-     the r_ldsomap member.  */
0b42f8
-  version
0b42f8
-    = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
0b42f8
-				    lmo->r_version_size, byte_order);
0b42f8
   if (version < 2 || lmo->r_ldsomap_offset == -1)
0b42f8
     return 0;
0b42f8