|
Packit |
cdaae3 |
/*
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
Copyright (C) 2000,2002,2004,2005 Silicon Graphics, Inc. All Rights Reserved.
|
|
Packit |
cdaae3 |
Portions Copyright (C) 2009-2011 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 |
#include "config.h"
|
|
Packit |
cdaae3 |
#include "dwarf_incl.h"
|
|
Packit |
cdaae3 |
#include <stdio.h>
|
|
Packit |
cdaae3 |
#include "dwarf_vars.h"
|
|
Packit |
cdaae3 |
#include "dwarf_global.h"
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_get_vars(Dwarf_Debug dbg,
|
|
Packit |
cdaae3 |
Dwarf_Var ** vars,
|
|
Packit |
cdaae3 |
Dwarf_Signed * ret_var_count, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
int res = _dwarf_load_section(dbg, &dbg->de_debug_varnames,error);
|
|
Packit |
cdaae3 |
if (res != DW_DLV_OK) {
|
|
Packit |
cdaae3 |
return res;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
if (!dbg->de_debug_abbrev.dss_size) {
|
|
Packit |
cdaae3 |
return (DW_DLV_NO_ENTRY);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return _dwarf_internal_get_pubnames_like_data(dbg,
|
|
Packit |
cdaae3 |
dbg->de_debug_varnames.dss_data,
|
|
Packit |
cdaae3 |
dbg->de_debug_varnames.dss_size,
|
|
Packit |
cdaae3 |
(Dwarf_Global **) vars, /* Type punning for sections
|
|
Packit |
cdaae3 |
with identical format. */
|
|
Packit |
cdaae3 |
ret_var_count,
|
|
Packit |
cdaae3 |
error,
|
|
Packit |
cdaae3 |
DW_DLA_VAR_CONTEXT,
|
|
Packit |
cdaae3 |
DW_DLA_VAR,
|
|
Packit |
cdaae3 |
DW_DLE_DEBUG_VARNAMES_LENGTH_BAD,
|
|
Packit |
cdaae3 |
DW_DLE_DEBUG_VARNAMES_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_vars_dealloc(Dwarf_Debug dbg, Dwarf_Var * dwgl,
|
|
Packit |
cdaae3 |
Dwarf_Signed count)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
_dwarf_internal_globals_dealloc(dbg, (Dwarf_Global *) dwgl,
|
|
Packit |
cdaae3 |
count,
|
|
Packit |
cdaae3 |
DW_DLA_VAR_CONTEXT,
|
|
Packit |
cdaae3 |
DW_DLA_VAR, DW_DLA_LIST);
|
|
Packit |
cdaae3 |
return;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_varname(Dwarf_Var var_in, char **ret_varname, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global var = (Dwarf_Global) var_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
if (var == NULL) {
|
|
Packit |
cdaae3 |
_dwarf_error(NULL, error, DW_DLE_VAR_NULL);
|
|
Packit |
cdaae3 |
return (DW_DLV_ERROR);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
*ret_varname = (char *) (var->gl_name);
|
|
Packit |
cdaae3 |
return DW_DLV_OK;
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_var_die_offset(Dwarf_Var var_in,
|
|
Packit |
cdaae3 |
Dwarf_Off * returned_offset, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global var = (Dwarf_Global) var_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return dwarf_global_die_offset(var, returned_offset, error);
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_var_cu_offset(Dwarf_Var var_in,
|
|
Packit |
cdaae3 |
Dwarf_Off * returned_offset, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global var = (Dwarf_Global) var_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return dwarf_global_cu_offset(var, returned_offset, error);
|
|
Packit |
cdaae3 |
}
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
int
|
|
Packit |
cdaae3 |
dwarf_var_name_offsets(Dwarf_Var var_in,
|
|
Packit |
cdaae3 |
char **returned_name,
|
|
Packit |
cdaae3 |
Dwarf_Off * die_offset,
|
|
Packit |
cdaae3 |
Dwarf_Off * cu_offset, Dwarf_Error * error)
|
|
Packit |
cdaae3 |
{
|
|
Packit |
cdaae3 |
Dwarf_Global var = (Dwarf_Global) var_in;
|
|
Packit |
cdaae3 |
|
|
Packit |
cdaae3 |
return
|
|
Packit |
cdaae3 |
dwarf_global_name_offsets(var,
|
|
Packit |
cdaae3 |
returned_name, die_offset, cu_offset,
|
|
Packit |
cdaae3 |
error);
|
|
Packit |
cdaae3 |
}
|