From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 795223857C6E for ; Wed, 22 Jul 2020 00:59:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 795223857C6E 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-251-vZSja34iMGCDl5qT4kk5YQ-1; Tue, 21 Jul 2020 20:59:00 -0400 X-MC-Unique: vZSja34iMGCDl5qT4kk5YQ-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 92C65107ACCA for ; Wed, 22 Jul 2020 00:58:59 +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 6549D69314; Wed, 22 Jul 2020 00:58:59 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH v5 00/14] Fix BZ 25631 - core file memory access problem Date: Tue, 21 Jul 2020 17:58:18 -0700 Message-Id: <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=-7.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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:08 -0000 This series fixes several core file related bugs. The bug which started this work can be viewed here: https://sourceware.org/bugzilla/show_bug.cgi?id=25631 Other problems were found either during review or during development. I discuss these in my commit log remarks. This v5 series has only minor changes from v4. Unless noted otherwise, these changes all address Pedro's concerns: o Patch #5, Test ability to access unwritten-to mmap data in core file: - Add setup_xfail for non-Linux OSes. (I spotted this while testing on FreeBSD.) o Patch #8, Use NT_FILE note section for reading core target memory: - Formatting fixes. - Close bfd after failed bfd_check_format_check. - Fix SECNAME leak. o Patch #11, Adjust coredump-filter.exp to account for NT_FILE note handling: - Instead of XFAILing test, use Mihails Strasuns's suggestion instead. o Patch #12, Add new command "maint print core-file-backed-mappings": - Formatting fixes. - Don't crash GDB with gdb_assert(). - Add comments (in both code and commit log) regarding utility of this new command. o Patch #14, New core file tests with mappings over existing program memory: - Formatting fixes. - Add another "maint print core-file-backed-mappings" test requested by Pedro in patch #12 review. This one makes sure that we don't crash GDB when NOT debugging a core file. I believe that all patches not listed above have been approved. Actually, I think that #5 is still approved too; I doubt that adding an XFAIL changes that. Kevin Buettner (14): Remove hack for GDB which sets the section size to 0 Adjust corefile.exp test to show regression after bfd hack removal section_table_xfer_memory: Replace section name with callback predicate Provide access to non SEC_HAS_CONTENTS core file sections Test ability to access unwritten-to mmap data in core file Update binary_get_section_contents to seek using section's file position Add new gdbarch method, read_core_file_mappings Use NT_FILE note section for reading core target memory Add test for accessing read-only mmapped data in a core file gcore command: Place all file-backed mappings in NT_FILE note Adjust coredump-filter.exp to account for NT_FILE note handling Add new command "maint print core-file-backed-mappings" Add documentation for "maint print core-file-backed-mappings" New core file tests with mappings over existing program memory bfd/binary.c | 12 +- bfd/elf.c | 8 - gdb/NEWS | 4 + gdb/arch-utils.c | 16 ++ gdb/arch-utils.h | 12 + gdb/bfd-target.c | 3 +- gdb/corelow.c | 264 ++++++++++++++++++++- gdb/doc/gdb.texinfo | 8 + gdb/exec.c | 8 +- gdb/exec.h | 13 +- gdb/gdbarch.c | 23 ++ gdb/gdbarch.h | 6 + gdb/gdbarch.sh | 3 + gdb/linux-tdep.c | 244 +++++++++++++------ gdb/target.c | 18 +- gdb/testsuite/gdb.base/coredump-filter.exp | 18 +- gdb/testsuite/gdb.base/corefile.exp | 27 ++- gdb/testsuite/gdb.base/corefile2.exp | 185 +++++++++++++++ gdb/testsuite/gdb.base/coremaker.c | 30 ++- gdb/testsuite/gdb.base/coremaker2.c | 150 ++++++++++++ 20 files changed, 942 insertions(+), 110 deletions(-) create mode 100644 gdb/testsuite/gdb.base/corefile2.exp create mode 100644 gdb/testsuite/gdb.base/coremaker2.c -- 2.26.2