|
Packit |
cdaae3 |
/*
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
Copyright (C) 2000,2002,2004,2005 Silicon Graphics, Inc. All Rights Reserved.
|
|
Packit |
cdaae3 |
Portions Copyright (C) 2009-2010 David Anderson. All Rights Reserved.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
This program is free software; you can redistribute it and/or modify it
|
|
Packit |
cdaae3 |
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
Packit |
cdaae3 |
as published by the Free Software Foundation.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
This program is distributed in the hope that it would be useful, but
|
|
Packit |
cdaae3 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
cdaae3 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
Further, this software is distributed without any warranty that it is
|
|
Packit |
cdaae3 |
free of the rightful claim of any third person regarding infringement
|
|
Packit |
cdaae3 |
or the like. Any license provided herein, whether implied or
|
|
Packit |
cdaae3 |
otherwise, applies only to this software file. Patent licenses, if
|
|
Packit |
cdaae3 |
any, provided herein do not apply to combinations of this program with
|
|
Packit |
cdaae3 |
other software, or any other product whatsoever.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
cdaae3 |
License along with this program; if not, write the Free Software
|
|
Packit |
cdaae3 |
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
Packit |
cdaae3 |
USA.
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
*/
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
/* Reads DWARF3 .debug_pubtypes section. */
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
#include "config.h"
|
|
Packit |
cdaae3 |
#include "dwarf_incl.h"
|
|
Packit |
cdaae3 |
#include <stdio.h>
|
|
Packit |
cdaae3 |
#include "dwarf_types.h"
|
|
Packit |
cdaae3 |
#include "dwarf_global.h"
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_get_pubtypes(Dwarf_Debug dbg,
|
|
Packit |
cdaae3 |
Dwarf_Type ** types,
|
|
Packit |
cdaae3 |
Dwarf_Signed * ret_type_count, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
int res = _dwarf_load_section(dbg, &dbg->de_debug_pubtypes,error);
|
|
Packit |
cdaae3 |
if (res != DW_DLV_OK) {
|
|
Packit |
cdaae3 |
return res;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
if (!dbg->de_debug_pubtypes.dss_size) {
|
|
Packit |
cdaae3 |
return (DW_DLV_NO_ENTRY);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return _dwarf_internal_get_pubnames_like_data(dbg,
|
|
Packit |
cdaae3 |
dbg->de_debug_pubtypes.dss_data,
|
|
Packit |
cdaae3 |
dbg->de_debug_pubtypes.dss_size,
|
|
Packit |
cdaae3 |
(Dwarf_Global **) types, /* Type punning for sections
|
|
Packit |
cdaae3 |
with identical format. */
|
|
Packit |
cdaae3 |
ret_type_count, error,
|
|
Packit |
cdaae3 |
DW_DLA_PUBTYPES_CONTEXT,
|
|
Packit |
cdaae3 |
DW_DLA_GLOBAL, /* We don't have DW_DLA_PUBTYPES,
|
|
Packit |
cdaae3 |
so use DW_DLA_GLOBAL. */
|
|
Packit |
cdaae3 |
DW_DLE_DEBUG_PUBTYPES_LENGTH_BAD,
|
|
Packit |
cdaae3 |
DW_DLE_DEBUG_PUBTYPES_VERSION_ERROR);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
/* Deallocating fully requires deallocating the list
|
|
Packit |
cdaae3 |
and all entries. But some internal data is
|
|
Packit |
cdaae3 |
not exposed, so we need a function with internal knowledge.
|
|
Packit |
cdaae3 |
*/
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
void
|
|
Packit |
cdaae3 |
dwarf_pubtypes_dealloc(Dwarf_Debug dbg, Dwarf_Type * dwgl,
|
|
Packit |
cdaae3 |
Dwarf_Signed count)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
_dwarf_internal_globals_dealloc(dbg,
|
|
Packit |
cdaae3 |
(Dwarf_Global *) dwgl,
|
|
Packit |
cdaae3 |
count,
|
|
Packit |
cdaae3 |
DW_DLA_PUBTYPES_CONTEXT,
|
|
Packit |
cdaae3 |
DW_DLA_GLOBAL, /* We don't have DW_DLA_PUBTYPES,
|
|
Packit |
cdaae3 |
so use DW_DLA_GLOBAL. */
|
|
Packit |
cdaae3 |
DW_DLA_LIST);
|
|
Packit |
cdaae3 |
return;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_pubtypename(Dwarf_Type type_in, char **ret_name,
|
|
Packit |
cdaae3 |
Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global type = (Dwarf_Global) type_in;
|
|
Packit |
cdaae3 |
if (type == NULL) {
|
|
Packit |
cdaae3 |
_dwarf_error(NULL, error, DW_DLE_TYPE_NULL);
|
|
Packit |
cdaae3 |
return (DW_DLV_ERROR);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
*ret_name = (char *) (type->gl_name);
|
|
Packit |
cdaae3 |
return DW_DLV_OK;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_pubtype_type_die_offset(Dwarf_Type type_in,
|
|
Packit |
cdaae3 |
Dwarf_Off * ret_offset,
|
|
Packit |
cdaae3 |
Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global type = (Dwarf_Global) type_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return dwarf_global_die_offset(type, ret_offset, error);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_pubtype_cu_offset(Dwarf_Type type_in,
|
|
Packit |
cdaae3 |
Dwarf_Off * ret_offset, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global type = (Dwarf_Global) type_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return dwarf_global_cu_offset(type, ret_offset, error);
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_pubtype_name_offsets(Dwarf_Type type_in,
|
|
Packit |
cdaae3 |
char **returned_name,
|
|
Packit |
cdaae3 |
Dwarf_Off * die_offset,
|
|
Packit |
cdaae3 |
Dwarf_Off * cu_die_offset,
|
|
Packit |
cdaae3 |
Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global type = (Dwarf_Global) type_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return dwarf_global_name_offsets(type,
|
|
Packit |
cdaae3 |
returned_name,
|
|
Packit |
cdaae3 |
die_offset, cu_die_offset, error);
|
|
Packit |
cdaae3 |
}
|