This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] gdb.python/lib-types.exp: test const+typedef stripping
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 08 Oct 2013 13:51:39 -0700
- Subject: [patch] gdb.python/lib-types.exp: test const+typedef stripping
- Authentication-results: sourceware.org; auth=none
lib-types.exp doesn't test both qualifier + typedef/ref stripping,
so I added some testcases to verify it works.
I will check this in in a few days if there are no objections.
2013-10-08 Doug Evans <dje@google.com>
* gdb.python/lib-types.cc (const_typedef_class1_obj): New global.
(const_class1_ref_obj): New global.
* gdb.python/lib-types.exp: Add tests for stripping const + typedef,
nad const + ref stripping.
Index: lib-types.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/lib-types.cc,v
retrieving revision 1.5
diff -u -p -r1.5 lib-types.cc
--- lib-types.cc 1 Jan 2013 06:41:26 -0000 1.5
+++ lib-types.cc 8 Oct 2013 20:50:11 -0000
@@ -30,8 +30,10 @@ const volatile class1 const_volatile_cla
typedef class1 typedef_class1;
typedef_class1 typedef_class1_obj (42);
+const typedef_class1 const_typedef_class1_obj (42);
class1& class1_ref_obj (class1_obj);
+const class1& const_class1_ref_obj (class1_obj);
typedef const typedef_class1 typedef_const_typedef_class1;
Index: lib-types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/lib-types.exp,v
retrieving revision 1.11
diff -u -p -r1.11 lib-types.exp
--- lib-types.exp 1 Jan 2013 06:41:26 -0000 1.11
+++ lib-types.exp 8 Oct 2013 20:50:11 -0000
@@ -78,6 +78,17 @@ gdb_test_multiple "python print (str (ba
}
}
+# test get_basic_type const then typedef stripping
+gdb_test_no_output "python const_typedef_class1_obj = gdb.parse_and_eval ('const_typedef_class1_obj')"
+gdb_test_no_output "python basic_type_const_typedef_class1_obj = gdb.types.get_basic_type (const_typedef_class1_obj.type)"
+gdb_test "python print (str (const_typedef_class1_obj.type))" "const typedef_class1"
+set test "const+typedef stripping"
+gdb_test_multiple "python print (str (basic_type_const_typedef_class1_obj))" $test {
+ -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" {
+ pass $test
+ }
+}
+
# test get_basic_type reference stripping
gdb_test_no_output "python class1_ref_obj = gdb.parse_and_eval ('class1_ref_obj')"
gdb_test_no_output "python basic_type_class1_ref_obj = gdb.types.get_basic_type (class1_ref_obj.type)"
@@ -89,6 +100,17 @@ gdb_test_multiple "python print (str (ba
}
}
+# test get_basic_type const then reference stripping
+gdb_test_no_output "python const_class1_ref_obj = gdb.parse_and_eval ('const_class1_ref_obj')"
+gdb_test_no_output "python basic_type_const_class1_ref_obj = gdb.types.get_basic_type (const_class1_ref_obj.type)"
+gdb_test "python print (str (const_class1_ref_obj.type))" "const class1 &"
+set test "reference stripping"
+gdb_test_multiple "python print (str (basic_type_const_class1_ref_obj))" $test {
+ -re "\[\r\n\]+class1\[\r\n\]+$gdb_prompt $" {
+ pass $test
+ }
+}
+
# test nested typedef stripping
gdb_test_no_output "python typedef_const_typedef_class1_obj = gdb.parse_and_eval ('typedef_const_typedef_class1_obj')"
gdb_test_no_output "python basic_type_typedef_const_typedef_class1_obj = gdb.types.get_basic_type (typedef_const_typedef_class1_obj.type)"