public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH 5/5] Add new test internalvar.exp
Date: Thu, 16 Jul 2015 18:51:00 -0000	[thread overview]
Message-ID: <1437072684-26565-5-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1437072684-26565-1-git-send-email-simon.marchi@ericsson.com>

I wrote this test While doing the work that lead to the previous patch,
so I thought I would contribute it upstream.  From what I can see, there
is no test currently to verify operations on internal variables (please
point me to it if I'm wrong).

gdb/testsuite/ChangeLog:

	* gdb.base/internalvar.exp: New file.
	* gdb.base/internalvar.c: New file.
---
 gdb/testsuite/gdb.base/internalvar.c   | 45 ++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.base/internalvar.exp | 42 +++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100644 gdb/testsuite/gdb.base/internalvar.c
 create mode 100644 gdb/testsuite/gdb.base/internalvar.exp

diff --git a/gdb/testsuite/gdb.base/internalvar.c b/gdb/testsuite/gdb.base/internalvar.c
new file mode 100644
index 0000000..2aadc11
--- /dev/null
+++ b/gdb/testsuite/gdb.base/internalvar.c
@@ -0,0 +1,45 @@
+struct inner
+{
+  int a;
+  int b[2];
+};
+
+struct outer
+{
+  int x;
+  int y;
+
+  struct inner inner;
+
+  int z[2];
+};
+
+struct outer o;
+struct inner i;
+
+void
+break_here (void)
+{
+}
+
+int
+main (void)
+{
+  o.x = 0x1111;
+  o.y = 0x2222;
+
+  o.inner.a = 0x3333;
+  o.inner.b[0] = 0x4444;
+  o.inner.b[1] = 0x5555;
+
+  o.z[0] = 0x6666;
+  o.z[1] = 0x7777;
+
+  i.a = 0x8888;
+  i.b[0] = 0x9999;
+  i.b[1] = 0xaaaa;
+
+  break_here ();
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/internalvar.exp b/gdb/testsuite/gdb.base/internalvar.exp
new file mode 100644
index 0000000..701cc16
--- /dev/null
+++ b/gdb/testsuite/gdb.base/internalvar.exp
@@ -0,0 +1,42 @@
+# Copyright 2015 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# Test operations on internal variables.
+#
+
+standard_testfile
+
+if {[prepare_for_testing ${testfile}.exp ${testfile}]} {
+    return -1
+}
+
+runto break_here
+
+gdb_test_no_output "set \$a = 0x1234"
+gdb_test "p/x \$a" " = 0x1234"
+
+gdb_test_no_output "set \$s = o"
+gdb_test "p/x \$s" " = {x = 0x1111, y = 0x2222, inner = {a = 0x3333, b = \\{0x4444, 0x5555}}, z = \\{0x6666, 0x7777}}"
+gdb_test "p/x \$s.inner" " = {a = 0x3333, b = \\{0x4444, 0x5555}}"
+gdb_test "p/x \$s.inner.b\[1\]" " = 0x5555"
+
+gdb_test_no_output "set \$s.inner = i"
+gdb_test "p/x \$s" " = {x = 0x1111, y = 0x2222, inner = {a = 0x8888, b = \\{0x9999, 0xaaaa}}, z = \\{0x6666, 0x7777}}"
+
+gdb_test_no_output "set \$s.x = 0xffff"
+gdb_test_no_output "set \$s.inner.b\[1\] = 0xeeee"
+gdb_test_no_output "set \$s.z\[1\] = 0xdddd"
+gdb_test "p/x \$s" " = {x = 0xffff, y = 0x2222, inner = {a = 0x8888, b = \\{0x9999, 0xeeee}}, z = \\{0x6666, 0xdddd}}"
-- 
2.1.4

  parent reply	other threads:[~2015-07-16 18:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 18:51 [PATCH 1/5] Update comment for struct type's length field, introduce type_length_units Simon Marchi
2015-07-16 18:51 ` [PATCH 4/5] Consider addressable memory unit size in various value functions Simon Marchi
2015-07-24 11:27   ` Pedro Alves
2015-07-27 22:05     ` Simon Marchi
2015-07-28 10:29       ` Pedro Alves
2015-07-28 15:07         ` Simon Marchi
2015-07-16 18:51 ` [PATCH 2/5] Update comments in struct value for non-8-bits architectures Simon Marchi
2015-07-24 11:27   ` Pedro Alves
2015-07-27 21:46     ` Simon Marchi
2015-07-28 10:20       ` Pedro Alves
2015-07-16 18:51 ` [PATCH 3/5] Introduce get_value_arch Simon Marchi
2015-07-24 11:27   ` Pedro Alves
2015-07-27 21:47     ` Simon Marchi
2015-07-28 10:25       ` Pedro Alves
2015-07-28 14:56         ` Simon Marchi
2015-07-28 15:06         ` Simon Marchi
2015-07-16 18:51 ` Simon Marchi [this message]
2015-07-24 11:41   ` [PATCH 5/5] Add new test internalvar.exp Pedro Alves
2015-07-24 11:26 ` [PATCH 1/5] Update comment for struct type's length field, introduce type_length_units Pedro Alves
2015-07-27 21:37   ` Simon Marchi
2015-07-28 10:19     ` Pedro Alves
2015-07-28 15:04       ` Simon Marchi

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=1437072684-26565-5-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.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).