|
Packit Service |
97d2fb |
/* Return DIE at given offset.
|
|
Packit Service |
97d2fb |
Copyright (C) 2002-2010, 2017 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
This file is free software; you can redistribute it and/or modify
|
|
Packit Service |
97d2fb |
it under the terms of either
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 3 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
* the GNU General Public License as published by the Free
|
|
Packit Service |
97d2fb |
Software Foundation; either version 2 of the License, or (at
|
|
Packit Service |
97d2fb |
your option) any later version
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
or both in parallel, as here.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit Service |
97d2fb |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
97d2fb |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
97d2fb |
General Public License for more details.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
You should have received copies of the GNU General Public License and
|
|
Packit Service |
97d2fb |
the GNU Lesser General Public License along with this program. If
|
|
Packit Service |
97d2fb |
not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
97d2fb |
# include <config.h>
|
|
Packit Service |
97d2fb |
#endif
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include <string.h>
|
|
Packit Service |
97d2fb |
#include "libdwP.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwarf_Die *
|
|
Packit Service |
97d2fb |
internal_function
|
|
Packit Service |
97d2fb |
__libdw_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die *result,
|
|
Packit Service |
97d2fb |
bool debug_types)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
if (dbg == NULL)
|
|
Packit Service |
97d2fb |
return NULL;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Elf_Data *const data = dbg->sectiondata[debug_types ? IDX_debug_types
|
|
Packit Service |
97d2fb |
: IDX_debug_info];
|
|
Packit Service |
97d2fb |
if (data == NULL || offset >= data->d_size)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
__libdw_seterrno (DWARF_E_INVALID_DWARF);
|
|
Packit Service |
97d2fb |
return NULL;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Clear the entire DIE structure. This signals we have not yet
|
|
Packit Service |
97d2fb |
determined any of the information. */
|
|
Packit Service |
97d2fb |
memset (result, '\0', sizeof (Dwarf_Die));
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
result->addr = (char *) data->d_buf + offset;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Get the CU. */
|
|
Packit Service |
97d2fb |
result->cu = __libdw_findcu (dbg, offset, debug_types);
|
|
Packit Service |
97d2fb |
if (result->cu == NULL)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
/* This should never happen. The input file is malformed. */
|
|
Packit Service |
97d2fb |
__libdw_seterrno (DWARF_E_INVALID_DWARF);
|
|
Packit Service |
97d2fb |
result = NULL;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return result;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwarf_Die *
|
|
Packit Service |
97d2fb |
dwarf_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die *result)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
return __libdw_offdie (dbg, offset, result, false);
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
INTDEF(dwarf_offdie)
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwarf_Die *
|
|
Packit Service |
97d2fb |
dwarf_offdie_types (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die *result)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
return __libdw_offdie (dbg, offset, result, true);
|
|
Packit Service |
97d2fb |
}
|