You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.9 KiB

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