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

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