summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorSergio Lopez <slp@redhat.com>2017-12-04 09:17:16 +0100
committerSergio Durigan Junior <sergiodj@redhat.com>2017-12-04 12:05:58 -0500
commit3e1a70a0189ae8d2dacfef93790e42e42e721762 (patch)
tree0a333415127944bf93f7b7269360f2ac5ffc6128 /gdb/testsuite
parentc179febe79bf2fe2f64852c827813fc46da819f5 (diff)
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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/coredump-filter.exp46
1 files changed, 34 insertions, 12 deletions
diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp
index f54164f75f..de2f22983f 100644
--- a/gdb/testsuite/gdb.base/coredump-filter.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter.exp
@@ -33,16 +33,26 @@ if { ![runto_main] } {
gdb_breakpoint [gdb_get_line_number "break-here"]
gdb_continue_to_breakpoint "break-here" ".* break-here .*"
-proc do_save_core { filter_flag core } {
+proc do_save_core { filter_flag core dump_excluded } {
verbose -log "writing $filter_flag to /proc/<inferior pid>/coredump_filter"
gdb_test "p set_coredump_filter ($filter_flag)" " = 0"
+ # 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 coredump_var_addr
set core_loaded [gdb_core_cmd "$core" "load core"]
@@ -52,10 +62,16 @@ proc do_load_and_test_core { core var working_var working_value } {
}
# Access the memory the addresses point to.
- gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
- "printing $var when core is loaded (should not work)"
- gdb_test "print/x *(char *) $coredump_var_addr($working_var)" " = $working_value.*" \
- "print/x *$working_var ( = $working_value)"
+ if { $dump_excluded == 0 } {
+ gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
+ "printing $var when core is loaded (should not work)"
+ gdb_test "print/x *(char *) $coredump_var_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 *) $coredump_var_addr($var)" " = $working_value.*" \
+ "print/x *$var ( = $working_value)"
+ }
}
# We do not do file-backed mappings in the test program, but it is
@@ -107,6 +123,7 @@ set non_shared_anon_core [standard_output_file non-shared-anon.gcore]
# 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.
#
@@ -122,6 +139,8 @@ set dont_dump_core [standard_output_file dont-dump.gcore]
# - 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.
@@ -129,13 +148,16 @@ set dont_dump_core [standard_output_file dont-dump.gcore]
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.
@@ -181,12 +203,12 @@ foreach item $all_anon_corefiles {
# 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]]
+ do_save_core [lindex $item 1] [subst [lindex $item 2]] [lindex $item 6]
}
}
with_test_prefix "saving corefile for non-Private-Shared-Anon-File" {
- do_save_core "0x60" $non_private_shared_anon_file_core
+ do_save_core "0x60" $non_private_shared_anon_file_core "0"
}
clean_restart $testfile
@@ -194,7 +216,7 @@ clean_restart $testfile
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]" {