#include "bfd.h"
#include "symtab.h"
#include "gdbtypes.h"
-#include "symfile.h"
#include "objfiles.h"
#include "elf/dwarf2.h"
#include "buildsym.h"
/* We put a pointer to this structure in the read_symtab_private field
of the psymtab.
The complete dwarf information for an objfile is kept in the
- psymbol_obstack, so that absolute die references can be handled.
+ objfile_obstack, so that absolute die references can be handled.
Most of the information in this structure is related to an entire
object file and could be passed via the sym_private field of the objfile.
It is however conceivable that dwarf2 might not be the only type
objfile->static_psymbols.next);
pst->read_symtab_private = (char *)
- obstack_alloc (&objfile->psymbol_obstack, sizeof (struct dwarf2_pinfo));
+ obstack_alloc (&objfile->objfile_obstack, sizeof (struct dwarf2_pinfo));
DWARF_INFO_BUFFER (pst) = dwarf_info_buffer;
DWARF_INFO_OFFSET (pst) = beg_of_comp_unit - dwarf_info_buffer;
DWARF_ABBREV_BUFFER (pst) = dwarf_abbrev_buffer;
char *actual_class_name = NULL;
if (cu->language == language_cplus
- && namespace == NULL
+ && (namespace == NULL || namespace[0] == '\0')
&& struct_pdi->name != NULL
&& struct_pdi->has_children)
{
- /* We don't have namespace debugging information, so see if we
- can figure out if this structure lives in a namespace. Look
+ /* See if we can figure out if the class lives in a namespace
+ (or is nested within another class.) We do this by looking
for a member function; its demangled name will contain
namespace info, if there is any. */
could fix this by only using the demangled name to get the
prefix (but see comment in read_structure_scope). */
+ /* FIXME: carlton/2004-01-23: If NAMESPACE equals "", we have
+ the appropriate debug information, so it would be nice to be
+ able to avoid this hack. But NAMESPACE may not be the
+ namespace where this class was defined: NAMESPACE reflects
+ where STRUCT_PDI occurs in the tree of dies, but because of
+ DW_AT_specification, that may not actually tell us where the
+ class is defined. (See the comment in read_func_scope for an
+ example of how this could occur.)
+
+ Unfortunately, our current partial symtab data structures are
+ completely unable to deal with DW_AT_specification. So, for
+ now, the best thing to do is to get nesting information from
+ places other than the tree structure of dies if there's any
+ chance that a DW_AT_specification is involved. :-( */
+
char *next_child = info_ptr;
while (1)
{
struct die_info *spec_die = die_specification (die, cu);
- /* NOTE: carlton/2004-01-23: We have to be careful in the
- presence of DW_AT_specification. For example, with GCC
- 3.4, given the code
+ /* NOTE: carlton/2004-01-23: We have to be careful in the
+ presence of DW_AT_specification. For example, with GCC 3.4,
+ given the code
- namespace N {
- void foo() {
- // Definition of N::foo.
- }
- }
+ namespace N {
+ void foo() {
+ // Definition of N::foo.
+ }
+ }
- then we'll have a tree of DIEs like this:
+ then we'll have a tree of DIEs like this:
- 1: DW_TAG_compile_unit
- 2: DW_TAG_namespace // N
- 3: DW_TAG_subprogram // declaration of N::foo
- 4: DW_TAG_subprogram // definition of N::foo
- DW_AT_specification // refers to die #3
+ 1: DW_TAG_compile_unit
+ 2: DW_TAG_namespace // N
+ 3: DW_TAG_subprogram // declaration of N::foo
+ 4: DW_TAG_subprogram // definition of N::foo
+ DW_AT_specification // refers to die #3
- Thus, when processing die #4, we have to pretend that
- we're in the context of its DW_AT_specification, namely
- the contex of die #3. */
+ Thus, when processing die #4, we have to pretend that we're
+ in the context of its DW_AT_specification, namely the contex
+ of die #3. */
if (spec_die != NULL)
{
if (attr && DW_STRING (attr))
fieldname = DW_STRING (attr);
fp->name = obsavestring (fieldname, strlen (fieldname),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
/* Change accessibility for artificial fields (e.g. virtual table
pointer or virtual base class pointer) to private. */
physname = dwarf2_linkage_name (die, cu);
SET_FIELD_PHYSNAME (*fp, obsavestring (physname, strlen (physname),
- &objfile->type_obstack));
+ &objfile->objfile_obstack));
FIELD_TYPE (*fp) = die_type (die, cu);
FIELD_NAME (*fp) = obsavestring (fieldname, strlen (fieldname),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
}
else if (die->tag == DW_TAG_inheritance)
{
/* Fill in the member function field info. */
fnp = &new_fnfield->fnfield;
fnp->physname = obsavestring (physname, strlen (physname),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
fnp->type = alloc_type (objfile);
if (die->type && TYPE_CODE (die->type) == TYPE_CODE_FUNC)
{
TYPE_TAG_NAME to be a const char *, I ran into a cascade
of changes which would have forced decode_line_1 to take
a const char **. */
- char *new_prefix = obconcat (&objfile->type_obstack,
+ char *new_prefix = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
processing_current_prefix[0] == '\0'
? "" : "::",
else
{
TYPE_TAG_NAME (type) = obsavestring (name, strlen (name),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
need_to_update_name = (cu->language == language_cplus);
}
}
TYPE_TAG_NAME (type)
= obsavestring (actual_class_name,
strlen (actual_class_name),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
}
xfree (actual_class_name);
need_to_update_name = 0;
if (processing_has_namespace_info)
{
- TYPE_TAG_NAME (type) = obconcat (&objfile->type_obstack,
+ TYPE_TAG_NAME (type) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
processing_current_prefix[0] == '\0'
? "" : "::",
else
{
TYPE_TAG_NAME (type) = obsavestring (name, strlen (name),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
}
}
/* Read the contents of the section at OFFSET and of size SIZE from the
- object file specified by OBJFILE into the psymbol_obstack and return it. */
+ object file specified by OBJFILE into the objfile_obstack and return it. */
char *
dwarf2_read_section (struct objfile *objfile, asection *sectp)
if (size == 0)
return NULL;
- buf = (char *) obstack_alloc (&objfile->psymbol_obstack, size);
+ buf = (char *) obstack_alloc (&objfile->objfile_obstack, size);
retbuf
= (char *) symfile_relocate_debug_section (abfd, sectp, (bfd_byte *) buf);
if (retbuf != NULL)
if (name)
{
- sym = (struct symbol *) obstack_alloc (&objfile->symbol_obstack,
+ sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symbol));
OBJSTAT (objfile, n_syms++);
memset (sym, 0, sizeof (struct symbol));
SYMBOL_LINKAGE_NAME (sym)
= obsavestring (TYPE_TAG_NAME (type),
strlen (TYPE_TAG_NAME (type)),
- &objfile->symbol_obstack);
+ &objfile->objfile_obstack);
}
}
if (cu->language == language_cplus)
{
struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile->symbol_obstack,
+ obstack_alloc (&objfile->objfile_obstack,
sizeof (struct symbol));
*typedef_sym = *sym;
SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
TYPE_NAME (SYMBOL_TYPE (sym)) =
obsavestring (SYMBOL_NATURAL_NAME (sym),
strlen (SYMBOL_NATURAL_NAME (sym)),
- &objfile->type_obstack);
+ &objfile->objfile_obstack);
add_symbol_to_list (typedef_sym, list_to_add);
}
}
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->symbol_obstack,
+ SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
"::",
name);
if (processing_has_namespace_info
&& processing_current_prefix[0] != '\0')
{
- SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->symbol_obstack,
+ SYMBOL_LINKAGE_NAME (sym) = obconcat (&objfile->objfile_obstack,
processing_current_prefix,
"::",
name);
TYPE_LENGTH (SYMBOL_TYPE
(sym)));
SYMBOL_VALUE_BYTES (sym) = (char *)
- obstack_alloc (&objfile->symbol_obstack, cu_header->addr_size);
+ obstack_alloc (&objfile->objfile_obstack, cu_header->addr_size);
/* NOTE: cagney/2003-05-09: In-lined store_address call with
it's body - store_unsigned_integer. */
store_unsigned_integer (SYMBOL_VALUE_BYTES (sym), cu_header->addr_size,
TYPE_LENGTH (SYMBOL_TYPE
(sym)));
SYMBOL_VALUE_BYTES (sym) = (char *)
- obstack_alloc (&objfile->symbol_obstack, blk->size);
+ obstack_alloc (&objfile->objfile_obstack, blk->size);
memcpy (SYMBOL_VALUE_BYTES (sym), blk->data, blk->size);
SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
break;
/* We don't create a macro table for this compilation unit
at all until we actually get a filename. */
if (! pending_macros)
- pending_macros = new_macro_table (&objfile->symbol_obstack,
+ pending_macros = new_macro_table (&objfile->objfile_obstack,
objfile->macro_cache);
if (! current_file)
{
struct dwarf2_loclist_baton *baton;
- baton = obstack_alloc (&cu->objfile->symbol_obstack,
+ baton = obstack_alloc (&cu->objfile->objfile_obstack,
sizeof (struct dwarf2_loclist_baton));
baton->objfile = cu->objfile;
{
struct dwarf2_locexpr_baton *baton;
- baton = obstack_alloc (&cu->objfile->symbol_obstack,
+ baton = obstack_alloc (&cu->objfile->objfile_obstack,
sizeof (struct dwarf2_locexpr_baton));
baton->objfile = cu->objfile;