From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id D71C83959C62 for ; Wed, 13 May 2020 17:13:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D71C83959C62 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-122-SiQdMWsnMJWLqNQLA2Uaqw-1; Wed, 13 May 2020 13:13:13 -0400 X-MC-Unique: SiQdMWsnMJWLqNQLA2Uaqw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B514518A0760 for ; Wed, 13 May 2020 17:13:12 +0000 (UTC) Received: from f31-1.lan (ovpn-112-112.phx2.redhat.com [10.3.112.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77DD510013D9; Wed, 13 May 2020 17:13:12 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [PATCH v2 5/5] Test ability to access unwritten-to mmap data in core file Date: Wed, 13 May 2020 10:11:55 -0700 Message-Id: <20200513171155.645761-6-kevinb@redhat.com> In-Reply-To: <20200513171155.645761-1-kevinb@redhat.com> References: <20200513171155.645761-1-kevinb@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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=-14.6 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_H2, 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, 13 May 2020 17:13:16 -0000 gdb/testsuite/ChangeLog: PR corefiles/25631 * gdb.base/corefile.exp (accessing anonymous, unwritten-to mmap data): New test. * gdb.base/coremaker.c (buf3): New global. (mmapdata): Add mmap call which uses MAP_ANONYMOUSE and MAP_PRIVATE flags. --- gdb/testsuite/gdb.base/corefile.exp | 6 ++++++ gdb/testsuite/gdb.base/coremaker.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp index 34b903b350..d46b38704c 100644 --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp @@ -175,6 +175,12 @@ gdb_test_multiple "x/8bd buf2" "$test" { } } +# Test ability to read anonymous and, more importantly, unwritten-to +# mmap'd data. + +gdb_test "x/wx buf3" "$hex:\[ \t\]+0x00000000" \ + "accessing anonymous, unwritten-to mmap data" + # test reinit_frame_cache gdb_load ${binfile} diff --git a/gdb/testsuite/gdb.base/coremaker.c b/gdb/testsuite/gdb.base/coremaker.c index 4c41b9c926..657764ca6b 100644 --- a/gdb/testsuite/gdb.base/coremaker.c +++ b/gdb/testsuite/gdb.base/coremaker.c @@ -38,6 +38,7 @@ char *buf1; char *buf2; +char *buf3; int coremaker_data = 1; /* In Data section */ int coremaker_bss; /* In BSS section */ @@ -104,6 +105,15 @@ mmapdata () } /* Touch buf2 so kernel writes it out into 'core'. */ buf2[0] = buf1[0]; + + /* Create yet another region which is allocated, but not written to. */ + buf3 = mmap (NULL, MAPSIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (buf3 == (char *) -1) + { + perror ("mmap failed"); + return; + } } void -- 2.25.4