/* Number of entries in the fnfieldlists array. */
int nfnfields;
+
+ /* typedefs defined inside this class. TYPEDEF_FIELD_LIST contains head of
+ a NULL terminated list of TYPEDEF_FIELD_LIST_COUNT elements. */
+ struct typedef_field_list
+ {
+ struct typedef_field field;
+ struct typedef_field_list *next;
+ }
+ *typedef_field_list;
+ unsigned typedef_field_list_count;
};
/* One item on the queue of compilation units to read in full symbols
static char *determine_prefix (struct die_info *die, struct dwarf2_cu *);
-static char *typename_concat (struct obstack *obs, const char *prefix,
+static char *typename_concat (struct obstack *obs, const char *prefix,
const char *suffix, int physname,
struct dwarf2_cu *cu);
static CORE_ADDR decode_locdesc (struct dwarf_block *, struct dwarf2_cu *);
-static enum dwarf_array_dim_ordering read_array_order (struct die_info *,
+static enum dwarf_array_dim_ordering read_array_order (struct die_info *,
struct dwarf2_cu *);
static struct die_info *read_comp_unit (gdb_byte *, struct dwarf2_cu *);
{
gdb_byte *initial_types_ptr = types_ptr;
- dwarf2_read_section (dwarf2_per_objfile->objfile,
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
&dwarf2_per_objfile->types);
cu_header->offset = types_ptr - dwarf2_per_objfile->types.buffer;
psymtabs_addrmap_cleanup (void *o)
{
struct objfile *objfile = o;
+
objfile->psymtabs_addrmap = NULL;
}
n_allocated = 10;
all_comp_units = xmalloc (n_allocated
* sizeof (struct dwarf2_per_cu_data *));
-
+
while (info_ptr < dwarf2_per_objfile->info.buffer + dwarf2_per_objfile->info.size)
{
unsigned int length, initial_length_size;
DW_TAG_namespace DIEs with a name of "::" for the global namespace.
Work around this problem here. */
if (cu->language == language_cplus
- && parent->tag == DW_TAG_namespace
+ && parent->tag == DW_TAG_namespace
&& strcmp (parent->name, "::") == 0
&& grandparent_scope == NULL)
{
symbol for that subprogram. When the CU language allows it, this
routine also defines a partial symbol for each nested subprogram
that this subprogram contains.
-
+
DIE my also be a lexical block, in which case we simply search
recursively for suprograms defined inside that lexical block.
Again, this is only performed when the CU language allows this
add_partial_symbol (pdi, cu);
}
}
-
+
if (! pdi->has_children)
return;
/* For Java and C++ methods, append formal parameter type
information, if PHYSNAME. */
-
+
if (physname && die->tag == DW_TAG_subprogram
&& (cu->language == language_cplus
|| cu->language == language_java))
bfd *abfd = objfile->obfd;
struct line_header *line_header = 0;
CORE_ADDR baseaddr;
-
+
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
get_scope_pc_bounds (die, &lowpc, &highpc, cu);
}
attr = dwarf2_attr (die, DW_AT_producer, cu);
- if (attr)
+ if (attr)
cu->producer = DW_STRING (attr);
/* We assume that we're processing GCC output. */
/* This isn't technically needed today. It is done for symmetry
with read_file_scope. */
attr = dwarf2_attr (die, DW_AT_producer, cu);
- if (attr)
+ if (attr)
cu->producer = DW_STRING (attr);
/* We assume that we're processing GCC output. */
/* If we have address ranges, record them. */
dwarf2_record_block_ranges (die, block, baseaddr, cu);
-
+
/* In C++, we can have functions nested inside functions (e.g., when
a function declares a class that has methods). This means that
when we finish processing a function scope, we may need to go
/* Ignore blocks with missing or invalid low and high pc attributes. */
/* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges
as multiple lexical blocks? Handling children in a sane way would
- be nasty. Might be easier to properly extend generic blocks to
+ be nasty. Might be easier to properly extend generic blocks to
describe ranges. */
if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
return;
subprograms or lexical blocks), we're done. */
if (cu->language != language_ada)
return;
-
+
/* Check all the children of the given DIE. If it contains nested
subprograms, then check their pc bounds. Likewise, we need to
check lexical blocks as well, as they may also contain subprogram
return;
}
- record_block_range (block,
- baseaddr + base + start,
+ record_block_range (block,
+ baseaddr + base + start,
baseaddr + base + end - 1);
}
}
static void
dwarf2_add_field (struct field_info *fip, struct die_info *die,
struct dwarf2_cu *cu)
-{
+{
struct objfile *objfile = cu->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct nextfield *new_field;
fp = &new_field->field;
+ /* NOTE: According to the dwarf standard, static data members are
+ indicated by having DW_AT_external.
+ The check here for ! die_is_declaration is historical.
+ This test is replicated in new_symbol. */
+
if (die->tag == DW_TAG_member && ! die_is_declaration (die, cu))
{
/* Data member other than a C++ static data member. */
-
+
/* Get type of field. */
fp->type = die_type (die, cu);
is a declaration, but all versions of G++ as of this writing
(so through at least 3.2.1) incorrectly generate
DW_TAG_variable tags. */
-
+
char *physname;
/* Get name of field. */
if (fieldname == NULL)
return;
+ attr = dwarf2_attr (die, DW_AT_const_value, cu);
+ if (attr)
+ {
+ /* A static const member, not much different than an enum as far as
+ we're concerned, except that we can support more types. */
+ new_symbol (die, NULL, cu);
+ }
+
/* Get physical name. */
physname = (char *) dwarf2_physname (fieldname, die, cu);
}
}
+/* Add a typedef defined in the scope of the FIP's class. */
+
+static void
+dwarf2_add_typedef (struct field_info *fip, struct die_info *die,
+ struct dwarf2_cu *cu)
+{
+ struct objfile *objfile = cu->objfile;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ struct typedef_field_list *new_field;
+ struct attribute *attr;
+ struct typedef_field *fp;
+ char *fieldname = "";
+
+ /* Allocate a new field list entry and link it in. */
+ new_field = xzalloc (sizeof (*new_field));
+ make_cleanup (xfree, new_field);
+
+ gdb_assert (die->tag == DW_TAG_typedef);
+
+ fp = &new_field->field;
+
+ /* Get name of field. */
+ fp->name = dwarf2_name (die, cu);
+ if (fp->name == NULL)
+ return;
+
+ fp->type = read_type_die (die, cu);
+
+ new_field->next = fip->typedef_field_list;
+ fip->typedef_field_list = new_field;
+ fip->typedef_field_list_count++;
+}
+
/* Create the vector of fields, and attach it to the type. */
static void
complaint (&symfile_complaints,
_("Member function \"%s\" (offset %d) is virtual but the vtable offset is not specified"),
fieldname, die->offset);
+ ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_CPLUS_DYNAMIC (type) = 1;
}
}
struct type *type;
struct attribute *attr;
char *name;
- struct cleanup *back_to = make_cleanup (null_cleanup, 0);
+ struct cleanup *back_to;
/* If the definition of this type lives in .debug_types, read that type.
Don't follow DW_AT_specification though, that will take us back up
return set_die_type (die, type, cu);
}
+ back_to = make_cleanup (null_cleanup, 0);
+
type = alloc_type (objfile);
INIT_CPLUS_SPECIFIC (type);
/* C++ base class field. */
dwarf2_add_field (&fi, child_die, cu);
}
+ else if (child_die->tag == DW_TAG_typedef)
+ dwarf2_add_typedef (&fi, child_die, cu);
child_die = sibling_die (child_die);
}
}
}
}
+
+ /* Copy fi.typedef_field_list linked list elements content into the
+ allocated array TYPE_TYPEDEF_FIELD_ARRAY (type). */
+ if (fi.typedef_field_list)
+ {
+ int i = fi.typedef_field_list_count;
+
+ ALLOCATE_CPLUS_STRUCT_TYPE (type);
+ TYPE_TYPEDEF_FIELD_ARRAY (type)
+ = TYPE_ALLOC (type, sizeof (TYPE_TYPEDEF_FIELD (type, 0)) * i);
+ TYPE_TYPEDEF_FIELD_COUNT (type) = i;
+
+ /* Reverse the list order to keep the debug info elements order. */
+ while (--i >= 0)
+ {
+ struct typedef_field *dest, *src;
+
+ dest = &TYPE_TYPEDEF_FIELD (type, i);
+ src = &fi.typedef_field_list->field;
+ fi.typedef_field_list = fi.typedef_field_list->next;
+ *dest = *src;
+ }
+ }
}
quirk_gcc_member_function_pointer (type, cu->objfile);
name = dwarf2_name (die, cu);
if (name)
TYPE_NAME (type) = name;
-
+
/* Install the type in the die. */
set_die_type (die, type, cu);
}
static enum dwarf_array_dim_ordering
-read_array_order (struct die_info *die, struct dwarf2_cu *cu)
+read_array_order (struct die_info *die, struct dwarf2_cu *cu)
{
struct attribute *attr;
/*
GNU F77 is a special case, as at 08/2004 array type info is the
- opposite order to the dwarf2 specification, but data is still
+ opposite order to the dwarf2 specification, but data is still
laid out as per normal fortran.
- FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
+ FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need
version checking.
*/
return DW_ORD_row_major;
}
- switch (cu->language_defn->la_array_ordering)
+ switch (cu->language_defn->la_array_ordering)
{
case array_column_major:
return DW_ORD_col_major;
if (die->child != NULL)
{
struct die_info *child_die = die->child;
-
+
while (child_die && child_die->tag)
{
process_die (child_die, cu);
{
complaint (&symfile_complaints, _("invalid pointer size %d"), byte_size);
}
- else
+ else
{
/* Should we also complain about unhandled address classes? */
}
we don't infinitely recurse when dealing with parameters
declared as the same subroutine type. */
set_die_type (die, ftype, cu);
-
+
if (die->child != NULL)
{
struct type *void_type = objfile_type (cu->objfile)->builtin_void;
type_flags |= TYPE_FLAG_UNSIGNED;
break;
case DW_ATE_signed_char:
- if (cu->language == language_ada || cu->language == language_m2
+ if (cu->language == language_ada || cu->language == language_m2
|| cu->language == language_pascal)
code = TYPE_CODE_CHAR;
break;
code = TYPE_CODE_CHAR;
type_flags |= TYPE_FLAG_UNSIGNED;
break;
+ case DW_ATE_UTF:
+ /* We just treat this as an integer and then recognize the
+ type by name elsewhere. */
+ break;
+
default:
complaint (&symfile_complaints, _("unsupported DW_AT_encoding: '%s'"),
dwarf_type_encoding_name (encoding));
return range_type;
if (cu->language == language_fortran)
- {
+ {
/* FORTRAN implies a lower bound of 1, if not given. */
low = 1;
}
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
if (attr)
- {
+ {
if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
{
/* GCC encodes arrays with unspecified or dynamic length
}
}
- negative_mask =
+ negative_mask =
(LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
low |= negative_mask;
name = dwarf2_name (die, cu);
if (name)
TYPE_NAME (range_type) = name;
-
+
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr)
TYPE_LENGTH (range_type) = DW_UNSND (attr);
return range_type;
}
-
+
static struct type *
read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu)
{
allocated_attrs = ATTR_ALLOC_CHUNK;
cur_attrs = xmalloc (allocated_attrs * sizeof (struct attr_abbrev));
-
+
/* loop until we reach an abbrev number of 0 */
while (abbrev_number)
{
from:
http://reality.sgiweb.org/davea/dwarf3-draft8-011125.pdf
-
+
This document is only a draft and is subject to change. (So beware.)
Details regarding the older, non-standard 64-bit format were
lh->include_dirs[lh->num_include_dirs++] = include_dir;
}
-
+
/* Add an entry to LH's file name table. */
static void
fe->included_p = 0;
fe->symtab = NULL;
}
-
+
/* Read the statement program header starting at OFFSET in
.debug_line, according to the endianness of ABFD. Return a pointer
line_ptr = dwarf2_per_objfile->line.buffer + offset;
/* Read in the header. */
- lh->total_length =
+ lh->total_length =
read_checked_initial_length_and_offset (abfd, line_ptr, &cu->header,
&bytes_read, &offset_size);
line_ptr += bytes_read;
add_file_name (lh, cur_file, dir_index, mod_time, length);
}
line_ptr += bytes_read;
- lh->statement_program_start = line_ptr;
+ lh->statement_program_start = line_ptr;
if (line_ptr > (dwarf2_per_objfile->line.buffer
+ dwarf2_per_objfile->line.size))
to create all necessary symbol tables, and their linetables.
The compilation directory of the file is passed in COMP_DIR,
and must not be NULL.
-
+
2. If PST is not NULL, this procedure reads the program to determine
the list of files included by the unit represented by PST, and
builds all the associated partial symbol tables. In this case,
}
if (op_code >= lh->opcode_base)
- {
+ {
/* Special operand. */
adj_opcode = op_code - lh->opcode_base;
address += (((op_index + (adj_opcode / lh->line_range))
{
char *cur_file;
unsigned int dir_index, mod_time, length;
-
+
cur_file = read_string (abfd, line_ptr, &bytes_read);
line_ptr += bytes_read;
dir_index =
BLOCK_FUNCTION from the blockvector. */
break;
case DW_TAG_variable:
+ case DW_TAG_member:
/* Compilation with minimal debug info may result in variables
with missing type entries. Change the misleading `void' type
to something sensible. */
= objfile_type (objfile)->nodebug_data_symbol;
attr = dwarf2_attr (die, DW_AT_const_value, cu);
+ /* In the case of DW_TAG_member, we should only be called for
+ static const members. */
+ if (die->tag == DW_TAG_member)
+ {
+ /* NOTE: This test seems wrong according to the dwarf standard.
+ static data members are represented by DW_AT_external.
+ However, dwarf2_add_field is currently calling
+ die_is_declaration to check, so we do the same. */
+ gdb_assert (die_is_declaration (die, cu));
+ gdb_assert (attr);
+ }
if (attr)
{
dwarf2_const_value (attr, sym, cu);
&& (cu->language == language_cplus
|| cu->language == language_java)
? &global_symbols : cu->list_in_scope);
-
+
add_symbol_to_list (sym, list_to_add);
/* The semantics of C++ state that "struct foo { ... }" also
&& (cu->language == language_cplus
|| cu->language == language_java)
? &global_symbols : cu->list_in_scope);
-
+
add_symbol_to_list (sym, list_to_add);
}
break;
cu_header->addr_size,
TYPE_LENGTH (SYMBOL_TYPE
(sym)));
- SYMBOL_VALUE_BYTES (sym) =
+ SYMBOL_VALUE_BYTES (sym) =
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. */
this_type = read_type_die (die, cu);
if (!this_type)
{
- dump_die_for_error (die);
- error (_("Dwarf Error: Cannot find type of die [in module %s]"),
- cu->objfile->name);
+ char *message, *saved;
+
+ /* read_type_die already issued a complaint. */
+ message = xstrprintf (_("<unknown type in %s, CU 0x%x, DIE 0x%x>"),
+ cu->objfile->name,
+ cu->header.offset,
+ die->offset);
+ saved = obstack_copy0 (&cu->objfile->objfile_obstack,
+ message, strlen (message));
+ xfree (message);
+
+ this_type = init_type (TYPE_CODE_ERROR, 0, 0, saved, cu->objfile);
}
return this_type;
}
return "DW_ATE_unsigned_fixed";
case DW_ATE_decimal_float:
return "DW_ATE_decimal_float";
+ /* DWARF 4. */
+ case DW_ATE_UTF:
+ return "DW_ATE_UTF";
/* HP extensions. */
case DW_ATE_HP_float80:
return "DW_ATE_HP_float80";
if (1 <= file && file <= lh->num_file_names)
{
struct file_entry *fe = &lh->file_names[file - 1];
-
+
if (IS_ABSOLUTE_PATH (fe->name))
return xstrdup (fe->name);
else
sprintf (fake_name, "<bad macro file number %d>", file);
- complaint (&symfile_complaints,
+ complaint (&symfile_complaints,
_("bad file number in macro information (%d)"),
file);
current_file = macro_include (current_file, line, full_name);
xfree (full_name);
-
+
return current_file;
}
The Dwarf 2 spec says that an object-like macro's name is always
followed by a space, but versions of GCC around March 2002 omit
- the space when the macro's definition is the empty string.
+ the space when the macro's definition is the empty string.
The Dwarf 2 spec says that there should be no spaces between the
formal arguments in a function-like macro's formal argument list,
dwarf2_macro_malformed_definition_complaint (body);
replacement = body + name_len;
}
-
+
macro_define_object (file, line, name, replacement);
xfree (name);
if (*p == ' ')
/* Perfectly formed definition, no complaints. */
macro_define_function (file, line, name,
- argc, (const char **) argv,
+ argc, (const char **) argv,
p + 1);
else if (*p == '\0')
{
/* Complain, but do define it. */
dwarf2_macro_malformed_definition_complaint (body);
macro_define_function (file, line, name,
- argc, (const char **) argv,
+ argc, (const char **) argv,
p);
}
else
complaint (&symfile_complaints,
_("debug info with no main source gives macro %s "
"on line %d: %s"),
- macinfo_type == DW_MACINFO_define ?
- _("definition") :
+ macinfo_type == DW_MACINFO_define ?
+ _("definition") :
macinfo_type == DW_MACINFO_undef ?
_("undefinition") :
_("something-or-other"), line, body);
_("debug info gives %s macro %s with %s line %d: %s"),
at_commandline ? _("command-line") : _("in-file"),
macinfo_type == DW_MACINFO_define ?
- _("definition") :
+ _("definition") :
macinfo_type == DW_MACINFO_undef ?
_("undefinition") :
_("something-or-other"),
baton->size = 0;
baton->data = NULL;
}
-
+
SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
SYMBOL_LOCATION_BATON (sym) = baton;
}
static void
show_dwarf2_cmd (char *args, int from_tty)
-{
+{
cmd_show_list (show_dwarf2_cmdlist, from_tty, "");
}