dwarf_query.c revision 07dc1947c362e187fb955d283b692f8769dd5def
/*
Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved.
Portions Copyright (C) 2007-2010 David Anderson. All Rights Reserved.
under the terms of version 2.1 of the GNU Lesser General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
USA.
Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
Mountain View, CA 94043, or:
For further information regarding this notice, see:
*/
/* The address of the Free Software Foundation is
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
SGI has moved from the Crittenden Lane address.
*/
#include "config.h"
#include "dwarf_incl.h"
#include <stdio.h>
#include "dwarf_die_deliv.h"
/* This is normally reliable.
But not always.
If different compilation
units have different address sizes
this may not give the correct value in all contexts.
If the Elf offset size != address_size
(for example if address_size = 4 but recorded in elf64 object)
this may not give the correct value in all contexts.
*/
int
{
Dwarf_Half address_size = 0;
if (dbg == 0) {
return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
/* This will be correct in all contexts where the
CU context of a DIE is known.
*/
int
{
Dwarf_Half address_size = 0;
return DW_DLV_OK;
}
int
{
return DW_DLV_OK;
}
/*
This function returns the offset of
the die relative to the start of its
compilation-unit rather than .debug_info.
Returns DW_DLV_ERROR on error.
*/
int
{
*cu_off =
return DW_DLV_OK;
}
/*
This function returns the global offset
(meaning the section offset) and length of
the CU that this die is a part of.
Used for correctness checking by dwarfdump.
*/
int
Dwarf_Error * error)
{
return DW_DLV_OK;
}
int
{
return DW_DLV_OK;
}
int
{
Dwarf_Word attr_count = 0;
Dwarf_Word i = 0;
Dwarf_Half attr = 0;
Dwarf_Half attr_form = 0;
Dwarf_Byte_Ptr abbrev_ptr = 0;
Dwarf_Attribute new_attr = 0;
Dwarf_Attribute *attr_ptr = 0;
Dwarf_Debug dbg = 0;
Dwarf_Byte_Ptr info_ptr = 0;
ab_code);
if (abbrev_list == NULL) {
return (DW_DLV_ERROR);
}
do {
if (attr != 0) {
new_attr =
return (DW_DLV_ERROR);
}
if (attr_form == DW_FORM_indirect) {
/* DECODE_LEB128_UWORD does info_ptr update */
}
{
}
else {
}
attr_count++;
}
if (attr_count == 0) {
*attrcnt = 0;
return (DW_DLV_NO_ENTRY);
}
attr_ptr = (Dwarf_Attribute *)
return (DW_DLV_ERROR);
}
for (i = 0; i < attr_count; i++) {
}
*attrcnt = attr_count;
return (DW_DLV_OK);
}
/*
This function takes a die, and an attr, and returns
a pointer to the start of the value of that attr in
the given die in the .debug_info section. The form
is returned in *attr_form.
Returns NULL on error, or if attr is not found.
However, *attr_form is 0 on error, and positive
otherwise.
*/
static Dwarf_Byte_Ptr
{
Dwarf_Byte_Ptr abbrev_ptr = 0;
Dwarf_Half curr_attr = 0;
Dwarf_Half curr_attr_form = 0;
Dwarf_Byte_Ptr info_ptr = 0;
if (abbrev_list == NULL) {
*attr_form = 0;
return (NULL);
}
do {
if (curr_attr_form == DW_FORM_indirect) {
/* DECODE_LEB128_UWORD updates info_ptr */
}
return (info_ptr);
}
} while (curr_attr != 0 || curr_attr_form != 0);
*attr_form = 1;
return (NULL);
}
int
{
Dwarf_Half attr_form = 0;
Dwarf_Debug dbg = 0;
Dwarf_Byte_Ptr info_ptr = 0;
int res = DW_DLV_ERROR;
if (attr_form == 0) {
return (DW_DLV_ERROR);
}
return DW_DLV_NO_ENTRY;
}
if (attr_form == DW_FORM_string) {
return DW_DLV_OK;
}
if (attr_form != DW_FORM_strp) {
return (DW_DLV_ERROR);
}
return (DW_DLV_ERROR);
}
return res;
}
return DW_DLV_OK;
}
int
{
Dwarf_Half attr_form = 0;
if (attr_form == 0) {
return (DW_DLV_ERROR);
}
*return_bool = false;
return DW_DLV_OK;
}
*return_bool = (true);
return DW_DLV_OK;
}
int
{
Dwarf_Half attr_form = 0;
Dwarf_Attribute attrib = 0;
Dwarf_Byte_Ptr info_ptr = 0;
Dwarf_Debug dbg = 0;
if (attr_form == 0) {
return (DW_DLV_ERROR);
}
return DW_DLV_NO_ENTRY;
}
return (DW_DLV_ERROR);
}
return DW_DLV_OK;
}
int
{
Dwarf_Addr ret_addr = 0;
Dwarf_Byte_Ptr info_ptr = 0;
Dwarf_Half attr_form = 0;
Dwarf_Debug dbg = 0;
Dwarf_Half address_size = 0;
return (DW_DLV_ERROR);
}
return (DW_DLV_NO_ENTRY);
}
*return_addr = ret_addr;
return (DW_DLV_OK);
}
int
{
Dwarf_Addr ret_addr = 0;
Dwarf_Byte_Ptr info_ptr = 0;
Dwarf_Half attr_form = 0;
Dwarf_Debug dbg = 0;
Dwarf_Half address_size = 0;
return (DW_DLV_ERROR);
}
return (DW_DLV_NO_ENTRY);
}
*return_addr = ret_addr;
return (DW_DLV_OK);
}
/*
Takes a die, an attribute attr, and checks if attr
occurs in die. Attr is required to be an attribute
whose form is in the "constant" class. If attr occurs
in die, the value is returned.
Returns DW_DLV_OK, DW_DLV_ERROR, or DW_DLV_NO_ENTRY as
appropriate. Sets the value thru the pointer return_val.
This function is meant to do all the
processing for dwarf_bytesize, dwarf_bitsize, dwarf_bitoffset,
and dwarf_srclang.
*/
static int
Dwarf_Error * error)
{
switch (attr_form) {
case DW_FORM_data1:
return (DW_DLV_OK);
case DW_FORM_data2:
info_ptr, sizeof(Dwarf_Shalf));
*return_val = ret_value;
return (DW_DLV_OK);
case DW_FORM_data4:
info_ptr, sizeof(Dwarf_sfixed));
*return_val = ret_value;
return (DW_DLV_OK);
case DW_FORM_data8:
info_ptr, sizeof(Dwarf_Unsigned));
*return_val = ret_value;
return (DW_DLV_OK);
case DW_FORM_udata:
return (DW_DLV_OK);
default:
return (DW_DLV_ERROR);
}
}
if (attr_form == 0) {
return (DW_DLV_ERROR);
}
return DW_DLV_NO_ENTRY;
}
int
{
Dwarf_Unsigned luns = 0;
return res;
}
int
{
Dwarf_Unsigned luns = 0;
return res;
}
int
{
Dwarf_Unsigned luns = 0;
return res;
}
/* Refer section 3.1, page 21 in Dwarf Definition. */
int
{
Dwarf_Unsigned luns = 0;
return res;
}
/* Refer section 5.4, page 37 in Dwarf Definition. */
int
{
Dwarf_Unsigned luns = 0;
return res;
}
/*
Return DW_DLV_OK if ok
DW_DLV_ERROR if failure.
If the die and the attr are not related the result is
meaningless.
*/
int
Dwarf_Error * error)
{
return DW_DLV_OK;
}
int
{
return die->di_abbrev_code;
}
/* Helper function for finding form class. */
static enum Dwarf_Form_Class
{
switch(attrnum) {
case DW_AT_stmt_list:
return DW_FORM_CLASS_LINEPTR;
case DW_AT_macro_info:
return DW_FORM_CLASS_MACPTR;
case DW_AT_ranges:
return DW_FORM_CLASS_RANGELISTPTR;
case DW_AT_location:
case DW_AT_string_length:
case DW_AT_return_addr:
case DW_AT_frame_base:
case DW_AT_segment:
case DW_AT_static_link:
case DW_AT_use_location:
return DW_FORM_CLASS_LOCLISTPTR;
case DW_AT_sibling:
case DW_AT_byte_size :
case DW_AT_bit_offset :
case DW_AT_bit_size :
case DW_AT_discr :
case DW_AT_import :
case DW_AT_common_reference:
case DW_AT_containing_type:
case DW_AT_default_value:
case DW_AT_lower_bound:
case DW_AT_bit_stride:
case DW_AT_upper_bound:
case DW_AT_abstract_origin:
case DW_AT_base_types:
case DW_AT_count:
case DW_AT_friend:
case DW_AT_namelist_item:
case DW_AT_priority:
case DW_AT_specification:
case DW_AT_type:
case DW_AT_allocated:
case DW_AT_associated:
case DW_AT_byte_stride:
case DW_AT_extension:
case DW_AT_trampoline:
case DW_AT_small:
case DW_AT_object_pointer:
case DW_AT_signature:
return DW_FORM_CLASS_REFERENCE;
case DW_AT_MIPS_fde: /* SGI/IRIX extension */
return DW_FORM_CLASS_FRAMEPTR;
}
return DW_FORM_CLASS_UNKNOWN;
}
/* It takes 4 pieces of data (including the FORM)
to accurately determine the form 'class' as documented
in the DWARF spec. This is per DWARF4, but will work
for DWARF2 or 3 as well. */
{
switch(form) {
case DW_FORM_addr: return DW_FORM_CLASS_ADDRESS;
case DW_FORM_data2: return DW_FORM_CLASS_CONSTANT;
case DW_FORM_data4:
if(class != DW_FORM_CLASS_UNKNOWN) {
return class;
}
}
return DW_FORM_CLASS_CONSTANT;
case DW_FORM_data8:
if(class != DW_FORM_CLASS_UNKNOWN) {
return class;
}
}
return DW_FORM_CLASS_CONSTANT;
case DW_FORM_sec_offset:
{
if(class != DW_FORM_CLASS_UNKNOWN) {
return class;
}
}
/* We do not know what this is. */
break;
case DW_FORM_string: return DW_FORM_CLASS_STRING;
case DW_FORM_strp: return DW_FORM_CLASS_STRING;
case DW_FORM_block: return DW_FORM_CLASS_BLOCK;
case DW_FORM_block1: return DW_FORM_CLASS_BLOCK;
case DW_FORM_block2: return DW_FORM_CLASS_BLOCK;
case DW_FORM_block4: return DW_FORM_CLASS_BLOCK;
case DW_FORM_data1: return DW_FORM_CLASS_CONSTANT;
case DW_FORM_sdata: return DW_FORM_CLASS_CONSTANT;
case DW_FORM_udata: return DW_FORM_CLASS_CONSTANT;
case DW_FORM_ref_addr: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_ref1: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_ref2: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_ref4: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_ref8: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_ref_udata: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_ref_sig8: return DW_FORM_CLASS_REFERENCE;
case DW_FORM_exprloc: return DW_FORM_CLASS_EXPRLOC;
case DW_FORM_flag: return DW_FORM_CLASS_FLAG;
case DW_FORM_flag_present: return DW_FORM_CLASS_FLAG;
case DW_FORM_indirect:
default:
break;
};
return DW_FORM_CLASS_UNKNOWN;
}