Blame SOURCES/gdb-rhbz1518243-gcore-VM_DONTDUMP-1of5.patch

01917d
commit afa840dcc021eaeb975dcde3bedbf46ea0511717
01917d
Author: Sergio Lopez <slp@redhat.com>
01917d
Date:   Mon Dec 4 09:17:12 2017 +0100
01917d
01917d
    Implement 'set dump-excluded-mappings' command
01917d
    
01917d
    Commit df8411da087dc05481926f4c4a82deabc5bc3859 implemented support for
01917d
    checking /proc/PID/coredump_filter, and also changed gcore behavior to
01917d
    unconditionally honor the VM_DONTDUMP flag, preventing sections marked
01917d
    as such for being dumped into the core file.
01917d
    
01917d
    This patch implements the 'set dump-excluded-mappings' command for
01917d
    instructing gdb to ignore the VM_DONTDUMP flag. Combined with 'set
01917d
    use-coredump-filter', this allows the user to restore the old behavior,
01917d
    dumping all sections (except the ones marked as IO) unconditionally.
01917d
    
01917d
    gdb/Changelog:
01917d
    2017-11-29  Sergio Lopez  <slp@redhat.com>
01917d
    
01917d
            * linux-tdep.c (dump_excluded_mappings): New variable.
01917d
            (dump_mapping_p): Use dump_excluded_mappings variable.
01917d
            (_initialize_linux_tdep): New command 'set dump_excluded_mappings'.
01917d
01917d
Index: gdb-7.6.1/gdb/linux-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/linux-tdep.c	2017-12-06 20:38:51.182203906 +0100
01917d
+++ gdb-7.6.1/gdb/linux-tdep.c	2017-12-06 20:39:12.708343183 +0100
01917d
@@ -88,6 +88,11 @@
01917d
 
01917d
 static int use_coredump_filter = 1;
01917d
 
01917d
+/* Whether the value of smaps_vmflags->exclude_coredump should be
01917d
+   ignored, including mappings marked with the VM_DONTDUMP flag in
01917d
+   the dump.  */
01917d
+static int dump_excluded_mappings = 0;
01917d
+
01917d
 static struct gdbarch_data *linux_gdbarch_data_handle;
01917d
 
01917d
 struct linux_gdbarch_data
01917d
@@ -512,7 +517,7 @@
01917d
 	return 0;
01917d
 
01917d
       /* Check if we should exclude this mapping.  */
01917d
-      if (v->exclude_coredump)
01917d
+      if (!dump_excluded_mappings && v->exclude_coredump)
01917d
 	return 0;
01917d
 
01917d
       /* Update our notion of whether this mapping is shared or
01917d
@@ -1886,6 +1891,17 @@
01917d
 			    " corefiles is %s.\n"), value);
01917d
 }
01917d
 
01917d
+/* Display whether the gcore command is dumping mappings marked with
01917d
+   the VM_DONTDUMP flag.  */
01917d
+
01917d
+static void
01917d
+show_dump_excluded_mappings (struct ui_file *file, int from_tty,
01917d
+			     struct cmd_list_element *c, const char *value)
01917d
+{
01917d
+  fprintf_filtered (file, _("Dumping of mappings marked with the VM_DONTDUMP"
01917d
+			    " flag is %s.\n"), value);
01917d
+}
01917d
+
01917d
 /* To be called from the various GDB_OSABI_LINUX handlers for the
01917d
    various GNU/Linux architectures and machine types.  */
01917d
 
01917d
@@ -1921,4 +1937,16 @@
01917d
 about this file, refer to the manpage of core(5)."),
01917d
 			   NULL, show_use_coredump_filter,
01917d
 			   &setlist, &showlist);
01917d
+
01917d
+  add_setshow_boolean_cmd ("dump-excluded-mappings", class_files,
01917d
+			   &dump_excluded_mappings, _("\
01917d
+Set whether gcore should dump mappings marked with the VM_DONTDUMP flag."),
01917d
+			   _("\
01917d
+Show whether gcore should dump mappings marked with the VM_DONTDUMP flag."),
01917d
+			   _("\
01917d
+Use this command to set whether gcore should dump mappings marked with the\n\
01917d
+VM_DONTDUMP flag (\"dd\" in /proc/PID/smaps) when generating the corefile.  For\n\
01917d
+more information about this file, refer to the manpage of proc(5) and core(5)."),
01917d
+			   NULL, show_dump_excluded_mappings,
01917d
+			   &setlist, &showlist);
01917d
 }