This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Better support for DWARF location blocks (was DWARF support for .debug_loc offsets)
- From: Petr Sorfa <petrs at caldera dot com>
- To: Jim Blandy <jimb at redhat dot com>
- Cc: "gdb-patches at sources dot redhat dot com" <gdb-patches at sources dot redhat dot com>
- Date: Fri, 12 Jul 2002 12:21:47 -0400
- Subject: Re: [RFA] Better support for DWARF location blocks (was DWARF support for .debug_loc offsets)
- Organization: Caldera
- References: <3D2DE995.BE7DA3B4@caldera.com> <npn0sxue43.fsf@zwingli.cygnus.com>
Hi Jim,
Thanks, will make the change.
Petr
> Looks good --- please commit. Thank you!
>
> But --- could you make a function attr_form_is_block that takes an
> attribute and returns true if its form is one of the DW_FORM_block*
> forms, and use that instead of writing out the list each time?
>
> Petr Sorfa <petrs@caldera.com> writes:
>
> > Hi,
> >
> > This patch provides better error detection when processing certain DWARF
> > location blocks. Basically an error is given in these cases when the
> > attribute's form is not a DW_AT_block*.
> >
> > Again, this patch does not support in read_tag_string_type() the
> > DW_AT_string_length attribute which is currently being misused by GCC
> > (it uses it to hold the length, rather than the location to the length)
> > and GDB supports this incorrect form.
> >
> > 2002-07-11 Petr Sorfa (petrs@caldera.com)
> >
> > * 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".Index: dwarf2read.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> > retrieving revision 1.60
> > diff -c -p -r1.60 dwarf2read.c
> > *** dwarf2read.c 22 Jun 2002 00:05:59 -0000 1.60
> > --- dwarf2read.c 11 Jul 2002 20:03:34 -0000
> > *************** static struct complaint dwarf2_macro_spa
> > *** 658,663 ****
> > --- 658,667 ----
> > {
> > "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 */
> >
> > *************** read_func_scope (struct die_info *die, s
> > *** 1870,1876 ****
> > attr = dwarf_attr (die, DW_AT_frame_base);
> > if (attr)
> > {
> > ! CORE_ADDR addr = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
> > if (isderef)
> > complain (&dwarf2_unsupported_at_frame_base, name);
> > else if (isreg)
> > --- 1874,1900 ----
> > attr = dwarf_attr (die, DW_AT_frame_base);
> > if (attr)
> > {
> > ! CORE_ADDR addr;
> > !
> > ! /* Support the .debug_loc offsets */
> > ! if (attr->form == DW_FORM_block1
> > ! || attr->form == DW_FORM_block2
> > ! || attr->form == DW_FORM_block4
> > ! || attr->form == DW_FORM_block)
> > ! {
> > ! 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)
> > *************** dwarf2_add_member_fn (struct field_info
> > *** 2348,2354 ****
> > /* 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;
> > }
> >
> > /* Create the vector of member function fields, and attach it to the type. */
> > --- 2372,2396 ----
> > /* Get index in virtual function table if it is a virtual member function. */
> > attr = dwarf_attr (die, DW_AT_vtable_elem_location);
> > if (attr)
> > ! {
> > ! /* Support the .debug_loc offsets */
> > ! if (attr->form == DW_FORM_block1
> > ! || attr->form == DW_FORM_block2
> > ! || attr->form == DW_FORM_block4
> > ! || attr->form == DW_FORM_block)
> > ! {
> > ! 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. */
> > *************** read_common_block (struct die_info *die,
> > *** 2812,2818 ****
> > attr = dwarf_attr (die, DW_AT_location);
> > if (attr)
> > {
> > ! base = decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
> > }
> > if (die->has_children)
> > {
> > --- 2854,2876 ----
> > attr = dwarf_attr (die, DW_AT_location);
> > if (attr)
> > {
> > ! /* Support the .debug_loc offsets */
> > ! if (attr->form == DW_FORM_block1
> > ! || attr->form == DW_FORM_block2
> > ! || attr->form == DW_FORM_block4
> > ! || attr->form == DW_FORM_block)
> > ! {
> > ! 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)
> > {
> > *************** read_partial_die (struct partial_die_inf
> > *** 3458,3464 ****
> > part_die->highpc = DW_ADDR (&attr);
> > break;
> > case DW_AT_location:
> > ! part_die->locdesc = DW_BLOCK (&attr);
> > break;
> > case DW_AT_language:
> > part_die->language = DW_UNSND (&attr);
> > --- 3516,3538 ----
> > part_die->highpc = DW_ADDR (&attr);
> > break;
> > case DW_AT_location:
> > ! /* Support the .debug_loc offsets */
> > ! if (attr.form == DW_FORM_block1
> > ! || attr.form == DW_FORM_block2
> > ! || attr.form == DW_FORM_block4
> > ! || attr.form == DW_FORM_block)
> > ! {
> > ! 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);
> > *************** new_symbol (struct die_info *die, struct
> > *** 4522,4528 ****
> > char *name;
> > struct attribute *attr = NULL;
> > struct attribute *attr2 = NULL;
> > ! CORE_ADDR addr;
> >
> > name = dwarf2_linkage_name (die);
> > if (name)
> > --- 4596,4602 ----
> > char *name;
> > struct attribute *attr = NULL;
> > struct attribute *attr2 = NULL;
> > ! CORE_ADDR addr = 0;
> >
> > name = dwarf2_linkage_name (die);
> > if (name)
> > *************** new_symbol (struct die_info *die, struct
> > *** 4606,4613 ****
> > 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);
> > add_symbol_to_list (sym, &global_symbols);
> >
> > /* In shared libraries the address of the variable
> > --- 4680,4704 ----
> > attr2 = dwarf_attr (die, DW_AT_external);
> > if (attr2 && (DW_UNSND (attr2) != 0))
> > {
> > ! /* Support the .debug_loc offsets */
> > ! if (attr->form == DW_FORM_block1
> > ! || attr->form == DW_FORM_block2
> > ! || attr->form == DW_FORM_block4
> > ! || attr->form == DW_FORM_block)
> > ! {
> > ! 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
> > *************** new_symbol (struct die_info *die, struct
> > *** 4630,4637 ****
> > }
> > else
> > {
> > ! SYMBOL_VALUE (sym) = addr =
> > ! decode_locdesc (DW_BLOCK (attr), objfile, cu_header);
> > add_symbol_to_list (sym, list_in_scope);
> > if (optimized_out)
> > {
> > --- 4721,4746 ----
> > }
> > else
> > {
> > ! /* Support the .debug_loc offsets */
> > ! if (attr->form == DW_FORM_block1
> > ! || attr->form == DW_FORM_block2
> > ! || attr->form == DW_FORM_block4
> > ! || attr->form == DW_FORM_block)
> > ! {
> > ! 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)
> > {