This is the mail archive of the gdb@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] |
> (gdb) ptype bar.empty > No definition of "bar.empty" in current context. Thanks for sending me your objfiles. I know what's going on, now. Once I understood the source of this issue, it was actually fairly simple to reproduce the problem with a C program. Consider: struct empty {}; struct not_empty { long long a; }; int main (void) { struct empty e = {}; struct not_empty n = { 1 }; n.a = (long long) &e; return 0; } The heart of the problem is that struct empty is a struct that does not have any children. We have some guards in dwarf2read.c for both partial symbols and full symbols readers that make GDB ignore the DW_TAG_structure DIEs for type empty: add_partial_symbol (...) { case DW_TAG_structure_type: /* Skip aggregate types without children, these are external references. */ /* NOTE: carlton/2003-10-07: See comment in new_symbol about static vs. global. */ !!!-> if (pdi->has_children == 0) return; add_psymbol_to_list (actual_name, strlen (actual_name), Same for full symbols: process_structure_scope (...) { [...] if (die->child != NULL && ! die_is_declaration (die, cu)) new_symbol (die, die->type, cu); What saves us with our version of GNAT Pro is that the compiler also creates a DW_TAG_typedef DIE associated to this struct. This is this DIE that allows GDB to create a symbol for this type. With the C example above, where the language allows me to control whether typedefs are emitted or not, I can reproduce with the compiler I use the same problem as yours. The guards cited above have been there since version 1.1 of dwarf2read.c. I don't know how relevant they are now - presumably today's compilers would rather use a declaration attribute rather than empty structs. Strictly speaking, the guard as implemented is wrong. So I propose to simply remove it. 2006-02-03 Joel Brobecker <brobecker@adacore.com> * dwarf2read.c (add_partial_symbol): Update copyright year. Do not skip struct, union and enum types with no children. 2006-02-03 Joel Brobecker <brobecker@adacore.com> * gdb.base/nofield.c: New file. * gdb.base/nofield.exp: New testcase. Tested on x86_64-linux. No regression. Nofield.exp has two FAILs before the patch, and is all PASS after. OK to apply? (It should fix the problem you are seeing, but I am unable to verify this, because I can't run your program on my machine. It was compiled with the shared version of the GNAT runtime (libgnat-4.0.so). Next time I'll make sure to ask to add -bargs -static. Can you verify that your FAIL is gone with this patch? - Thank you!) -- Joel
Attachment:
nochild.diff
Description: Text document
Attachment:
nofield.c
Description: Text document
Attachment:
nofield.exp
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |