From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id ECAAB383E817 for ; Wed, 22 Jul 2020 00:59:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ECAAB383E817 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-1h92rkk5NLSj1_4kdt3Z_w-1; Tue, 21 Jul 2020 20:59:26 -0400 X-MC-Unique: 1h92rkk5NLSj1_4kdt3Z_w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 311671005504 for ; Wed, 22 Jul 2020 00:59:25 +0000 (UTC) Received: from f32-1.lan (ovpn-112-21.phx2.redhat.com [10.3.112.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id F407069314; Wed, 22 Jul 2020 00:59:24 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH v5 11/14] Adjust coredump-filter.exp to account for NT_FILE note handling Date: Tue, 21 Jul 2020 17:58:29 -0700 Message-Id: <20200722005832.863276-12-kevinb@redhat.com> In-Reply-To: <20200722005832.863276-1-kevinb@redhat.com> References: <20200722005832.863276-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2020 00:59:29 -0000 This commit makes adjustments to coredump-filter.exp to account for the fact that NT_FILE file-backed mappings are now available when a core file is loaded. Thus, a test which was expected to PASS when a memory region was determined to be unavailable (due to no file-backed mappings being available) will now FAIL due to those mappings being available from having loaded the NT_FILE note. I had originally marked the test as XFAIL, but Mihails Strasuns suggested a much better approach: 1) First test that it still works if file is accessible in the filesystem. 2) Temporarily move / rename the file and test that disassembly doesn't work anymore. That's what this commit implements. gdb/testsuite/ChangeLog: * gdb.base/coredump-filter.exp: Add second non-Private-Shared-Anon-File test. (test_disasm): Rename binfile for test which is expected to fail. --- gdb/testsuite/gdb.base/coredump-filter.exp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp index ff398f2b85..b723b62490 100644 --- a/gdb/testsuite/gdb.base/coredump-filter.exp +++ b/gdb/testsuite/gdb.base/coredump-filter.exp @@ -80,15 +80,26 @@ proc do_load_and_test_core { core var working_var working_value dump_excluded } # disassemble of a function (i.e., the binary's .text section). GDB # should fail in this case. However, it must succeed if the binary is # provided along with the corefile. This is what we test here. +# +# A further complication is that Linux NT_FILE notes are now read from +# the corefile. This note allows GDB to find the binary for file +# backed mappings even though the binary wasn't loaded by GDB in the +# conventional manner. In order to see the expected failure for this +# case, we rename the binary in order to perform this test. proc test_disasm { core address should_fail } { - global testfile hex + global testfile hex binfile # Restart GDB without loading the binary. with_test_prefix "no binary" { gdb_exit gdb_start + set hide_binfile [standard_output_file "${testfile}.hide"] + if { $should_fail == 1 } { + file rename -force $binfile $hide_binfile + } + set core_loaded [gdb_core_cmd "$core" "load core"] if { $core_loaded == -1 } { fail "loading $core" @@ -96,6 +107,7 @@ proc test_disasm { core address should_fail } { } if { $should_fail == 1 } { + file rename -force $hide_binfile $binfile gdb_test "x/i \$pc" "=> $hex:\tCannot access memory at address $hex" \ "disassemble function with corefile and without a binary" } else { @@ -225,5 +237,9 @@ foreach item $all_anon_corefiles { } with_test_prefix "loading and testing corefile for non-Private-Shared-Anon-File" { + test_disasm $non_private_shared_anon_file_core $main_addr 0 +} + +with_test_prefix "loading and testing corefile for non-Private-Shared-Anon-File with renamed binary" { test_disasm $non_private_shared_anon_file_core $main_addr 1 } -- 2.26.2