mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
cd6c91b4f8
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
119 lines
4.0 KiB
C
119 lines
4.0 KiB
C
/* 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/>. */
|
|
|
|
#ifndef GDB_DWARF2_ATTRIBUTE_H
|
|
#define GDB_DWARF2_ATTRIBUTE_H
|
|
|
|
#include "dwarf2.h"
|
|
|
|
/* Blocks are a bunch of untyped bytes. */
|
|
struct dwarf_block
|
|
{
|
|
size_t size;
|
|
|
|
/* Valid only if SIZE is not zero. */
|
|
const gdb_byte *data;
|
|
};
|
|
|
|
/* Attributes have a name and a value. */
|
|
struct attribute
|
|
{
|
|
/* Read the given attribute value as an address, taking the
|
|
attribute's form into account. */
|
|
CORE_ADDR value_as_address () const;
|
|
|
|
/* Return non-zero if ATTR's value is a section offset --- classes
|
|
lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
|
|
You may use DW_UNSND (attr) to retrieve such offsets.
|
|
|
|
Section 7.5.4, "Attribute Encodings", explains that no attribute
|
|
may have a value that belongs to more than one of these classes; it
|
|
would be ambiguous if we did, because we use the same forms for all
|
|
of them. */
|
|
|
|
bool form_is_section_offset () const;
|
|
|
|
/* Return non-zero if ATTR's value falls in the 'constant' class, or
|
|
zero otherwise. When this function returns true, you can apply
|
|
dwarf2_get_attr_constant_value to it.
|
|
|
|
However, note that for some attributes you must check
|
|
attr_form_is_section_offset before using this test. DW_FORM_data4
|
|
and DW_FORM_data8 are members of both the constant class, and of
|
|
the classes that contain offsets into other debug sections
|
|
(lineptr, loclistptr, macptr or rangelistptr). The DWARF spec says
|
|
that, if an attribute's can be either a constant or one of the
|
|
section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
|
|
taken as section offsets, not constants.
|
|
|
|
DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
|
|
cannot handle that. */
|
|
|
|
bool form_is_constant () const;
|
|
|
|
/* DW_ADDR is always stored already as sect_offset; despite for the forms
|
|
besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
|
|
|
|
bool form_is_ref () const;
|
|
|
|
|
|
ENUM_BITFIELD(dwarf_attribute) name : 16;
|
|
ENUM_BITFIELD(dwarf_form) form : 15;
|
|
|
|
/* Has DW_STRING already been updated by dwarf2_canonicalize_name? This
|
|
field should be in u.str (existing only for DW_STRING) but it is kept
|
|
here for better struct attribute alignment. */
|
|
unsigned int string_is_canonical : 1;
|
|
|
|
union
|
|
{
|
|
const char *str;
|
|
struct dwarf_block *blk;
|
|
ULONGEST unsnd;
|
|
LONGEST snd;
|
|
CORE_ADDR addr;
|
|
ULONGEST signature;
|
|
}
|
|
u;
|
|
};
|
|
|
|
/* Get at parts of an attribute structure. */
|
|
|
|
#define DW_STRING(attr) ((attr)->u.str)
|
|
#define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical)
|
|
#define DW_UNSND(attr) ((attr)->u.unsnd)
|
|
#define DW_BLOCK(attr) ((attr)->u.blk)
|
|
#define DW_SND(attr) ((attr)->u.snd)
|
|
#define DW_ADDR(attr) ((attr)->u.addr)
|
|
#define DW_SIGNATURE(attr) ((attr)->u.signature)
|
|
|
|
/* Check if the attribute's form is a DW_FORM_block*
|
|
if so return true else false. */
|
|
|
|
extern int attr_form_is_block (const struct attribute *attr);
|
|
|
|
#endif /* GDB_DWARF2_ATTRIBUTE_H */
|