From: Kevin Buettner <kevinb@redhat.com>
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 [thread overview]
Message-ID: <20200722005832.863276-12-kevinb@redhat.com> (raw)
In-Reply-To: <20200722005832.863276-1-kevinb@redhat.com>
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
next prev parent reply other threads:[~2020-07-22 0:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-22 0:58 [PATCH v5 00/14] Fix BZ 25631 - core file memory access problem Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 01/14] Remove hack for GDB which sets the section size to 0 Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 02/14] Adjust corefile.exp test to show regression after bfd hack removal Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 03/14] section_table_xfer_memory: Replace section name with callback predicate Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 04/14] Provide access to non SEC_HAS_CONTENTS core file sections Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 05/14] Test ability to access unwritten-to mmap data in core file Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 06/14] Update binary_get_section_contents to seek using section's file position Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 07/14] Add new gdbarch method, read_core_file_mappings Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 08/14] Use NT_FILE note section for reading core target memory Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 09/14] Add test for accessing read-only mmapped data in a core file Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 10/14] gcore command: Place all file-backed mappings in NT_FILE note Kevin Buettner
2020-07-22 0:58 ` Kevin Buettner [this message]
2020-07-22 18:56 ` [PATCH v5 11/14] Adjust coredump-filter.exp to account for NT_FILE note handling Pedro Alves
2020-07-22 0:58 ` [PATCH v5 12/14] Add new command "maint print core-file-backed-mappings" Kevin Buettner
2020-07-23 13:08 ` Tom de Vries
2020-07-23 20:47 ` Kevin Buettner
2020-07-22 0:58 ` [PATCH v5 13/14] Add documentation for " Kevin Buettner
2020-07-22 2:27 ` Eli Zaretskii
2020-07-22 0:58 ` [PATCH v5 14/14] New core file tests with mappings over existing program memory Kevin Buettner
2020-07-22 18:58 ` [PATCH v5 00/14] Fix BZ 25631 - core file memory access problem Pedro Alves
2020-07-22 20:14 ` Kevin Buettner
2020-07-22 22:40 ` Luis Machado
2020-07-23 3:49 ` Kevin Buettner
2020-07-23 10:37 ` Luis Machado
2020-07-23 21:44 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200722005832.863276-12-kevinb@redhat.com \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox