From patchwork Mon Dec 4 08:17:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 24707 Received: (qmail 4320 invoked by alias); 4 Dec 2017 08:27:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 4066 invoked by uid 89); 4 Dec 2017 08:27:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=WILL X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Dec 2017 08:27:00 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B5833577 for ; Mon, 4 Dec 2017 08:17:42 +0000 (UTC) Received: from dritchie.redhat.com (ovpn-117-55.ams2.redhat.com [10.36.117.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D75596FDC1; Mon, 4 Dec 2017 08:17:39 +0000 (UTC) From: Sergio Lopez To: gdb-patches@sourceware.org Cc: Sergio Lopez Subject: [PATCH v3 5/5] Extend gdb.core/coredump-filter.exp to test dump-excluded-mappings. Date: Mon, 4 Dec 2017 09:17:16 +0100 Message-Id: <20171204081716.5414-6-slp@redhat.com> In-Reply-To: <20171204081716.5414-1-slp@redhat.com> References: <20171204081716.5414-1-slp@redhat.com> gdb/testsuite/ChangeLog: 2017-11-30 Sergio Lopez * gdb.core/coredump-filter.exp: Extend test to verify the functionality of the dump-excluded-mappings command. --- gdb/testsuite/gdb.base/coredump-filter.exp | 46 ++++++++++++++++++++++-------- 1 file 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//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 = \)?" \ - "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 = \)?" \ + "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]" {