From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/3] Test case for dump/restore of large array
Date: Mon, 06 Mar 2017 16:02:00 -0000 [thread overview]
Message-ID: <1488816060-20776-3-git-send-email-arnez@linux.vnet.ibm.com> (raw)
In-Reply-To: <1488816060-20776-1-git-send-email-arnez@linux.vnet.ibm.com>
This adds a test case to dump.exp that dumps and restores a large array.
In particular it verifies that the dump and restore operations are
completed in reasonable time.
gdb/testsuite/ChangeLog:
PR gdb/21220
* gdb.base/dump.c (bigarray): New variable.
(zero_all): Clear bigarray as well.
(func, fill_bigarray, cmp_bigarray): New functions.
(main): Call fill_bigarray.
* gdb.base/dump.exp: Add test for dump/restore of a large array.
---
gdb/testsuite/gdb.base/dump.c | 37 +++++++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.base/dump.exp | 8 ++++++++
2 files changed, 45 insertions(+)
diff --git a/gdb/testsuite/gdb.base/dump.c b/gdb/testsuite/gdb.base/dump.c
index bdcafbf..fdeefa8 100644
--- a/gdb/testsuite/gdb.base/dump.c
+++ b/gdb/testsuite/gdb.base/dump.c
@@ -3,6 +3,9 @@
#define ARRSIZE 32
int intarray[ARRSIZE], intarray2[ARRSIZE];
+#define BIGSIZE 16777216
+unsigned char bigarray[BIGSIZE];
+
struct teststruct {
int a;
int b;
@@ -25,6 +28,38 @@ zero_all ()
memset ((char *) &intarray2, 0, sizeof (intarray2));
memset ((char *) &intstruct, 0, sizeof (intstruct));
memset ((char *) &intstruct2, 0, sizeof (intstruct2));
+ memset ((char *) &bigarray, 0, sizeof (bigarray));
+}
+
+static unsigned char
+func (unsigned u)
+{
+ unsigned char a = u;
+ unsigned char b = (u >> 8);
+ unsigned char c = (u >> 16);
+ unsigned char d = (u >> 24);
+
+ return (a ^ b ^ c ^ d);
+}
+
+int
+fill_bigarray ()
+{
+ unsigned i;
+
+ for (i = 0; i < sizeof (bigarray); i++)
+ bigarray[i] = func (i);
+}
+
+int
+cmp_bigarray ()
+{
+ unsigned i;
+
+ for (i = 0; i < sizeof (bigarray); i++)
+ if (bigarray[i] != func (i))
+ return 0;
+ return 1;
}
int
@@ -43,6 +78,8 @@ main()
intstruct.f = 12 * 6;
intstruct.g = 12 * 7;
+ fill_bigarray ();
+
checkpoint1 ();
return 0;
}
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index e67e1aa..170a09f 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -74,6 +74,7 @@ set all_files {
intstr2.bin intstr2b.bin intstr2.ihex
intstr2.srec intstr2.tekhex intstr2.verilog
intarr3.srec
+ bigarr1.bin
}
# This loop sets variables dynamically -- each name listed in
@@ -263,6 +264,9 @@ make_dump_file \
"dump srec mem [set intarr3.srec] &intarray \(char *\) &intarray + sizeof intarray" \
"dump array as mem, srec, expressions"
+make_dump_file "dump bin mem [set bigarr1.bin] &bigarray &bigarray\[sizeof bigarray\]" \
+ "dump big array as memory, default"
+
proc test_restore_saved_value { restore_args msg oldval newval } {
global gdb_prompt
@@ -348,6 +352,10 @@ test_restore_saved_value "[set intstr2.bin] binary $struct_start" \
"struct as memory, binary" \
$struct_val "intstruct"
+test_restore_saved_value "[set bigarr1.bin] binary &bigarray" \
+ "reload big array as memory, binary" \
+ 1 "cmp_bigarray ()"
+
# test restore with offset.
set array2_start [capture_value "/x &intarray2\[0\]"]
--
2.3.0
next prev parent reply other threads:[~2017-03-06 16:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 16:01 [PATCH 0/3] PR gdb/21220: Fix quadratic runtime of memory writes into inferior on GNU/Linux Andreas Arnez
2017-03-06 16:01 ` [PATCH 1/3] inf-ptrace: Do not stop memory transfers after a single word Andreas Arnez
2017-03-08 19:10 ` Simon Marchi
2017-03-09 17:22 ` Andreas Arnez
2017-03-10 15:49 ` Simon Marchi
2017-03-13 19:39 ` Pedro Alves
2017-03-13 19:50 ` Andreas Arnez
2017-03-13 19:51 ` Pedro Alves
2017-03-14 15:12 ` Andreas Arnez
2017-03-14 15:23 ` Pedro Alves
2017-03-06 16:02 ` Andreas Arnez [this message]
2017-03-13 19:51 ` [PATCH 2/3] Test case for dump/restore of large array Pedro Alves
2017-03-06 16:03 ` [PATCH 3/3] linux-nat: Exploit /proc/<pid>/mem for writing Andreas Arnez
2017-03-13 20:05 ` Pedro Alves
2017-03-13 20:08 ` Pedro Alves
2017-03-14 11:23 ` Andreas Arnez
2017-03-14 9:54 ` Andreas Arnez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1488816060-20776-3-git-send-email-arnez@linux.vnet.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).