This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 5/5] Add new test internalvar.exp


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]