From patchwork Thu Mar 5 00:42:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Buettner X-Patchwork-Id: 38415 Received: (qmail 64964 invoked by alias); 5 Mar 2020 00:43:40 -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 64949 invoked by uid 89); 5 Mar 2020 00:43:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Touch, HX-Languages-Length:1712, corefile.exp, UD:corefile.exp X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Mar 2020 00:43:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583369017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z9cTIctsQVP/0Q8U2UG0k80p8flLgHDajLuovnLpTPQ=; b=cY+8mDwWe/HmwJPzACoXx4ozY6HCK8AaobjpX4ziXR4+dc7eQeiR9TCTCLXkeKneD1SFTN LZf0zfPRA6baYzELmK6cgYxFDXjEPhAYrOv3dhqO0f29hRjxsAPF6yw7NjPgRK01TGq6px eS4ctH6yR4xoXb6JT+31FmlbpnU0SMM= 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-324-1c5yH3RJOPW8DDgw2FMlkQ-1; Wed, 04 Mar 2020 19:43:35 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 053818010F6 for ; Thu, 5 Mar 2020 00:43:35 +0000 (UTC) Received: from f31-1.lan (ovpn-116-156.phx2.redhat.com [10.3.116.156]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3507272A1; Thu, 5 Mar 2020 00:43:34 +0000 (UTC) From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Kevin Buettner Subject: [PATCH 4/4] Test ability to access unwritten-to mmap data in core file Date: Wed, 4 Mar 2020 17:42:43 -0700 Message-Id: <20200305004243.334607-5-kevinb@redhat.com> In-Reply-To: <20200305004243.334607-1-kevinb@redhat.com> References: <20200305004243.334607-1-kevinb@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes gdb/testsuite/ChangeLog: * 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. Change-Id: Ifb8d77b06050e1220f33f83f1bec27533e4d9ead --- 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 55330fd3e8..3a01c16405 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 */ @@ -98,6 +99,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