[rfa] lookup_transparent_type hack

David Carlton carlton@kealia.com
Fri Jan 23 23:06:00 GMT 2004


On Thu, 22 Jan 2004 14:00:08 -0800, David Carlton <carlton@kealia.com> said:

> These failures aren't caused by my patch to GDB - they happen with or
> without the patch - but I want to look into the reason for the
> behavior first before committing the patch.

I've looked into them; as I suspected, they didn't really have
anything to do with this patch.  There is a bug in the way I handle
the debug output that GCC 3.4 generates for classes in namespaces;
I'll submit a patch for that later this afternoon.  And, once I fixed
that bug, I discovered that, if you do:


  void func ()
  {
    C2 *obj = create2 ();

    return;
  }

and set a breakpoint on the 'return' line then, if it's compiled with
GCC 3.4, 'print *obj' claims that there isn't a variable named 'obj'.
Sigh.

So I tweaked rtti1.cc to avoid this issue.  With that change, I
committed the patch; the rtti1.cc part of the patch is below.

David Carlton
carlton@kealia.com

Index: testsuite/gdb.cp/rtti1.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/rtti1.cc,v
retrieving revision 1.1
diff -u -p -r1.1 rtti1.cc
--- testsuite/gdb.cp/rtti1.cc	23 Aug 2003 03:55:59 -0000	1.1
+++ testsuite/gdb.cp/rtti1.cc	23 Jan 2004 22:54:25 -0000
@@ -1,6 +1,6 @@
 /* Code to go along with tests in rtti.exp.
    
-   Copyright 2003 Free Software Foundation, Inc.
+   Copyright 2003, 2004 Free Software Foundation, Inc.
 
    Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
    Inc.
@@ -55,6 +55,26 @@ namespace n1 {
 
 } // n1
 
+// NOTE: carlton/2004-01-23: This call exists only to convince GCC to
+// keep around a reference to 'obj' in n2::func - GCC 3.4 had been
+// optimizing it away.
+void refer_to (n2::C2 *obj)
+{
+  // Do nothing.
+}
+
+namespace n2
+{
+  void func ()
+  {
+    C2 *obj = create2 ();
+
+    refer_to (obj);			// func-constructs-done
+
+    return;
+  }
+}
+
 int main()
 {
     using namespace n1;
@@ -63,5 +83,7 @@ int main()
     C1 *e1 = create1();
     C2 *e2 = create2();
 
-    return 0;				// constructs-done
+    n2::func();				// main-constructs-done
+
+    return 0;
 }



More information about the Gdb-patches mailing list