2003-12-20 12:43:08 +01:00
|
|
|
/* libunwind - a platform-independent unwind library
|
2005-05-20 11:48:08 +02:00
|
|
|
Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P.
|
2014-09-20 18:03:10 +02:00
|
|
|
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
This file is part of libunwind.
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
|
|
|
|
#ifndef dwarf_h
|
|
|
|
#define dwarf_h
|
|
|
|
|
2005-05-20 11:48:08 +02:00
|
|
|
#include <libunwind.h>
|
2003-12-20 12:43:08 +01:00
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
struct dwarf_cursor; /* forward-declaration */
|
2012-03-13 02:45:40 +01:00
|
|
|
struct elf_dyn_info;
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
#include "dwarf-config.h"
|
Add basic support for the QNX operating system
This change adds some special cases to allow libunwind to compile
for QNX.
* QNX's copy of <elf.h> and <link.h> reside in sys/ instead. To deal
with this, an AC_CHECK_HEADERS() was added to check for the files
in both locations.
* Similarly, QNX does not have <endian.h>. In cases where the file is
not found, logic was added to refer to QNX-specific macros to determine
endianness.
* The QCC compiler, which is a wrapper around GCC, cannot handle some
standard GCC options. Therefore, logic was added to check for QCC,
and when it is found, to suppress the use of -lgcc, and to express the
option -nostartfiles as -Wc,-nostartfiles instead, which is correctly
passed on to the underlying GCC.
* Finally, the support file os-qnx.c was added, patterned after the existing
os-*.c files. Only local image lookup is currently supported (see the
comments for more information), but this is sufficient for QNX, since
ptrace is not supported there anyway, and that is the only case where the
function is required to do remote image lookup.
Change-Id: Ie7934f94a7317bdde59335f2acd4c3a97c0384c1
2013-04-15 16:53:29 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-10-23 20:35:00 +02:00
|
|
|
#ifdef HAVE___THREAD
|
|
|
|
/* For now, turn off per-thread caching. It uses up too much TLS
|
|
|
|
memory per thread even when the thread never uses libunwind at
|
|
|
|
all. */
|
|
|
|
# undef HAVE___THREAD
|
|
|
|
#endif
|
|
|
|
|
2011-10-20 17:28:25 +02:00
|
|
|
#ifndef UNW_REMOTE_ONLY
|
Add basic support for the QNX operating system
This change adds some special cases to allow libunwind to compile
for QNX.
* QNX's copy of <elf.h> and <link.h> reside in sys/ instead. To deal
with this, an AC_CHECK_HEADERS() was added to check for the files
in both locations.
* Similarly, QNX does not have <endian.h>. In cases where the file is
not found, logic was added to refer to QNX-specific macros to determine
endianness.
* The QCC compiler, which is a wrapper around GCC, cannot handle some
standard GCC options. Therefore, logic was added to check for QCC,
and when it is found, to suppress the use of -lgcc, and to express the
option -nostartfiles as -Wc,-nostartfiles instead, which is correctly
passed on to the underlying GCC.
* Finally, the support file os-qnx.c was added, patterned after the existing
os-*.c files. Only local image lookup is currently supported (see the
comments for more information), but this is sufficient for QNX, since
ptrace is not supported there anyway, and that is the only case where the
function is required to do remote image lookup.
Change-Id: Ie7934f94a7317bdde59335f2acd4c3a97c0384c1
2013-04-15 16:53:29 +02:00
|
|
|
#if defined(HAVE_LINK_H)
|
|
|
|
#include <link.h>
|
|
|
|
#elif defined(HAVE_SYS_LINK_H)
|
|
|
|
#include <sys/link.h>
|
|
|
|
#else
|
|
|
|
#error Could not find <link.h>
|
|
|
|
#endif
|
2011-10-20 17:28:25 +02:00
|
|
|
#endif
|
Add basic support for the QNX operating system
This change adds some special cases to allow libunwind to compile
for QNX.
* QNX's copy of <elf.h> and <link.h> reside in sys/ instead. To deal
with this, an AC_CHECK_HEADERS() was added to check for the files
in both locations.
* Similarly, QNX does not have <endian.h>. In cases where the file is
not found, logic was added to refer to QNX-specific macros to determine
endianness.
* The QCC compiler, which is a wrapper around GCC, cannot handle some
standard GCC options. Therefore, logic was added to check for QCC,
and when it is found, to suppress the use of -lgcc, and to express the
option -nostartfiles as -Wc,-nostartfiles instead, which is correctly
passed on to the underlying GCC.
* Finally, the support file os-qnx.c was added, patterned after the existing
os-*.c files. Only local image lookup is currently supported (see the
comments for more information), but this is sufficient for QNX, since
ptrace is not supported there anyway, and that is the only case where the
function is required to do remote image lookup.
Change-Id: Ie7934f94a7317bdde59335f2acd4c3a97c0384c1
2013-04-15 16:53:29 +02:00
|
|
|
|
2011-09-09 11:16:09 +02:00
|
|
|
#include <pthread.h>
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
/* DWARF expression opcodes. */
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
DW_OP_addr = 0x03,
|
|
|
|
DW_OP_deref = 0x06,
|
|
|
|
DW_OP_const1u = 0x08,
|
|
|
|
DW_OP_const1s = 0x09,
|
|
|
|
DW_OP_const2u = 0x0a,
|
|
|
|
DW_OP_const2s = 0x0b,
|
|
|
|
DW_OP_const4u = 0x0c,
|
|
|
|
DW_OP_const4s = 0x0d,
|
|
|
|
DW_OP_const8u = 0x0e,
|
|
|
|
DW_OP_const8s = 0x0f,
|
|
|
|
DW_OP_constu = 0x10,
|
|
|
|
DW_OP_consts = 0x11,
|
|
|
|
DW_OP_dup = 0x12,
|
|
|
|
DW_OP_drop = 0x13,
|
|
|
|
DW_OP_over = 0x14,
|
|
|
|
DW_OP_pick = 0x15,
|
|
|
|
DW_OP_swap = 0x16,
|
|
|
|
DW_OP_rot = 0x17,
|
|
|
|
DW_OP_xderef = 0x18,
|
|
|
|
DW_OP_abs = 0x19,
|
|
|
|
DW_OP_and = 0x1a,
|
|
|
|
DW_OP_div = 0x1b,
|
|
|
|
DW_OP_minus = 0x1c,
|
|
|
|
DW_OP_mod = 0x1d,
|
|
|
|
DW_OP_mul = 0x1e,
|
|
|
|
DW_OP_neg = 0x1f,
|
|
|
|
DW_OP_not = 0x20,
|
|
|
|
DW_OP_or = 0x21,
|
|
|
|
DW_OP_plus = 0x22,
|
|
|
|
DW_OP_plus_uconst = 0x23,
|
|
|
|
DW_OP_shl = 0x24,
|
|
|
|
DW_OP_shr = 0x25,
|
|
|
|
DW_OP_shra = 0x26,
|
|
|
|
DW_OP_xor = 0x27,
|
|
|
|
DW_OP_skip = 0x2f,
|
|
|
|
DW_OP_bra = 0x28,
|
|
|
|
DW_OP_eq = 0x29,
|
|
|
|
DW_OP_ge = 0x2a,
|
|
|
|
DW_OP_gt = 0x2b,
|
|
|
|
DW_OP_le = 0x2c,
|
|
|
|
DW_OP_lt = 0x2d,
|
|
|
|
DW_OP_ne = 0x2e,
|
|
|
|
DW_OP_lit0 = 0x30,
|
2003-12-20 12:43:08 +01:00
|
|
|
DW_OP_lit1, DW_OP_lit2, DW_OP_lit3, DW_OP_lit4, DW_OP_lit5,
|
|
|
|
DW_OP_lit6, DW_OP_lit7, DW_OP_lit8, DW_OP_lit9, DW_OP_lit10,
|
|
|
|
DW_OP_lit11, DW_OP_lit12, DW_OP_lit13, DW_OP_lit14, DW_OP_lit15,
|
|
|
|
DW_OP_lit16, DW_OP_lit17, DW_OP_lit18, DW_OP_lit19, DW_OP_lit20,
|
|
|
|
DW_OP_lit21, DW_OP_lit22, DW_OP_lit23, DW_OP_lit24, DW_OP_lit25,
|
|
|
|
DW_OP_lit26, DW_OP_lit27, DW_OP_lit28, DW_OP_lit29, DW_OP_lit30,
|
|
|
|
DW_OP_lit31,
|
2014-09-20 18:03:10 +02:00
|
|
|
DW_OP_reg0 = 0x50,
|
2003-12-20 12:43:08 +01:00
|
|
|
DW_OP_reg1, DW_OP_reg2, DW_OP_reg3, DW_OP_reg4, DW_OP_reg5,
|
|
|
|
DW_OP_reg6, DW_OP_reg7, DW_OP_reg8, DW_OP_reg9, DW_OP_reg10,
|
|
|
|
DW_OP_reg11, DW_OP_reg12, DW_OP_reg13, DW_OP_reg14, DW_OP_reg15,
|
|
|
|
DW_OP_reg16, DW_OP_reg17, DW_OP_reg18, DW_OP_reg19, DW_OP_reg20,
|
|
|
|
DW_OP_reg21, DW_OP_reg22, DW_OP_reg23, DW_OP_reg24, DW_OP_reg25,
|
|
|
|
DW_OP_reg26, DW_OP_reg27, DW_OP_reg28, DW_OP_reg29, DW_OP_reg30,
|
|
|
|
DW_OP_reg31,
|
2014-09-20 18:03:10 +02:00
|
|
|
DW_OP_breg0 = 0x70,
|
2003-12-20 12:43:08 +01:00
|
|
|
DW_OP_breg1, DW_OP_breg2, DW_OP_breg3, DW_OP_breg4, DW_OP_breg5,
|
|
|
|
DW_OP_breg6, DW_OP_breg7, DW_OP_breg8, DW_OP_breg9, DW_OP_breg10,
|
|
|
|
DW_OP_breg11, DW_OP_breg12, DW_OP_breg13, DW_OP_breg14, DW_OP_breg15,
|
|
|
|
DW_OP_breg16, DW_OP_breg17, DW_OP_breg18, DW_OP_breg19, DW_OP_breg20,
|
|
|
|
DW_OP_breg21, DW_OP_breg22, DW_OP_breg23, DW_OP_breg24, DW_OP_breg25,
|
|
|
|
DW_OP_breg26, DW_OP_breg27, DW_OP_breg28, DW_OP_breg29, DW_OP_breg30,
|
|
|
|
DW_OP_breg31,
|
2014-09-20 18:03:10 +02:00
|
|
|
DW_OP_regx = 0x90,
|
|
|
|
DW_OP_fbreg = 0x91,
|
|
|
|
DW_OP_bregx = 0x92,
|
|
|
|
DW_OP_piece = 0x93,
|
|
|
|
DW_OP_deref_size = 0x94,
|
|
|
|
DW_OP_xderef_size = 0x95,
|
|
|
|
DW_OP_nop = 0x96,
|
|
|
|
DW_OP_push_object_address = 0x97,
|
|
|
|
DW_OP_call2 = 0x98,
|
|
|
|
DW_OP_call4 = 0x99,
|
|
|
|
DW_OP_call_ref = 0x9a,
|
|
|
|
DW_OP_lo_user = 0xe0,
|
|
|
|
DW_OP_hi_user = 0xff
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_expr_op_t;
|
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DWARF_CIE_VERSION 3 /* GCC emits version 1??? */
|
2003-12-20 12:43:08 +01:00
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DWARF_CFA_OPCODE_MASK 0xc0
|
|
|
|
#define DWARF_CFA_OPERAND_MASK 0x3f
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
DW_CFA_advance_loc = 0x40,
|
|
|
|
DW_CFA_offset = 0x80,
|
|
|
|
DW_CFA_restore = 0xc0,
|
|
|
|
DW_CFA_nop = 0x00,
|
|
|
|
DW_CFA_set_loc = 0x01,
|
|
|
|
DW_CFA_advance_loc1 = 0x02,
|
|
|
|
DW_CFA_advance_loc2 = 0x03,
|
|
|
|
DW_CFA_advance_loc4 = 0x04,
|
|
|
|
DW_CFA_offset_extended = 0x05,
|
|
|
|
DW_CFA_restore_extended = 0x06,
|
|
|
|
DW_CFA_undefined = 0x07,
|
|
|
|
DW_CFA_same_value = 0x08,
|
|
|
|
DW_CFA_register = 0x09,
|
|
|
|
DW_CFA_remember_state = 0x0a,
|
|
|
|
DW_CFA_restore_state = 0x0b,
|
|
|
|
DW_CFA_def_cfa = 0x0c,
|
|
|
|
DW_CFA_def_cfa_register = 0x0d,
|
|
|
|
DW_CFA_def_cfa_offset = 0x0e,
|
|
|
|
DW_CFA_def_cfa_expression = 0x0f,
|
|
|
|
DW_CFA_expression = 0x10,
|
|
|
|
DW_CFA_offset_extended_sf = 0x11,
|
|
|
|
DW_CFA_def_cfa_sf = 0x12,
|
|
|
|
DW_CFA_def_cfa_offset_sf = 0x13,
|
|
|
|
DW_CFA_val_expression = 0x16,
|
|
|
|
DW_CFA_lo_user = 0x1c,
|
|
|
|
DW_CFA_MIPS_advance_loc8 = 0x1d,
|
|
|
|
DW_CFA_GNU_window_save = 0x2d,
|
|
|
|
DW_CFA_GNU_args_size = 0x2e,
|
|
|
|
DW_CFA_GNU_negative_offset_extended = 0x2f,
|
|
|
|
DW_CFA_hi_user = 0x3c
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_cfa_t;
|
|
|
|
|
|
|
|
/* DWARF Pointer-Encoding (PEs).
|
|
|
|
|
|
|
|
Pointer-Encodings were invented for the GCC exception-handling
|
|
|
|
support for C++, but they represent a rather generic way of
|
|
|
|
describing the format in which an address/pointer is stored and
|
|
|
|
hence we include the definitions here, in the main dwarf.h file.
|
|
|
|
The Pointer-Encoding format is partially documented in Linux Base
|
|
|
|
Spec v1.3 (http://www.linuxbase.org/spec/). The rest is reverse
|
|
|
|
engineered from GCC.
|
|
|
|
|
|
|
|
*/
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DW_EH_PE_FORMAT_MASK 0x0f /* format of the encoded value */
|
|
|
|
#define DW_EH_PE_APPL_MASK 0x70 /* how the value is to be applied */
|
2003-12-20 12:43:08 +01:00
|
|
|
/* Flag bit. If set, the resulting pointer is the address of the word
|
|
|
|
that contains the final address. */
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DW_EH_PE_indirect 0x80
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
/* Pointer-encoding formats: */
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DW_EH_PE_omit 0xff
|
|
|
|
#define DW_EH_PE_ptr 0x00 /* pointer-sized unsigned value */
|
|
|
|
#define DW_EH_PE_uleb128 0x01 /* unsigned LE base-128 value */
|
|
|
|
#define DW_EH_PE_udata2 0x02 /* unsigned 16-bit value */
|
|
|
|
#define DW_EH_PE_udata4 0x03 /* unsigned 32-bit value */
|
|
|
|
#define DW_EH_PE_udata8 0x04 /* unsigned 64-bit value */
|
|
|
|
#define DW_EH_PE_sleb128 0x09 /* signed LE base-128 value */
|
|
|
|
#define DW_EH_PE_sdata2 0x0a /* signed 16-bit value */
|
|
|
|
#define DW_EH_PE_sdata4 0x0b /* signed 32-bit value */
|
|
|
|
#define DW_EH_PE_sdata8 0x0c /* signed 64-bit value */
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
/* Pointer-encoding application: */
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DW_EH_PE_absptr 0x00 /* absolute value */
|
|
|
|
#define DW_EH_PE_pcrel 0x10 /* rel. to addr. of encoded value */
|
|
|
|
#define DW_EH_PE_textrel 0x20 /* text-relative (GCC-specific???) */
|
|
|
|
#define DW_EH_PE_datarel 0x30 /* data-relative */
|
2003-12-20 12:43:08 +01:00
|
|
|
/* The following are not documented by LSB v1.3, yet they are used by
|
|
|
|
GCC, presumably they aren't documented by LSB since they aren't
|
|
|
|
used on Linux: */
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DW_EH_PE_funcrel 0x40 /* start-of-procedure-relative */
|
|
|
|
#define DW_EH_PE_aligned 0x50 /* aligned pointer */
|
2003-12-20 12:43:08 +01:00
|
|
|
|
2006-07-27 06:36:03 +02:00
|
|
|
extern struct mempool dwarf_reg_state_pool;
|
|
|
|
extern struct mempool dwarf_cie_info_pool;
|
|
|
|
|
2003-12-20 12:43:08 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
DWARF_WHERE_UNDEF, /* register isn't saved at all */
|
|
|
|
DWARF_WHERE_SAME, /* register has same value as in prev. frame */
|
|
|
|
DWARF_WHERE_CFAREL, /* register saved at CFA-relative address */
|
|
|
|
DWARF_WHERE_REG, /* register saved in another register */
|
|
|
|
DWARF_WHERE_EXPR, /* register saved */
|
|
|
|
DWARF_WHERE_VAL_EXPR, /* register has computed value */
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_where_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
dwarf_where_t where; /* how is the register saved? */
|
|
|
|
unw_word_t val; /* where it's saved */
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_save_loc_t;
|
|
|
|
|
|
|
|
/* For uniformity, we'd like to treat the CFA save-location like any
|
|
|
|
other register save-location, but this doesn't quite work, because
|
|
|
|
the CFA can be expressed as a (REGISTER,OFFSET) pair. To handle
|
|
|
|
this, we use two dwarf_save_loc structures to describe the CFA.
|
|
|
|
The first one (CFA_REG_COLUMN), tells us where the CFA is saved.
|
|
|
|
In the case of DWARF_WHERE_EXPR, the CFA is defined by a DWARF
|
|
|
|
location expression whose address is given by member "val". In the
|
|
|
|
case of DWARF_WHERE_REG, member "val" gives the number of the
|
|
|
|
base-register and the "val" member of DWARF_CFA_OFF_COLUMN gives
|
|
|
|
the offset value. */
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DWARF_CFA_REG_COLUMN DWARF_NUM_PRESERVED_REGS
|
|
|
|
#define DWARF_CFA_OFF_COLUMN (DWARF_NUM_PRESERVED_REGS + 1)
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
typedef struct dwarf_reg_state
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
struct dwarf_reg_state *next; /* for rs_stack */
|
2003-12-20 12:43:08 +01:00
|
|
|
dwarf_save_loc_t reg[DWARF_NUM_PRESERVED_REGS + 2];
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t ip; /* ip this rs is for */
|
2006-07-27 05:29:50 +02:00
|
|
|
unw_word_t ret_addr_column; /* indicates which column in the rule table represents return address */
|
2014-09-20 18:03:10 +02:00
|
|
|
unsigned short lru_chain; /* used for least-recently-used chain */
|
|
|
|
unsigned short coll_chain; /* used for hash collisions */
|
|
|
|
unsigned short hint; /* hint for next rs to try (or -1) */
|
2012-03-26 03:33:40 +02:00
|
|
|
unsigned short valid : 1; /* optional machine-dependent signal info */
|
|
|
|
unsigned short signal_frame : 1; /* optional machine-dependent signal info */
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_reg_state_t;
|
|
|
|
|
2005-05-03 11:13:17 +02:00
|
|
|
typedef struct dwarf_cie_info
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t cie_instr_start; /* start addr. of CIE "initial_instructions" */
|
|
|
|
unw_word_t cie_instr_end; /* end addr. of CIE "initial_instructions" */
|
|
|
|
unw_word_t fde_instr_start; /* start addr. of FDE "instructions" */
|
|
|
|
unw_word_t fde_instr_end; /* end addr. of FDE "instructions" */
|
|
|
|
unw_word_t code_align; /* code-alignment factor */
|
|
|
|
unw_word_t data_align; /* data-alignment factor */
|
|
|
|
unw_word_t ret_addr_column; /* column of return-address register */
|
|
|
|
unw_word_t handler; /* address of personality-routine */
|
2005-05-03 11:13:17 +02:00
|
|
|
uint16_t abi;
|
|
|
|
uint16_t tag;
|
|
|
|
uint8_t fde_encoding;
|
|
|
|
uint8_t lsda_encoding;
|
|
|
|
unsigned int sized_augmentation : 1;
|
|
|
|
unsigned int have_abi_marker : 1;
|
2010-04-20 23:13:09 +02:00
|
|
|
unsigned int signal_frame : 1;
|
2005-05-03 11:13:17 +02:00
|
|
|
}
|
|
|
|
dwarf_cie_info_t;
|
|
|
|
|
2003-12-20 12:43:08 +01:00
|
|
|
typedef struct dwarf_state_record
|
|
|
|
{
|
|
|
|
unsigned char fde_encoding;
|
|
|
|
unw_word_t args_size;
|
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
dwarf_reg_state_t rs_initial; /* reg-state after CIE instructions */
|
|
|
|
dwarf_reg_state_t rs_current; /* current reg-state */
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_state_record_t;
|
|
|
|
|
|
|
|
typedef struct dwarf_cursor
|
|
|
|
{
|
2014-09-20 18:03:10 +02:00
|
|
|
void *as_arg; /* argument to address-space callbacks */
|
|
|
|
unw_addr_space_t as; /* reference to per-address-space info */
|
2003-12-20 12:43:08 +01:00
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t cfa; /* canonical frame address; aka frame-/stack-pointer */
|
|
|
|
unw_word_t ip; /* instruction pointer */
|
|
|
|
unw_word_t args_size; /* size of arguments */
|
|
|
|
unw_word_t ret_addr_column; /* column for return-address */
|
2005-05-03 11:13:17 +02:00
|
|
|
unw_word_t eh_args[UNW_TDEP_NUM_EH_REGS];
|
|
|
|
unsigned int eh_valid_mask;
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
dwarf_loc_t loc[DWARF_NUM_PRESERVED_REGS];
|
|
|
|
|
2011-03-19 10:00:48 +01:00
|
|
|
unsigned int stash_frames :1; /* stash frames for fast lookup */
|
2010-04-25 04:16:09 +02:00
|
|
|
unsigned int use_prev_instr :1; /* use previous (= call) or current (= signal) instruction? */
|
2014-09-20 18:03:10 +02:00
|
|
|
unsigned int pi_valid :1; /* is proc_info valid? */
|
2003-12-20 12:43:08 +01:00
|
|
|
unsigned int pi_is_dynamic :1; /* proc_info found via dynamic proc info? */
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_proc_info_t pi; /* info about current procedure */
|
2006-07-27 05:18:49 +02:00
|
|
|
|
|
|
|
short hint; /* faster lookup of the rs cache */
|
|
|
|
short prev_rs;
|
2003-12-20 12:43:08 +01:00
|
|
|
}
|
|
|
|
dwarf_cursor_t;
|
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DWARF_LOG_UNW_CACHE_SIZE 7
|
|
|
|
#define DWARF_UNW_CACHE_SIZE (1 << DWARF_LOG_UNW_CACHE_SIZE)
|
2006-07-27 05:18:49 +02:00
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
#define DWARF_LOG_UNW_HASH_SIZE (DWARF_LOG_UNW_CACHE_SIZE + 1)
|
|
|
|
#define DWARF_UNW_HASH_SIZE (1 << DWARF_LOG_UNW_HASH_SIZE)
|
2006-07-27 05:18:49 +02:00
|
|
|
|
|
|
|
typedef unsigned char unw_hash_index_t;
|
|
|
|
|
|
|
|
struct dwarf_rs_cache
|
|
|
|
{
|
|
|
|
pthread_mutex_t lock;
|
2014-09-20 18:03:10 +02:00
|
|
|
unsigned short lru_head; /* index of lead-recently used rs */
|
|
|
|
unsigned short lru_tail; /* index of most-recently used rs */
|
2006-07-27 05:18:49 +02:00
|
|
|
|
|
|
|
/* hash table that maps instruction pointer to rs index: */
|
|
|
|
unsigned short hash[DWARF_UNW_HASH_SIZE];
|
|
|
|
|
2014-09-20 18:03:10 +02:00
|
|
|
uint32_t generation; /* generation number */
|
2006-07-27 05:18:49 +02:00
|
|
|
|
|
|
|
/* rs cache: */
|
|
|
|
dwarf_reg_state_t buckets[DWARF_UNW_CACHE_SIZE];
|
|
|
|
};
|
|
|
|
|
2008-02-05 01:16:37 +01:00
|
|
|
/* A list of descriptors for loaded .debug_frame sections. */
|
|
|
|
|
|
|
|
struct unw_debug_frame_list
|
|
|
|
{
|
|
|
|
/* The start (inclusive) and end (exclusive) of the described region. */
|
|
|
|
unw_word_t start;
|
|
|
|
unw_word_t end;
|
|
|
|
/* The debug frame itself. */
|
|
|
|
char *debug_frame;
|
|
|
|
size_t debug_frame_size;
|
|
|
|
/* Index (for binary search). */
|
|
|
|
struct table_entry *index;
|
|
|
|
size_t index_size;
|
|
|
|
/* Pointer to next descriptor. */
|
|
|
|
struct unw_debug_frame_list *next;
|
|
|
|
};
|
|
|
|
|
2011-08-12 11:23:18 +02:00
|
|
|
struct dwarf_callback_data
|
|
|
|
{
|
|
|
|
/* in: */
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t ip; /* instruction-pointer we're looking for */
|
|
|
|
unw_proc_info_t *pi; /* proc-info pointer */
|
2011-08-12 11:23:18 +02:00
|
|
|
int need_unwind_info;
|
|
|
|
/* out: */
|
2014-09-20 18:03:10 +02:00
|
|
|
int single_fde; /* did we find a single FDE? (vs. a table) */
|
|
|
|
unw_dyn_info_t di; /* table info (if single_fde is false) */
|
|
|
|
unw_dyn_info_t di_debug; /* additional table info for .debug_frame */
|
2011-08-12 11:23:18 +02:00
|
|
|
};
|
|
|
|
|
2003-12-20 12:43:08 +01:00
|
|
|
/* Convenience macros: */
|
2014-09-20 18:03:10 +02:00
|
|
|
#define dwarf_init UNW_ARCH_OBJ (dwarf_init)
|
|
|
|
#define dwarf_callback UNW_OBJ (dwarf_callback)
|
|
|
|
#define dwarf_find_proc_info UNW_OBJ (dwarf_find_proc_info)
|
|
|
|
#define dwarf_find_debug_frame UNW_OBJ (dwarf_find_debug_frame)
|
|
|
|
#define dwarf_search_unwind_table UNW_OBJ (dwarf_search_unwind_table)
|
|
|
|
#define dwarf_find_unwind_table UNW_OBJ (dwarf_find_unwind_table)
|
|
|
|
#define dwarf_put_unwind_info UNW_OBJ (dwarf_put_unwind_info)
|
|
|
|
#define dwarf_put_unwind_info UNW_OBJ (dwarf_put_unwind_info)
|
|
|
|
#define dwarf_eval_expr UNW_OBJ (dwarf_eval_expr)
|
2005-05-03 11:13:17 +02:00
|
|
|
#define dwarf_extract_proc_info_from_fde \
|
2014-09-20 18:03:10 +02:00
|
|
|
UNW_OBJ (dwarf_extract_proc_info_from_fde)
|
|
|
|
#define dwarf_find_save_locs UNW_OBJ (dwarf_find_save_locs)
|
|
|
|
#define dwarf_create_state_record UNW_OBJ (dwarf_create_state_record)
|
|
|
|
#define dwarf_make_proc_info UNW_OBJ (dwarf_make_proc_info)
|
|
|
|
#define dwarf_read_encoded_pointer UNW_OBJ (dwarf_read_encoded_pointer)
|
|
|
|
#define dwarf_step UNW_OBJ (dwarf_step)
|
2003-12-20 12:43:08 +01:00
|
|
|
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_init (void);
|
2011-10-20 17:28:25 +02:00
|
|
|
#ifndef UNW_REMOTE_ONLY
|
2011-08-12 11:23:18 +02:00
|
|
|
extern int dwarf_callback (struct dl_phdr_info *info, size_t size, void *ptr);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_find_proc_info (unw_addr_space_t as, unw_word_t ip,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_proc_info_t *pi,
|
|
|
|
int need_unwind_info, void *arg);
|
2011-10-20 17:28:25 +02:00
|
|
|
#endif /* !UNW_REMOTE_ONLY */
|
2010-05-27 04:21:30 +02:00
|
|
|
extern int dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t ip, unw_word_t segbase,
|
|
|
|
const char* obj_name, unw_word_t start,
|
|
|
|
unw_word_t end);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_search_unwind_table (unw_addr_space_t as,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t ip,
|
|
|
|
unw_dyn_info_t *di,
|
|
|
|
unw_proc_info_t *pi,
|
|
|
|
int need_unwind_info, void *arg);
|
2012-03-13 02:45:40 +01:00
|
|
|
extern int dwarf_find_unwind_table (struct elf_dyn_info *edi, unw_addr_space_t as,
|
2014-09-20 18:03:10 +02:00
|
|
|
char *path, unw_word_t segbase, unw_word_t mapoff,
|
|
|
|
unw_word_t ip);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern void dwarf_put_unwind_info (unw_addr_space_t as,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_proc_info_t *pi, void *arg);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_eval_expr (struct dwarf_cursor *c, unw_word_t *addr,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_word_t len, unw_word_t *valp,
|
|
|
|
int *is_register);
|
2005-05-03 11:13:17 +02:00
|
|
|
extern int dwarf_extract_proc_info_from_fde (unw_addr_space_t as,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_accessors_t *a,
|
|
|
|
unw_word_t *fde_addr,
|
|
|
|
unw_proc_info_t *pi,
|
|
|
|
int need_unwind_info,
|
|
|
|
unw_word_t base,
|
|
|
|
void *arg);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_find_save_locs (struct dwarf_cursor *c);
|
|
|
|
extern int dwarf_create_state_record (struct dwarf_cursor *c,
|
2014-09-20 18:03:10 +02:00
|
|
|
dwarf_state_record_t *sr);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_make_proc_info (struct dwarf_cursor *c);
|
|
|
|
extern int dwarf_read_encoded_pointer (unw_addr_space_t as,
|
2014-09-20 18:03:10 +02:00
|
|
|
unw_accessors_t *a,
|
|
|
|
unw_word_t *addr,
|
|
|
|
unsigned char encoding,
|
|
|
|
const unw_proc_info_t *pi,
|
|
|
|
unw_word_t *valp, void *arg);
|
2003-12-21 08:57:42 +01:00
|
|
|
extern int dwarf_step (struct dwarf_cursor *c);
|
2003-12-20 12:43:08 +01:00
|
|
|
|
|
|
|
#endif /* dwarf_h */
|