Blame SOURCES/gdb-rhbz1842691-corefile-mem-access-5of15.patch

46818e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
46818e
From: Keith Seitz <keiths@redhat.com>
46818e
Date: Mon, 27 Jul 2020 17:27:39 -0400
46818e
Subject: gdb-rhbz1842691-corefile-mem-access-5of15.patch
46818e
46818e
;; Test ability to access unwritten-to mmap data in core file
46818e
;; Kevin Buettner, RH BZ 1842961
46818e
46818e
   Author: Kevin Buettner <kevinb@redhat.com>
46818e
   Date:   Wed Mar 4 17:42:43 2020 -0700
46818e
46818e
    Test ability to access unwritten-to mmap data in core file
46818e
46818e
    gdb/testsuite/ChangeLog:
46818e
46818e
    	PR corefiles/25631
46818e
    	* gdb.base/corefile.exp (accessing anonymous, unwritten-to mmap data):
46818e
    	New test.
46818e
    	* gdb.base/coremaker.c (buf3): New global.
46818e
    	(mmapdata): Add mmap call which uses MAP_ANONYMOUS and MAP_PRIVATE
46818e
    	flags.
46818e
46818e
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
46818e
--- a/gdb/testsuite/gdb.base/corefile.exp
46818e
+++ b/gdb/testsuite/gdb.base/corefile.exp
46818e
@@ -175,6 +175,15 @@ gdb_test_multiple "x/8bd buf2" "$test" {
46818e
     }
46818e
 }
46818e
 
46818e
+# Test ability to read anonymous and, more importantly, unwritten-to
46818e
+# mmap'd data.
46818e
+
46818e
+if { ![istarget *-linux*] } {
46818e
+    setup_xfail "*-*-*"
46818e
+}
46818e
+gdb_test "x/wx buf3" "$hex:\[ \t\]+0x00000000" \
46818e
+	 "accessing anonymous, unwritten-to mmap data"
46818e
+
46818e
 # test reinit_frame_cache
46818e
 
46818e
 gdb_load ${binfile}
46818e
diff --git a/gdb/testsuite/gdb.base/coremaker.c b/gdb/testsuite/gdb.base/coremaker.c
46818e
--- a/gdb/testsuite/gdb.base/coremaker.c
46818e
+++ b/gdb/testsuite/gdb.base/coremaker.c
46818e
@@ -38,6 +38,7 @@
46818e
 
46818e
 char *buf1;
46818e
 char *buf2;
46818e
+char *buf3;
46818e
 
46818e
 int coremaker_data = 1;	/* In Data section */
46818e
 int coremaker_bss;	/* In BSS section */
46818e
@@ -104,6 +105,15 @@ mmapdata ()
46818e
     }
46818e
   /* Touch buf2 so kernel writes it out into 'core'. */
46818e
   buf2[0] = buf1[0];
46818e
+
46818e
+  /* Create yet another region which is allocated, but not written to.  */
46818e
+  buf3 = mmap (NULL, MAPSIZE, PROT_READ | PROT_WRITE,
46818e
+               MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
46818e
+  if (buf3 == (char *) -1)
46818e
+    {
46818e
+      perror ("mmap failed");
46818e
+      return;
46818e
+    }
46818e
 }
46818e
 
46818e
 void