From 8e19ed76b7ae680bcefc97d17b943591ee4b84e7 Mon Sep 17 00:00:00 2001 From: Petr Sorfa Date: Fri, 12 Jul 2002 19:55:10 +0000 Subject: [PATCH] 2002-07-12 Petr Sorfa * dwarf2read.c (dwarf2_invalid_attrib_class): New complaint for invalid attribute class or form. (read_func_scope): DW_AT_frame_base better handling of DW_AT_block*. (dwarf2_add_member_fn): DW_AT_vtable_elem_location better handling of DW_AT_block*. (read_common_block): DW_AT_location better handling of DW_AT_block*. (read_partial_die): DW_AT_location better handling of DW_AT_block*. (new_symbol): DW_AT_external better handling of DW_AT_block*. Proper initialization of variable "addr". (attr_form_is_block): New function that returns true if the attribute's form is of DW_FORM_block*. --- gdb/ChangeLog | 18 +++++++ gdb/dwarf2read.c | 123 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 132 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 364c4b1126b..5f6a4fd9d36 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +2002-07-12 Petr Sorfa + + * dwarf2read.c (dwarf2_invalid_attrib_class): New + complaint for invalid attribute class or form. + (read_func_scope): DW_AT_frame_base + better handling of DW_AT_block*. + (dwarf2_add_member_fn): DW_AT_vtable_elem_location + better handling of DW_AT_block*. + (read_common_block): DW_AT_location + better handling of DW_AT_block*. + (read_partial_die): DW_AT_location better handling + of DW_AT_block*. + (new_symbol): DW_AT_external better handling of + DW_AT_block*. Proper initialization of variable + "addr". + (attr_form_is_block): New function that returns true + if the attribute's form is of DW_FORM_block*. + 2002-07-12 Peter Schauer * valops.c (find_method_list): Remove comment about diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index fde7d3b7b87..786dffc5115 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -658,6 +658,10 @@ static struct complaint dwarf2_macro_spaces_in_definition = { "macro definition contains spaces in formal argument list:\n`%s'", 0, 0 }; +static struct complaint dwarf2_invalid_attrib_class = +{ + "invalid attribute class or form for '%s' in '%s'", 0, 0 +}; /* local function prototypes */ @@ -906,6 +910,8 @@ static void dwarf_decode_macros (struct line_header *, unsigned int, char *, bfd *, const struct comp_unit_head *, struct objfile *); +static int attr_form_is_block (struct attribute *); + /* Try to locate the sections we need for DWARF 2 debugging information and return true if we have enough to do something. */ @@ -1870,7 +1876,24 @@ read_func_scope (struct die_info *die, struct objfile *objfile, attr = dwarf_attr (die, DW_AT_frame_base); if (attr) { - CORE_ADDR addr = decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + CORE_ADDR addr; + + /* Support the .debug_loc offsets */ + if (attr_form_is_block (attr)) + { + addr = decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + } + else if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) + { + complain (&dwarf2_complex_location_expr); + addr = 0; + } + else + { + complain (&dwarf2_invalid_attrib_class, "DW_AT_frame_base", name); + addr = 0; + } + if (isderef) complain (&dwarf2_unsupported_at_frame_base, name); else if (isreg) @@ -2348,7 +2371,22 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* Get index in virtual function table if it is a virtual member function. */ attr = dwarf_attr (die, DW_AT_vtable_elem_location); if (attr) - fnp->voffset = decode_locdesc (DW_BLOCK (attr), objfile, cu_header) + 2; + { + /* Support the .debug_loc offsets */ + if (attr_form_is_block (attr)) + { + fnp->voffset = decode_locdesc (DW_BLOCK (attr), objfile, cu_header) + 2; + } + else if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) + { + complain (&dwarf2_complex_location_expr); + } + else + { + complain (&dwarf2_invalid_attrib_class, "DW_AT_vtable_elem_location", + fieldname); + } + } } /* Create the vector of member function fields, and attach it to the type. */ @@ -2812,7 +2850,20 @@ read_common_block (struct die_info *die, struct objfile *objfile, attr = dwarf_attr (die, DW_AT_location); if (attr) { - base = decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + /* Support the .debug_loc offsets */ + if (attr_form_is_block (attr)) + { + base = decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + } + else if (attr->form == DW_FORM_data4 || attr->form == DW_FORM_data8) + { + complain (&dwarf2_complex_location_expr); + } + else + { + complain (&dwarf2_invalid_attrib_class, "DW_AT_location", + "common block member"); + } } if (die->has_children) { @@ -3458,7 +3509,20 @@ read_partial_die (struct partial_die_info *part_die, bfd *abfd, part_die->highpc = DW_ADDR (&attr); break; case DW_AT_location: - part_die->locdesc = DW_BLOCK (&attr); + /* Support the .debug_loc offsets */ + if (attr_form_is_block (&attr)) + { + part_die->locdesc = DW_BLOCK (&attr); + } + else if (attr.form == DW_FORM_data4 || attr.form == DW_FORM_data8) + { + complain (&dwarf2_complex_location_expr); + } + else + { + complain (&dwarf2_invalid_attrib_class, "DW_AT_location", + "partial symbol information"); + } break; case DW_AT_language: part_die->language = DW_UNSND (&attr); @@ -4522,7 +4586,7 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile, char *name; struct attribute *attr = NULL; struct attribute *attr2 = NULL; - CORE_ADDR addr; + CORE_ADDR addr = 0; name = dwarf2_linkage_name (die); if (name) @@ -4606,8 +4670,22 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile, attr2 = dwarf_attr (die, DW_AT_external); if (attr2 && (DW_UNSND (attr2) != 0)) { - SYMBOL_VALUE_ADDRESS (sym) = - decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + /* Support the .debug_loc offsets */ + if (attr_form_is_block (attr)) + { + SYMBOL_VALUE_ADDRESS (sym) = + decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + } + else if (attr->form == DW_FORM_data4 + || attr->form == DW_FORM_data8) + { + complain (&dwarf2_complex_location_expr); + } + else + { + complain (&dwarf2_invalid_attrib_class, "DW_AT_location", + "external variable"); + } add_symbol_to_list (sym, &global_symbols); /* In shared libraries the address of the variable @@ -4630,8 +4708,23 @@ new_symbol (struct die_info *die, struct type *type, struct objfile *objfile, } else { - SYMBOL_VALUE (sym) = addr = - decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + /* Support the .debug_loc offsets */ + if (attr_form_is_block (attr)) + { + SYMBOL_VALUE (sym) = addr = + decode_locdesc (DW_BLOCK (attr), objfile, cu_header); + } + else if (attr->form == DW_FORM_data4 + || attr->form == DW_FORM_data8) + { + complain (&dwarf2_complex_location_expr); + } + else + { + complain (&dwarf2_invalid_attrib_class, "DW_AT_location", + "external variable"); + addr = 0; + } add_symbol_to_list (sym, list_in_scope); if (optimized_out) { @@ -6794,3 +6887,15 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset, } } } + +/* Check if the attribute's form is a DW_FORM_block* + if so return true else false. */ +static int +attr_form_is_block (struct attribute *attr) +{ + return (attr == NULL ? 0 : + attr->form == DW_FORM_block1 + || attr->form == DW_FORM_block2 + || attr->form == DW_FORM_block4 + || attr->form == DW_FORM_block); +} -- 2.30.2