mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-09 17:43:40 +08:00
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.
This commit is contained in:
parent
c179febe79
commit
3e1a70a018
@ -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]" {
|
||||
|
Loading…
Reference in New Issue
Block a user