Test ability to access unwritten-to mmap data in core file
authorKevin Buettner <kevinb@redhat.com>
Thu, 5 Mar 2020 00:42:43 +0000 (17:42 -0700)
committerKevin Buettner <kevinb@redhat.com>
Wed, 22 Jul 2020 19:40:42 +0000 (12:40 -0700)
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_ANONYMOUS and MAP_PRIVATE
flags.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/corefile.exp
gdb/testsuite/gdb.base/coremaker.c

index 6c3bb5ec9d5fa0106b778ab28f56f06f84502793..57e63f5216c51eeae7dbc97f3a4dab1178f05742 100644 (file)
@@ -1,4 +1,13 @@
-2020-07-20  Kevin Buettner  <kevinb@redhat.com>
+2020-07-22  Kevin Buettner  <kevinb@redhat.com>
+
+       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_ANONYMOUS and MAP_PRIVATE
+       flags.
+
+2020-07-22  Kevin Buettner  <kevinb@redhat.com>
 
        * gdb.base/coremaker.c (filler_ro): New global constant.
 
index 34b903b350dca5a18c90376adc24abbebffdf44e..eaabe6c0f8c9f2414cc25bd21790bf354e7a6582 100644 (file)
@@ -175,6 +175,15 @@ gdb_test_multiple "x/8bd buf2" "$test" {
     }
 }
 
+# Test ability to read anonymous and, more importantly, unwritten-to
+# mmap'd data.
+
+if { ![istarget *-linux*] } {
+    setup_xfail "*-*-*"
+}
+gdb_test "x/wx buf3" "$hex:\[ \t\]+0x00000000" \
+        "accessing anonymous, unwritten-to mmap data"
+
 # test reinit_frame_cache
 
 gdb_load ${binfile}
index a39b3ba8a4b60ab9d1832f1b87c090d411fb75ca..0981b21738fcd115f2345c8556dd228e4220ebc2 100644 (file)
@@ -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
This page took 0.059913 seconds and 4 git commands to generate.