Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
/* DWARF attributes
|
|
|
|
|
|
|
|
Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
|
|
|
|
Inc. with support from Florida State University (under contract
|
|
|
|
with the Ada Joint Program Office), and Silicon Graphics, Inc.
|
|
|
|
Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
|
|
|
|
based on Fred Fish's (Cygnus Support) implementation of DWARF 1
|
|
|
|
support.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "dwarf2/attribute.h"
|
Change two functions to be methods on struct attribute
This changes dwarf2_get_ref_die_offset and
dwarf2_get_attr_constant_value to be methods on struct attribute.
gdb/ChangeLog
2020-03-26 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (handle_data_member_location, dwarf2_add_field)
(mark_common_block_symbol_computed, read_tag_string_type)
(attr_to_dynamic_prop, read_subrange_type): Update.
(dwarf2_get_ref_die_offset, dwarf2_get_attr_constant_value): Move
to be methods on struct attribute.
(skip_one_die, process_imported_unit_die, read_namespace_alias)
(read_call_site_scope, partial_die_info::read)
(partial_die_info::read, lookup_die_type, follow_die_ref):
Update.
* dwarf2/attribute.c (attribute::get_ref_die_offset): New method,
from dwarf2_get_ref_die_offset.
(attribute::constant_value): New method, from
dwarf2_get_attr_constant_value.
* dwarf2/attribute.h (struct attribute) <get_ref_die_offset>:
Declare method.
<constant_value>: New method.
2020-03-26 16:28:08 +01:00
|
|
|
#include "dwarf2/stringify.h"
|
|
|
|
#include "complaints.h"
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
|
|
|
|
/* See attribute.h. */
|
|
|
|
|
|
|
|
CORE_ADDR
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
attribute::value_as_address () const
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
{
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
if (form != DW_FORM_addr && form != DW_FORM_addrx
|
|
|
|
&& form != DW_FORM_GNU_addr_index)
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
{
|
|
|
|
/* Aside from a few clearly defined exceptions, attributes that
|
|
|
|
contain an address must always be in DW_FORM_addr form.
|
|
|
|
Unfortunately, some compilers happen to be violating this
|
|
|
|
requirement by encoding addresses using other forms, such
|
|
|
|
as DW_FORM_data4 for example. For those broken compilers,
|
|
|
|
we try to do our best, without any guarantee of success,
|
|
|
|
to interpret the address correctly. It would also be nice
|
|
|
|
to generate a complaint, but that would require us to maintain
|
|
|
|
a list of legitimate cases where a non-address form is allowed,
|
|
|
|
as well as update callers to pass in at least the CU's DWARF
|
|
|
|
version. This is more overhead than what we're willing to
|
|
|
|
expand for a pretty rare case. */
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
addr = DW_UNSND (this);
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
}
|
|
|
|
else
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
addr = DW_ADDR (this);
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See attribute.h. */
|
|
|
|
|
2020-04-24 23:35:01 +02:00
|
|
|
const char *
|
|
|
|
attribute::value_as_string () const
|
|
|
|
{
|
|
|
|
if (form == DW_FORM_strp || form == DW_FORM_line_strp
|
|
|
|
|| form == DW_FORM_string
|
|
|
|
|| form == DW_FORM_strx
|
|
|
|
|| form == DW_FORM_strx1
|
|
|
|
|| form == DW_FORM_strx2
|
|
|
|
|| form == DW_FORM_strx3
|
|
|
|
|| form == DW_FORM_strx4
|
|
|
|
|| form == DW_FORM_GNU_str_index
|
|
|
|
|| form == DW_FORM_GNU_strp_alt)
|
|
|
|
return DW_STRING (this);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See attribute.h. */
|
|
|
|
|
Change attr_form_is_block to be a method
This changes attr_form_is_block to be a method. This is done
separately because, unlike the other attribute functions,
attr_form_is_block had special handling for the case where the
argument was NULL. This required auditing each call site; in most
cases, NULL was already ruled out, but in a few spots, an additional
check was needed.
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (read_call_site_scope)
(handle_data_member_location, dwarf2_add_member_fn)
(mark_common_block_symbol_computed, read_common_block)
(attr_to_dynamic_prop, partial_die_info::read)
(var_decode_location, dwarf2_fetch_die_loc_sect_off)
(dwarf2_symbol_mark_computed, set_die_type): Update.
* dwarf2/attribute.h (struct attribute) <form_is_block>: Declare
method.
(attr_form_is_block): Don't declare.
* dwarf2/attribute.c (attribute::form_is_block): Now a method.
Change-Id: Idfb290c61d738301ab991666f43e0b9cf577b2ae
2020-02-08 21:40:54 +01:00
|
|
|
bool
|
|
|
|
attribute::form_is_block () const
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
{
|
Change attr_form_is_block to be a method
This changes attr_form_is_block to be a method. This is done
separately because, unlike the other attribute functions,
attr_form_is_block had special handling for the case where the
argument was NULL. This required auditing each call site; in most
cases, NULL was already ruled out, but in a few spots, an additional
check was needed.
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (read_call_site_scope)
(handle_data_member_location, dwarf2_add_member_fn)
(mark_common_block_symbol_computed, read_common_block)
(attr_to_dynamic_prop, partial_die_info::read)
(var_decode_location, dwarf2_fetch_die_loc_sect_off)
(dwarf2_symbol_mark_computed, set_die_type): Update.
* dwarf2/attribute.h (struct attribute) <form_is_block>: Declare
method.
(attr_form_is_block): Don't declare.
* dwarf2/attribute.c (attribute::form_is_block): Now a method.
Change-Id: Idfb290c61d738301ab991666f43e0b9cf577b2ae
2020-02-08 21:40:54 +01:00
|
|
|
return (form == DW_FORM_block1
|
|
|
|
|| form == DW_FORM_block2
|
|
|
|
|| form == DW_FORM_block4
|
|
|
|
|| form == DW_FORM_block
|
|
|
|
|| form == DW_FORM_exprloc);
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* See attribute.h. */
|
|
|
|
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
bool
|
|
|
|
attribute::form_is_section_offset () const
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
{
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
return (form == DW_FORM_data4
|
|
|
|
|| form == DW_FORM_data8
|
2020-04-07 15:05:58 +02:00
|
|
|
|| form == DW_FORM_sec_offset
|
|
|
|
|| form == DW_FORM_loclistx);
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* See attribute.h. */
|
|
|
|
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
bool
|
|
|
|
attribute::form_is_constant () const
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
{
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
switch (form)
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
{
|
|
|
|
case DW_FORM_sdata:
|
|
|
|
case DW_FORM_udata:
|
|
|
|
case DW_FORM_data1:
|
|
|
|
case DW_FORM_data2:
|
|
|
|
case DW_FORM_data4:
|
|
|
|
case DW_FORM_data8:
|
|
|
|
case DW_FORM_implicit_const:
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
return true;
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
default:
|
Change some attribute functions to be methods
This changes most of the attribute-related functions to be methods.
(attr_form_is_block changed in a subsequent patch.)
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_find_base_address, )
(read_call_site_scope, rust_containing_type)
(dwarf2_get_pc_bounds, dwarf2_record_block_ranges)
(handle_data_member_location, dwarf2_add_member_fn)
(get_alignment, read_structure_type, process_structure_scope)
(mark_common_block_symbol_computed, read_common_block)
(read_tag_string_type, attr_to_dynamic_prop, read_subrange_type)
(partial_die_info::read, read_attribute_value, new_symbol)
(lookup_die_type, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, follow_die_ref_or_sig)
(dwarf2_fetch_die_loc_sect_off, get_DW_AT_signature_type)
(dwarf2_symbol_mark_computed): Update.
* dwarf2/attribute.h (struct attribute) <value_as_address,
form_is_section_offset, form_is_constant, form_is_ref>: Declare
methods.
(value_as_address, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Don't declare.
* dwarf2/attribute.c (attribute::value_as_address)
(attribute::form_is_section_offset, attribute::form_is_constant)
(attribute::form_is_ref): Now methods.
Change-Id: I320dad13002c59b848dc86c39d5d7111c8a15bdc
2020-02-08 21:40:54 +01:00
|
|
|
return false;
|
Create dwarf2/attribute.[ch]
This moves the attribute-related code out of dwarf2read.c and into the
new files dwarf2/attribute.[ch].
gdb/ChangeLog
2020-02-08 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct attribute, DW_STRING)
(DW_STRING_IS_CANONICAL, DW_UNSND, DW_BLOCK, DW_SND, DW_ADDR)
(DW_SIGNATURE, struct dwarf_block, attr_value_as_address)
(attr_form_is_block, attr_form_is_section_offset)
(attr_form_is_constant, attr_form_is_ref): Move.
* dwarf2/attribute.h: New file.
* dwarf2/attribute.c: New file, from dwarf2read.c.
* Makefile.in (COMMON_SFILES): Add dwarf2/attribute.c.
Change-Id: I1ea4c146256a1b9e38b66f1c605d782a14eeded7
2020-02-08 21:40:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Change two functions to be methods on struct attribute
This changes dwarf2_get_ref_die_offset and
dwarf2_get_attr_constant_value to be methods on struct attribute.
gdb/ChangeLog
2020-03-26 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (handle_data_member_location, dwarf2_add_field)
(mark_common_block_symbol_computed, read_tag_string_type)
(attr_to_dynamic_prop, read_subrange_type): Update.
(dwarf2_get_ref_die_offset, dwarf2_get_attr_constant_value): Move
to be methods on struct attribute.
(skip_one_die, process_imported_unit_die, read_namespace_alias)
(read_call_site_scope, partial_die_info::read)
(partial_die_info::read, lookup_die_type, follow_die_ref):
Update.
* dwarf2/attribute.c (attribute::get_ref_die_offset): New method,
from dwarf2_get_ref_die_offset.
(attribute::constant_value): New method, from
dwarf2_get_attr_constant_value.
* dwarf2/attribute.h (struct attribute) <get_ref_die_offset>:
Declare method.
<constant_value>: New method.
2020-03-26 16:28:08 +01:00
|
|
|
/* See attribute.h. */
|
|
|
|
|
2020-05-27 19:48:18 +02:00
|
|
|
void
|
|
|
|
attribute::get_ref_die_offset_complaint () const
|
Change two functions to be methods on struct attribute
This changes dwarf2_get_ref_die_offset and
dwarf2_get_attr_constant_value to be methods on struct attribute.
gdb/ChangeLog
2020-03-26 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (handle_data_member_location, dwarf2_add_field)
(mark_common_block_symbol_computed, read_tag_string_type)
(attr_to_dynamic_prop, read_subrange_type): Update.
(dwarf2_get_ref_die_offset, dwarf2_get_attr_constant_value): Move
to be methods on struct attribute.
(skip_one_die, process_imported_unit_die, read_namespace_alias)
(read_call_site_scope, partial_die_info::read)
(partial_die_info::read, lookup_die_type, follow_die_ref):
Update.
* dwarf2/attribute.c (attribute::get_ref_die_offset): New method,
from dwarf2_get_ref_die_offset.
(attribute::constant_value): New method, from
dwarf2_get_attr_constant_value.
* dwarf2/attribute.h (struct attribute) <get_ref_die_offset>:
Declare method.
<constant_value>: New method.
2020-03-26 16:28:08 +01:00
|
|
|
{
|
|
|
|
complaint (_("unsupported die ref attribute form: '%s'"),
|
|
|
|
dwarf_form_name (form));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* See attribute.h. */
|
|
|
|
|
|
|
|
LONGEST
|
|
|
|
attribute::constant_value (int default_value) const
|
|
|
|
{
|
|
|
|
if (form == DW_FORM_sdata || form == DW_FORM_implicit_const)
|
|
|
|
return DW_SND (this);
|
|
|
|
else if (form == DW_FORM_udata
|
|
|
|
|| form == DW_FORM_data1
|
|
|
|
|| form == DW_FORM_data2
|
|
|
|
|| form == DW_FORM_data4
|
|
|
|
|| form == DW_FORM_data8)
|
|
|
|
return DW_UNSND (this);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* For DW_FORM_data16 see attribute::form_is_constant. */
|
|
|
|
complaint (_("Attribute value is not a constant (%s)"),
|
|
|
|
dwarf_form_name (form));
|
|
|
|
return default_value;
|
|
|
|
}
|
|
|
|
}
|