ce123的技术博客
专注于嵌入式软件开发
自己动手实现arm函数栈帧回溯
分类: ARM Linux开发 2013-12-12 22:38 374人阅读评论(1) 收藏举报
自己动手实现arm函数栈帧回溯
内核版本:
glibc版本:
CPU平台:arm
glic中其实有这些函数,当时用的uclib版本较低,没有这些函数,但又
需要,只能自己实现了(较高的版本应该有这些函数,换版本很麻烦),而且可以加
,直接上例子!
#include <>
#include <>
#include <>
#include <>
#include <>
void A(int a);
void B(int b);
void C(int c);
void DebugBacktrace(unsigned int sn , siginfo_t *si , void *ptr);
typedef struct
{
const char *dli_fname; /* File name of defining object. */
void *dli_fbase; /* Load address of that object. */
const char *dli_sname; /* Name of nearest */
void *dli_saddr; /* Exact value of nearest */
} Dl_info;
struct ucontext_ce123 {
unsigned long uc_flags;
struct ucontext *uc_link;
stack_t uc_stack;
struct sigcontext uc_mcontext;
sigset_t uc_sigmask; /* mask last for extensibility */
}ucontext_ce123_;
struct sigframe_ce123 {
struct sigcontext sc;//保存一组寄存器上下文
unsigned long extramask[1];
unsigned long retcode;//保存返回地址
//struct aux_sigframe aux __attribute__((aligned(8)));
}sigframe_ce123;
int backtrace_ce123 (void **array, int size);
char ** backtrace_symbols_ce123 (void *const *array, int size);
int backtrace_ce123 (void **array, int size)
1
{
if (size <= 0)
return 0;
int *fp = 0, *next_fp = 0;
t = 0;
int ret
自己动手实现arm函数栈帧回溯 来自淘豆网m.daumloan.com转载请标明出处.