Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/dwarf-2] Fix for the null record problem
@ 2004-02-19 14:01 Joel Brobecker
  2004-02-19 21:52 ` Elena Zannoni
  0 siblings, 1 reply; 19+ messages in thread
From: Joel Brobecker @ 2004-02-19 14:01 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]

Hello,

This is a followup on the thread that started with:

   http://sources.redhat.com/ml/gdb-patches/2004-02/msg00058.html

The test proposed under that thread was dropped because an empty
struct is not legal C. However, it is legal in Ada, and I've seen
a message saying that it is also legal in C++.

I have found the source of the problem, and suggest the attached patch.
The problem was that GDB was mistakenly deducing that the empry record
was only a stub because of the lack of fields, and was therefore tagging
it with TYPE_FLAG_STUB. This is not correct. Instead, the right
approach, I believe, is to check for the DW_AT_declaration attribute.

2004-02-19  J. Brobecker  <brobecker@gnat.com>

        * dwarf2read.c (read_structure_scope): Identify stub types
        using the DW_AT_declaration attribute.

tested on x86-linux. No regression. Fixes the testcase that was
proposed by Andrew (even though it is not legal C) and the Ada
case.

OK to apply?

Thanks,
-- 
Joel

PS: BTW, my past 3 months of traveling will soon be over. The past
couple of weeks have been very hectic. I have noticed that there were
some messages directed at me to which I haven't answered yet. I am
really sorry. I have kept these messages and will try to answer them
soon.

[-- Attachment #2: null_record.diff --]
[-- Type: text/plain, Size: 963 bytes --]

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.130
diff -u -p -r1.130 dwarf2read.c
--- dwarf2read.c	28 Jan 2004 18:43:06 -0000	1.130
+++ dwarf2read.c	19 Feb 2004 13:58:42 -0000
@@ -3077,6 +3077,9 @@ read_structure_scope (struct die_info *d
       TYPE_LENGTH (type) = 0;
     }
 
+  if (dwarf2_attr (die, DW_AT_declaration, cu) != NULL)
+    TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
+
   /* We need to add the type field to the die immediately so we don't
      infinitely recurse when dealing with pointers to the structure
      type within the structure itself. */
@@ -3213,11 +3216,6 @@ read_structure_scope (struct die_info *d
       new_symbol (die, type, cu);
 
       do_cleanups (back_to);
-    }
-  else
-    {
-      /* No children, must be stub. */
-      TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
     }
 
   processing_current_prefix = previous_prefix;

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [RFA/dwarf-2] Fix for the null record problem
@ 2004-02-26 19:49 Michael Elizabeth Chastain
  2004-02-26 20:23 ` Joel Brobecker
  0 siblings, 1 reply; 19+ messages in thread
From: Michael Elizabeth Chastain @ 2004-02-26 19:49 UTC (permalink / raw)
  To: brobecker, ezannoni, gdb-patches

I like the idea, but there are two gotchas:

. update the copyright year in class2.exp
. quote the '{' and '}' chars in class2.exp:

  "= \{<No data fields>\}"

With these two changes, and if you re-test, then I approve the patch.

Michael C

===

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.


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [RFA/dwarf-2] Fix for the null record problem
@ 2004-02-26 21:34 Michael Elizabeth Chastain
  0 siblings, 0 replies; 19+ messages in thread
From: Michael Elizabeth Chastain @ 2004-02-26 21:34 UTC (permalink / raw)
  To: brobecker; +Cc: carlton, ezannoni, gdb-patches

Thanks Joel.

===

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.


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2004-04-16  3:59 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-19 14:01 [RFA/dwarf-2] Fix for the null record problem Joel Brobecker
2004-02-19 21:52 ` Elena Zannoni
2004-02-19 23:29   ` Andrew Cagney
2004-02-19 23:37   ` Joel Brobecker
2004-02-26  2:31   ` Joel Brobecker
2004-02-26  3:27     ` Daniel Jacobowitz
2004-02-26 19:00       ` Joel Brobecker
2004-04-01  1:18   ` Joel Brobecker
2004-04-13  5:26     ` Joel Brobecker
2004-04-14 17:24       ` Jim Blandy
2004-04-14 17:47         ` Daniel Jacobowitz
2004-04-15  5:01           ` Jim Blandy
2004-04-15 20:43             ` Joel Brobecker
2004-04-16  3:18               ` Joel Brobecker
2004-04-16  3:59                 ` Jim Blandy
2004-04-15  5:33           ` Jim Blandy
2004-02-26 19:49 Michael Elizabeth Chastain
2004-02-26 20:23 ` Joel Brobecker
2004-02-26 21:34 Michael Elizabeth Chastain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox