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

01917d
commit 3e1a70a0189ae8d2dacfef93790e42e42e721762
01917d
Author: Sergio Lopez <slp@redhat.com>
01917d
Date:   Mon Dec 4 09:17:16 2017 +0100
01917d
01917d
    Extend gdb.core/coredump-filter.exp to test dump-excluded-mappings.
01917d
    
01917d
    gdb/testsuite/ChangeLog:
01917d
    2017-11-30  Sergio Lopez  <slp@redhat.com>
01917d
    
01917d
            * gdb.core/coredump-filter.exp: Extend test to verify
01917d
            the functionality of the dump-excluded-mappings command.
01917d
01917d
Index: gdb-7.6.1/gdb/testsuite/gdb.base/coredump-filter.exp
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/testsuite/gdb.base/coredump-filter.exp	2017-12-06 20:59:21.016161086 +0100
01917d
+++ gdb-7.6.1/gdb/testsuite/gdb.base/coredump-filter.exp	2017-12-06 21:03:20.445710226 +0100
01917d
@@ -95,16 +95,26 @@
01917d
     return -1
01917d
 }
01917d
 
01917d
-proc do_save_core { filter_flag core ipid } {
01917d
+proc do_save_core { filter_flag core ipid dump_excluded } {
01917d
     verbose -log "writing $filter_flag to /proc/$ipid/coredump_filter"
01917d
 
01917d
     remote_exec target "sh -c \"echo $filter_flag > /proc/$ipid/coredump_filter\""
01917d
 
01917d
+    # Enable dumping of excluded mappings (i.e. VM_DONTDUMP).
01917d
+    if { $dump_excluded == 1 } {
01917d
+        gdb_test_no_output "set dump-excluded-mappings on"
01917d
+    }
01917d
+
01917d
     # Generate a corefile.
01917d
     gdb_gcore_cmd "$core" "save corefile"
01917d
+
01917d
+    # Restore original status.
01917d
+    if { $dump_excluded == 1 } {
01917d
+        gdb_test_no_output "set dump-excluded-mappings off"
01917d
+    }
01917d
 }
01917d
 
01917d
-proc do_load_and_test_core { core var working_var working_value } {
01917d
+proc do_load_and_test_core { core var working_var working_value dump_excluded } {
01917d
     global hex decimal addr
01917d
 
01917d
     set core_loaded [gdb_core_cmd "$core" "load core"]
01917d
@@ -114,10 +124,16 @@
01917d
     }
01917d
 
01917d
     # Access the memory the addresses point to.
01917d
-    gdb_test "print/x *(char *) $addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
01917d
-	"printing $var when core is loaded (should not work)"
01917d
-    gdb_test "print/x *(char *) $addr($working_var)" " = $working_value.*" \
01917d
-	"print/x *$working_var ( = $working_value)"
01917d
+    if { $dump_excluded == 0 } {
01917d
+	gdb_test "print/x *(char *) $addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
01917d
+	    "printing $var when core is loaded (should not work)"
01917d
+	gdb_test "print/x *(char *) $addr($working_var)" " = $working_value.*" \
01917d
+	    "print/x *$working_var ( = $working_value)"
01917d
+    } else {
01917d
+        # Check if VM_DONTDUMP mappings are present in the core file.
01917d
+        gdb_test "print/x *(char *) $addr($var)" " = $working_value.*" \
01917d
+	    "print/x *$var ( = $working_value)"
01917d
+    }
01917d
 }
01917d
 
01917d
 # We do not do file-backed mappings in the test program, but it is
01917d
@@ -169,6 +185,7 @@
01917d
 # A corefile without {private,shared} {anonymous,file-backed} pages
01917d
 set non_private_shared_anon_file_core [standard_output_file non-private-shared-anon-file.gcore]
01917d
 set dont_dump_core [standard_output_file dont-dump.gcore]
01917d
+set dump_excluded_core [standard_output_file dump-excluded.gcore]
01917d
 
01917d
 # We will generate a few corefiles.
01917d
 #
01917d
@@ -184,6 +201,8 @@
01917d
 # - name of a variable in the C source code that points to a memory
01917d
 #   mapping that WILL be present in the corefile
01917d
 # - corresponding value expected for the above variable
01917d
+# - whether to include mappings marked as VM_DONTDUMP in the
01917d
+#   corefile (1) or not (0).
01917d
 #
01917d
 # This list refers to the corefiles generated by MAP_ANONYMOUS in the
01917d
 # test program.
01917d
@@ -191,13 +210,16 @@
01917d
 set all_anon_corefiles { { "non-Private-Anonymous" "0x7e" \
01917d
 			       $non_private_anon_core \
01917d
 			       "private_anon" \
01917d
-			       "shared_anon" "0x22" }
01917d
+			       "shared_anon" "0x22" "0" }
01917d
     { "non-Shared-Anonymous" "0x7d" \
01917d
 	  $non_shared_anon_core "shared_anon" \
01917d
-	  "private_anon" "0x11" }
01917d
+	  "private_anon" "0x11" "0" }
01917d
     { "DoNotDump" "0x33" \
01917d
 	  $dont_dump_core "dont_dump" \
01917d
-	  "shared_anon" "0x22" } }
01917d
+	  "shared_anon" "0x22" "0" }
01917d
+    { "DoNotDump-DumpExcluded" "0x33" \
01917d
+	  $dump_excluded_core "dont_dump" \
01917d
+	  "shared_anon" "0x55" "1" } }
01917d
 
01917d
 # If corefile loading is not supported, we do not even try to run the
01917d
 # tests.
01917d
@@ -239,12 +261,12 @@
01917d
 # Generate corefiles for the "anon" case.
01917d
 foreach item $all_anon_corefiles {
01917d
     with_test_prefix "saving corefile for [lindex $item 0]" {
01917d
-	do_save_core [lindex $item 1] [subst [lindex $item 2]] $infpid
01917d
+	do_save_core [lindex $item 1] [subst [lindex $item 2]] $infpid [lindex $item 6]
01917d
     }
01917d
 }
01917d
 
01917d
 with_test_prefix "saving corefile for non-Private-Shared-Anon-File" {
01917d
-    do_save_core "0x60" $non_private_shared_anon_file_core $infpid
01917d
+    do_save_core "0x60" $non_private_shared_anon_file_core $infpid "0"
01917d
 }
01917d
 
01917d
 clean_restart $testfile
01917d
@@ -252,7 +274,7 @@
01917d
 foreach item $all_anon_corefiles {
01917d
     with_test_prefix "loading and testing corefile for [lindex $item 0]" {
01917d
 	do_load_and_test_core [subst [lindex $item 2]] [lindex $item 3] \
01917d
-	    [lindex $item 4] [lindex $item 5]
01917d
+	    [lindex $item 4] [lindex $item 5] [lindex $item 6]
01917d
     }
01917d
 
01917d
     with_test_prefix "disassembling function main for [lindex $item 0]" {