Linux Perf
unwind-libunwind-local.c File Reference
#include <elf.h>
#include <errno.h>
#include <gelf.h>
#include <fcntl.h>
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <linux/list.h>
#include "callchain.h"
#include "thread.h"
#include "session.h"
#include "perf_regs.h"
#include "unwind.h"
#include "symbol.h"
#include "util.h"
#include "debug.h"
#include "asm/bug.h"
#include "dso.h"
#include <libunwind.h>
#include <libunwind-ptrace.h>
Include dependency graph for unwind-libunwind-local.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  unwind_info
 
struct  table_entry
 
struct  eh_frame_hdr
 

Macros

#define dwarf_search_unwind_table   UNW_OBJ(dwarf_search_unwind_table)
 
#define dwarf_find_debug_frame   UNW_OBJ(dwarf_find_debug_frame)
 
#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 */
 
#define DW_EH_PE_omit   0xff
 
#define DW_EH_PE_ptr   0x00 /* pointer-sized unsigned 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_sdata4   0x0b /* signed 32-bit value */
 
#define DW_EH_PE_sdata8   0x0c /* signed 64-bit value */
 
#define DW_EH_PE_absptr   0x00 /* absolute value */
 
#define DW_EH_PE_pcrel   0x10 /* rel. to addr. of encoded value */
 
#define DW_EH_PE_funcrel   0x40 /* start-of-procedure-relative */
 
#define DW_EH_PE_aligned   0x50 /* aligned pointer */
 
#define dw_read(ptr, type, end)
 
#define dw_read_encoded_value(ptr, end, enc)
 

Functions

int UNW_OBJ() dwarf_search_unwind_table (unw_addr_space_t as, unw_word_t ip, unw_dyn_info_t *di, unw_proc_info_t *pi, int need_unwind_info, void *arg)
 
int UNW_OBJ() dwarf_find_debug_frame (int found, unw_dyn_info_t *di_debug, unw_word_t ip, unw_word_t segbase, const char *obj_name, unw_word_t start, unw_word_t end)
 
static int __dw_read_encoded_value (u8 **p, u8 *end, u64 *val, u8 encoding)
 
static u64 elf_section_offset (int fd, const char *name)
 
static int elf_is_exec (int fd, const char *name)
 
static int unwind_spec_ehframe (struct dso *dso, struct machine *machine, u64 offset, u64 *table_data, u64 *segbase, u64 *fde_count)
 
static int read_unwind_spec_eh_frame (struct dso *dso, struct machine *machine, u64 *table_data, u64 *segbase, u64 *fde_count)
 
static int read_unwind_spec_debug_frame (struct dso *dso, struct machine *machine, u64 *offset)
 
static struct mapfind_map (unw_word_t ip, struct unwind_info *ui)
 
static int find_proc_info (unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, int need_unwind_info, void *arg)
 
static int access_fpreg (unw_addr_space_t __maybe_unused as, unw_regnum_t __maybe_unused num, unw_fpreg_t __maybe_unused *val, int __maybe_unused __write, void __maybe_unused *arg)
 
static int get_dyn_info_list_addr (unw_addr_space_t __maybe_unused as, unw_word_t __maybe_unused *dil_addr, void __maybe_unused *arg)
 
static int resume (unw_addr_space_t __maybe_unused as, unw_cursor_t __maybe_unused *cu, void __maybe_unused *arg)
 
static int get_proc_name (unw_addr_space_t __maybe_unused as, unw_word_t __maybe_unused addr, char __maybe_unused *bufp, size_t __maybe_unused buf_len, unw_word_t __maybe_unused *offp, void __maybe_unused *arg)
 
static int access_dso_mem (struct unwind_info *ui, unw_word_t addr, unw_word_t *data)
 
static int access_mem (unw_addr_space_t __maybe_unused as, unw_word_t addr, unw_word_t *valp, int __write, void *arg)
 
static int access_reg (unw_addr_space_t __maybe_unused as, unw_regnum_t regnum, unw_word_t *valp, int __write, void *arg)
 
static void put_unwind_info (unw_addr_space_t __maybe_unused as, unw_proc_info_t *pi __maybe_unused, void *arg __maybe_unused)
 
static int entry (u64 ip, struct thread *thread, unwind_entry_cb_t cb, void *arg)
 
static void display_error (int err)
 
static int _unwind__prepare_access (struct thread *thread)
 
static void _unwind__flush_access (struct thread *thread)
 
static void _unwind__finish_access (struct thread *thread)
 
static int get_entries (struct unwind_info *ui, unwind_entry_cb_t cb, void *arg, int max_stack)
 
static int _unwind__get_entries (unwind_entry_cb_t cb, void *arg, struct thread *thread, struct perf_sample *data, int max_stack)
 

Variables

struct eh_frame_hdr __packed
 
static unw_accessors_t accessors
 
static struct unwind_libunwind_ops _unwind_libunwind_ops
 
struct unwind_libunwind_opslocal_unwind_libunwind_ops = &_unwind_libunwind_ops
 

Macro Definition Documentation

◆ DW_EH_PE_absptr

#define DW_EH_PE_absptr   0x00 /* absolute value */

Definition at line 73 of file unwind-libunwind-local.c.

◆ DW_EH_PE_aligned

#define DW_EH_PE_aligned   0x50 /* aligned pointer */

Definition at line 82 of file unwind-libunwind-local.c.

◆ DW_EH_PE_APPL_MASK

#define DW_EH_PE_APPL_MASK   0x70 /* how the value is to be applied */

Definition at line 62 of file unwind-libunwind-local.c.

◆ DW_EH_PE_FORMAT_MASK

#define DW_EH_PE_FORMAT_MASK   0x0f /* format of the encoded value */

Definition at line 61 of file unwind-libunwind-local.c.

◆ DW_EH_PE_funcrel

#define DW_EH_PE_funcrel   0x40 /* start-of-procedure-relative */

Definition at line 81 of file unwind-libunwind-local.c.

◆ DW_EH_PE_omit

#define DW_EH_PE_omit   0xff

Definition at line 65 of file unwind-libunwind-local.c.

◆ DW_EH_PE_pcrel

#define DW_EH_PE_pcrel   0x10 /* rel. to addr. of encoded value */

Definition at line 74 of file unwind-libunwind-local.c.

◆ DW_EH_PE_ptr

#define DW_EH_PE_ptr   0x00 /* pointer-sized unsigned value */

Definition at line 66 of file unwind-libunwind-local.c.

◆ DW_EH_PE_sdata4

#define DW_EH_PE_sdata4   0x0b /* signed 32-bit value */

Definition at line 69 of file unwind-libunwind-local.c.

◆ DW_EH_PE_sdata8

#define DW_EH_PE_sdata8   0x0c /* signed 64-bit value */

Definition at line 70 of file unwind-libunwind-local.c.

◆ DW_EH_PE_udata4

#define DW_EH_PE_udata4   0x03 /* unsigned 32-bit value */

Definition at line 67 of file unwind-libunwind-local.c.

◆ DW_EH_PE_udata8

#define DW_EH_PE_udata8   0x04 /* unsigned 64-bit value */

Definition at line 68 of file unwind-libunwind-local.c.

◆ dw_read

#define dw_read (   ptr,
  type,
  end 
)
Value:
({ \
type *__p = (type *) ptr; \
type __v; \
if ((__p + 1) > (type *) end) \
return -EINVAL; \
__v = *__p++; \
ptr = (typeof(ptr)) __p; \
__v; \
})

Definition at line 100 of file unwind-libunwind-local.c.

◆ dw_read_encoded_value

#define dw_read_encoded_value (   ptr,
  end,
  enc 
)
Value:
({ \
u64 __v; \
if (__dw_read_encoded_value(&ptr, end, &__v, enc)) { \
return -EINVAL; \
} \
__v; \
})
static int __dw_read_encoded_value(u8 **p, u8 *end, u64 *val, u8 encoding)

Definition at line 162 of file unwind-libunwind-local.c.

◆ dwarf_find_debug_frame

#define dwarf_find_debug_frame   UNW_OBJ(dwarf_find_debug_frame)

Definition at line 59 of file unwind-libunwind-local.c.

◆ dwarf_search_unwind_table

#define dwarf_search_unwind_table   UNW_OBJ(dwarf_search_unwind_table)

Definition at line 50 of file unwind-libunwind-local.c.

Function Documentation

◆ __dw_read_encoded_value()

static int __dw_read_encoded_value ( u8 **  p,
u8 *  end,
u64 *  val,
u8  encoding 
)
static

Definition at line 110 of file unwind-libunwind-local.c.

◆ _unwind__finish_access()

static void _unwind__finish_access ( struct thread thread)
static

Definition at line 638 of file unwind-libunwind-local.c.

◆ _unwind__flush_access()

static void _unwind__flush_access ( struct thread thread)
static

Definition at line 631 of file unwind-libunwind-local.c.

◆ _unwind__get_entries()

static int _unwind__get_entries ( unwind_entry_cb_t  cb,
void *  arg,
struct thread thread,
struct perf_sample data,
int  max_stack 
)
static

Definition at line 709 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ _unwind__prepare_access()

static int _unwind__prepare_access ( struct thread thread)
static

Definition at line 617 of file unwind-libunwind-local.c.

◆ access_dso_mem()

static int access_dso_mem ( struct unwind_info ui,
unw_word_t  addr,
unw_word_t *  data 
)
static

Definition at line 463 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ access_fpreg()

static int access_fpreg ( unw_addr_space_t __maybe_unused  as,
unw_regnum_t __maybe_unused  num,
unw_fpreg_t __maybe_unused *  val,
int __maybe_unused  __write,
void __maybe_unused *  arg 
)
static

Definition at line 428 of file unwind-libunwind-local.c.

◆ access_mem()

static int access_mem ( unw_addr_space_t __maybe_unused  as,
unw_word_t  addr,
unw_word_t *  valp,
int  __write,
void *  arg 
)
static

Definition at line 484 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ access_reg()

static int access_reg ( unw_addr_space_t __maybe_unused  as,
unw_regnum_t  regnum,
unw_word_t *  valp,
int  __write,
void *  arg 
)
static

Definition at line 530 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ display_error()

static void display_error ( int  err)
static

Definition at line 589 of file unwind-libunwind-local.c.

◆ dwarf_find_debug_frame()

int UNW_OBJ() dwarf_find_debug_frame ( int  found,
unw_dyn_info_t *  di_debug,
unw_word_t  ip,
unw_word_t  segbase,
const char *  obj_name,
unw_word_t  start,
unw_word_t  end 
)

◆ dwarf_search_unwind_table()

int UNW_OBJ() dwarf_search_unwind_table ( unw_addr_space_t  as,
unw_word_t  ip,
unw_dyn_info_t *  di,
unw_proc_info_t *  pi,
int  need_unwind_info,
void *  arg 
)

◆ elf_is_exec()

static int elf_is_exec ( int  fd,
const char *  name 
)
static

Definition at line 196 of file unwind-libunwind-local.c.

◆ elf_section_offset()

static u64 elf_section_offset ( int  fd,
const char *  name 
)
static

Definition at line 170 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ entry()

static int entry ( u64  ip,
struct thread thread,
unwind_entry_cb_t  cb,
void *  arg 
)
static

Definition at line 571 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ find_map()

static struct map* find_map ( unw_word_t  ip,
struct unwind_info ui 
)
static

Definition at line 366 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ find_proc_info()

static int find_proc_info ( unw_addr_space_t  as,
unw_word_t  ip,
unw_proc_info_t *  pi,
int  need_unwind_info,
void *  arg 
)
static

Definition at line 373 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ get_dyn_info_list_addr()

static int get_dyn_info_list_addr ( unw_addr_space_t __maybe_unused  as,
unw_word_t __maybe_unused *  dil_addr,
void __maybe_unused *  arg 
)
static

Definition at line 438 of file unwind-libunwind-local.c.

◆ get_entries()

static int get_entries ( struct unwind_info ui,
unwind_entry_cb_t  cb,
void *  arg,
int  max_stack 
)
static

Definition at line 645 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ get_proc_name()

static int get_proc_name ( unw_addr_space_t __maybe_unused  as,
unw_word_t __maybe_unused  addr,
char __maybe_unused *  bufp,
size_t __maybe_unused  buf_len,
unw_word_t __maybe_unused *  offp,
void __maybe_unused *  arg 
)
static

Definition at line 454 of file unwind-libunwind-local.c.

◆ put_unwind_info()

static void put_unwind_info ( unw_addr_space_t __maybe_unused  as,
unw_proc_info_t *pi  __maybe_unused,
void *arg  __maybe_unused 
)
static

Definition at line 564 of file unwind-libunwind-local.c.

◆ read_unwind_spec_debug_frame()

static int read_unwind_spec_debug_frame ( struct dso dso,
struct machine machine,
u64 *  offset 
)
static

Definition at line 298 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ read_unwind_spec_eh_frame()

static int read_unwind_spec_eh_frame ( struct dso dso,
struct machine machine,
u64 *  table_data,
u64 *  segbase,
u64 *  fde_count 
)
static

Definition at line 271 of file unwind-libunwind-local.c.

Here is the call graph for this function:

◆ resume()

static int resume ( unw_addr_space_t __maybe_unused  as,
unw_cursor_t __maybe_unused *  cu,
void __maybe_unused *  arg 
)
static

Definition at line 445 of file unwind-libunwind-local.c.

◆ unwind_spec_ehframe()

static int unwind_spec_ehframe ( struct dso dso,
struct machine machine,
u64  offset,
u64 *  table_data,
u64 *  segbase,
u64 *  fde_count 
)
static

Definition at line 248 of file unwind-libunwind-local.c.

Here is the call graph for this function:

Variable Documentation

◆ __packed

struct eh_frame_hdr __packed

◆ _unwind_libunwind_ops

struct unwind_libunwind_ops _unwind_libunwind_ops
static
Initial value:
= {
.prepare_access = _unwind__prepare_access,
.flush_access = _unwind__flush_access,
.finish_access = _unwind__finish_access,
.get_entries = _unwind__get_entries,
}
static int _unwind__prepare_access(struct thread *thread)
static void _unwind__finish_access(struct thread *thread)
static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg, struct thread *thread, struct perf_sample *data, int max_stack)
static void _unwind__flush_access(struct thread *thread)

Definition at line 729 of file unwind-libunwind-local.c.

◆ accessors

unw_accessors_t accessors
static
Initial value:
= {
.find_proc_info = find_proc_info,
.put_unwind_info = put_unwind_info,
.get_dyn_info_list_addr = get_dyn_info_list_addr,
.access_mem = access_mem,
.access_reg = access_reg,
.access_fpreg = access_fpreg,
.resume = resume,
.get_proc_name = get_proc_name,
}
static int find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi, int need_unwind_info, void *arg)
static int access_reg(unw_addr_space_t __maybe_unused as, unw_regnum_t regnum, unw_word_t *valp, int __write, void *arg)
static int get_proc_name(unw_addr_space_t __maybe_unused as, unw_word_t __maybe_unused addr, char __maybe_unused *bufp, size_t __maybe_unused buf_len, unw_word_t __maybe_unused *offp, void __maybe_unused *arg)
static int access_fpreg(unw_addr_space_t __maybe_unused as, unw_regnum_t __maybe_unused num, unw_fpreg_t __maybe_unused *val, int __maybe_unused __write, void __maybe_unused *arg)
static int resume(unw_addr_space_t __maybe_unused as, unw_cursor_t __maybe_unused *cu, void __maybe_unused *arg)
static int get_dyn_info_list_addr(unw_addr_space_t __maybe_unused as, unw_word_t __maybe_unused *dil_addr, void __maybe_unused *arg)
static int access_mem(unw_addr_space_t __maybe_unused as, unw_word_t addr, unw_word_t *valp, int __write, void *arg)
static void put_unwind_info(unw_addr_space_t __maybe_unused as, unw_proc_info_t *pi __maybe_unused, void *arg __maybe_unused)

Definition at line 606 of file unwind-libunwind-local.c.

◆ local_unwind_libunwind_ops

struct unwind_libunwind_ops* local_unwind_libunwind_ops = &_unwind_libunwind_ops

Definition at line 738 of file unwind-libunwind-local.c.