[RFA/dwarf-2] Fix for the null record problem
Joel Brobecker
brobecker@gnat.com
Thu Feb 26 19:00:00 GMT 2004
> I'd like to have the empty struct test anyway. Remember to add a
> variable of that type if you add a type to class2.cc; or newer GCCs
> will just elide the type.
Would the following patch be ok to apply?
2004-02-26 J. Brobecker <brobecker@gnat.com>
* gdb.cp/class2.cc (empty): New class.
(refer): New function.
(main): Declare an object of type empty and use it.
* gdb.cp/class2.exp: Print the value of an object of type empty.
Tested on x86-linux.
--
Joel
-------------- next part --------------
Index: class2.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/class2.cc,v
retrieving revision 1.2
diff -u -r1.2 class2.cc
--- class2.cc 11 Feb 2004 14:01:25 -0000 1.2
+++ class2.cc 26 Feb 2004 18:51:32 -0000
@@ -48,10 +48,19 @@
;
}
+struct empty {};
+
+// Stop the compiler from optimizing away data.
+void refer (empty *)
+{
+ ;
+}
+
int main (void)
{
A alpha, *aap, *abp;
B beta, *bbp;
+ empty e;
alpha.a1 = 100;
beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
@@ -59,6 +68,7 @@
aap = α refer (aap);
abp = β refer (abp);
bbp = β refer (bbp);
+ refer (&e);
return 0; // marker return 0
} // marker close brace
Index: class2.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/class2.exp,v
retrieving revision 1.1
diff -u -r1.1 class2.exp
--- class2.exp 25 Nov 2003 15:01:31 -0000 1.1
+++ class2.exp 26 Feb 2004 18:51:32 -0000
@@ -113,3 +113,7 @@
gdb_test "print * (B *) abp" \
"= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
"print * (B *) abp at marker return 0"
+
+# Printing the value of an object containing no data fields:
+
+gdb_test "p e" "= {<No data fields>}" "print object with no data fields"
More information about the Gdb-patches
mailing list