1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Portions Copyright (C) 2007-2010 David Anderson. All Rights Reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This program is free software; you can redistribute it and/or modify it
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo under the terms of version 2.1 of the GNU Lesser General Public License
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo as published by the Free Software Foundation.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This program is distributed in the hope that it would be useful, but
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo WITHOUT ANY WARRANTY; without even the implied warranty of
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Further, this software is distributed without any warranty that it is
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo free of the rightful claim of any third person regarding infringement
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo or the like. Any license provided herein, whether implied or
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo otherwise, applies only to this software file. Patent licenses, if
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo any, provided herein do not apply to combinations of this program with
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo other software, or any other product whatsoever.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo You should have received a copy of the GNU Lesser General Public
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo License along with this program; if not, write the Free Software
3c96341aef2b4da56c902941f089284b52bd573fnarayan Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Mountain View, CA 94043, or:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo For further information regarding this notice, see:
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan/* The address of the Free Software Foundation is
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Boston, MA 02110-1301, USA.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo SGI has moved from the Crittenden Lane address.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* This is normally reliable.
3c96341aef2b4da56c902941f089284b52bd573fnarayanBut not always.
3c96341aef2b4da56c902941f089284b52bd573fnarayanIf different compilation
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartreunits have different address sizes
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppothis may not give the correct value in all contexts.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoIf the Elf offset size != address_size
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan(for example if address_size = 4 but recorded in elf64 object)
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayanthis may not give the correct value in all contexts.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo if (dbg == 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* This will be correct in all contexts where the
445b4c2ed2d52ef648ae6b36e4f5e14ff3d234afsb CU context of a DIE is known.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This function returns the offset of
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo the die relative to the start of its
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo compilation-unit rather than .debug_info.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Returns DW_DLV_ERROR on error.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo (die->di_debug_info_ptr - cu_context->cc_dbg->de_debug_info.dss_data -
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre This function returns the global offset
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre (meaning the section offset) and length of
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre the CU that this die is a part of.
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre Used for correctness checking by dwarfdump.
445b4c2ed2d52ef648ae6b36e4f5e14ff3d234afsb *cu_length = cu_context->cc_length + cu_context->cc_length_size
445b4c2ed2d52ef648ae6b36e4f5e14ff3d234afsbdwarf_tag(Dwarf_Die die, Dwarf_Half * tag, Dwarf_Error * error)
3af08d828975d7e2581b6829e0eecff14d87a483lm abbrev_list = _dwarf_get_abbrev_for_code(die->di_cu_context,
3af08d828975d7e2581b6829e0eecff14d87a483lm if (attr != 0) {
3af08d828975d7e2581b6829e0eecff14d87a483lm /* DECODE_LEB128_UWORD does info_ptr update */
3af08d828975d7e2581b6829e0eecff14d87a483lm if (attr_count == 0) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo for (i = 0; i < attr_count; i++) {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo This function takes a die, and an attr, and returns
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo a pointer to the start of the value of that attr in
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo the given die in the .debug_info section. The form
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo is returned in *attr_form.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Returns NULL on error, or if attr is not found.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo However, *attr_form is 0 on error, and positive
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan abbrev_list = _dwarf_get_abbrev_for_code(die->di_cu_context,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* DECODE_LEB128_UWORD updates info_ptr */
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan info_ptr += _dwarf_get_size_of_val(die->di_cu_context->cc_dbg,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppodwarf_diename(Dwarf_Die die, char **ret_name, Dwarf_Error * error)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo info_ptr = _dwarf_get_value_ptr(die, DW_AT_name, &attr_form);
3c96341aef2b4da56c902941f089284b52bd573fnarayan res = _dwarf_load_section(dbg, &dbg->de_debug_str,error);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *ret_name = (char *) (dbg->de_debug_str.dss_data + string_offset);
3c96341aef2b4da56c902941f089284b52bd573fnarayan if (_dwarf_get_value_ptr(die, attr, &attr_form) == NULL) {
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre info_ptr = _dwarf_get_value_ptr(die, attr, &attr_form);
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre attrib = (Dwarf_Attribute) _dwarf_get_alloc(dbg, DW_DLA_ATTR, 1);
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre address_size = die->di_cu_context->cc_address_size;
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre info_ptr = _dwarf_get_value_ptr(die, DW_AT_low_pc, &attr_form);
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre address_size = die->di_cu_context->cc_address_size;
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre info_ptr = _dwarf_get_value_ptr(die, DW_AT_high_pc, &attr_form);
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre Takes a die, an attribute attr, and checks if attr
690555a1dfb3e9c3b00be26ece1988ed10a6fbe5achartre occurs in die. Attr is required to be an attribute
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo whose form is in the "constant" class. If attr occurs
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan in die, the value is returned.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo Returns DW_DLV_OK, DW_DLV_ERROR, or DW_DLV_NO_ENTRY as
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan appropriate. Sets the value thru the pointer return_val.
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan This function is meant to do all the
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan processing for dwarf_bytesize, dwarf_bitsize, dwarf_bitoffset,
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan and dwarf_srclang.
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan info_ptr = _dwarf_get_value_ptr(die, attr, &attr_form);
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan *return_val = (_dwarf_decode_u_leb128(info_ptr, NULL));
3c96341aef2b4da56c902941f089284b52bd573fnarayan int res = _dwarf_die_attr_unsigned_constant(die, DW_AT_byte_size,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int res = _dwarf_die_attr_unsigned_constant(die, DW_AT_bit_size,
3af08d828975d7e2581b6829e0eecff14d87a483lm/* Refer section 3.1, page 21 in Dwarf Definition. */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int res = _dwarf_die_attr_unsigned_constant(die, DW_AT_language,
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan/* Refer section 5.4, page 37 in Dwarf Definition. */
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan int res = _dwarf_die_attr_unsigned_constant(die, DW_AT_ordering,
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan Return DW_DLV_OK if ok
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan DW_DLV_ERROR if failure.
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan If the die and the attr are not related the result is
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan meaningless.
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayandwarf_attr_offset(Dwarf_Die die, Dwarf_Attribute attr,
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan Dwarf_Off * offset /* return offset thru this ptr */,
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan die->di_cu_context->cc_dbg->de_debug_info.dss_data);
3c96341aef2b4da56c902941f089284b52bd573fnarayan/* Helper function for finding form class. */
3af08d828975d7e2581b6829e0eecff14d87a483lm/* It takes 4 pieces of data (including the FORM)
3af08d828975d7e2581b6829e0eecff14d87a483lm to accurately determine the form 'class' as documented
3af08d828975d7e2581b6829e0eecff14d87a483lm in the DWARF spec. This is per DWARF4, but will work
3af08d828975d7e2581b6829e0eecff14d87a483lm for DWARF2 or 3 as well. */
3af08d828975d7e2581b6829e0eecff14d87a483lm enum Dwarf_Form_Class class = dw_get_special_offset(attrnum);
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan enum Dwarf_Form_Class class = dw_get_special_offset(attrnum);
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan enum Dwarf_Form_Class class = dw_get_special_offset(attrnum);
3af08d828975d7e2581b6829e0eecff14d87a483lm /* We do not know what this is. */
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan case DW_FORM_ref_addr: return DW_FORM_CLASS_REFERENCE;
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan case DW_FORM_ref_udata: return DW_FORM_CLASS_REFERENCE;
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan case DW_FORM_ref_sig8: return DW_FORM_CLASS_REFERENCE;