This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-variable-monitor/source/ucli_py/libunwind/unwind.h

109 lines
1.8 KiB
C

#ifndef __UNWIND_H
#define __UNWIND_H
#include <libunwind-ptrace.h>
#include <libunwind.h>
#include <linux/ptrace.h>
#include "symbol.h"
#define DIAG_USER_STACK_SIZE (16 * 1024)
typedef unsigned long u64;
typedef unsigned char u8;
typedef unsigned int u32;
typedef long s64;
typedef char s8;
typedef int s32;
typedef struct {
struct pt_regs regs;
unsigned long ip;
unsigned long bp;
unsigned long sp;
unsigned long stack_size;
unsigned long stack[DIAG_USER_STACK_SIZE / sizeof(unsigned long)];
} raw_stack_detail;
struct regs_dump {
u64 *regs;
};
struct ip_callchain {
u64 nr;
u64 ips[0];
};
struct branch_flags {
u64 mispred : 1;
u64 predicted : 1;
u64 reserved : 62;
};
struct branch_entry {
u64 from;
u64 to;
struct branch_flags flags;
};
struct branch_stack {
u64 nr;
struct branch_entry entries[0];
};
struct stack_dump {
unsigned short offset;
u64 size;
char *data;
};
struct perf_sample {
u64 ip;
u32 pid, tid;
u64 time;
u64 addr;
u64 id;
u64 stream_id;
u64 period;
u32 cpu;
u32 raw_size;
void *raw_data;
struct ip_callchain *callchain;
struct branch_stack *branch_stack;
struct regs_dump user_regs;
struct stack_dump user_stack;
};
#define PERF_REG_IP 0
#define PERF_REG_SP 1
#define PERF_REG_BP 2
struct unwind_entry {
int pid;
int pid_ns;
u64 ip;
struct vma *map;
};
typedef struct {
struct perf_sample *stack_sample;
void *arg;
} entry_cb_arg_t;
typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
// unw_create_addr_space need
extern unw_accessors_t accessors;
struct unwind_info {
struct perf_sample *sample;
int pid;
int pid_ns;
symbol_parser *sp;
};
extern "C" void diag_printf_raw_stack(int pid, int ns_pid, const char *comm,
raw_stack_detail *raw_stack, int attach);
#endif /* __UNWIND_H */