本文介绍了任何可用的回溯对uClibc中的移植?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在运行在ARM 9. uClibc的Linux的问题是uClibc的不支持回溯。当一个核心转储发生,我不能抢调用堆栈。

We are running the uclibc linux on ARM 9. The problem is uclibc doesn't support backtrace. When a core dump happens, I cannot grab the call stack.

有没有人有一个很好的解决方案是什么?

Does anyone have a good solution for that?

例如,回溯的现有移植的uClibc的,或者抢当一个核心转储发生在调用堆栈(uClibc的+ ARM + Linux)的?有什么好的方法

For example, an existing porting of backtrace for uclibc, or any good method to grab the call stack when a core dump happens (uclibc+ARM+Linux)?

推荐答案

更新:

看来,一个 的成立是为了支持回溯()上uClibc的x86和ARM(XScale的),它利用了 __ libc_stack_end 符号。

It seems that a patch was created to support backtrace() on uclibc for x86 and ARM (XScale) and it makes use of the __libc_stack_end symbol.

原来的答复:

我工作所在的版本中,我们正在使用没有提供的功能回溯()我们的ARM处理器的glibc的,所以我们开发的glibc我们自己之外的项目使用 __ libc_stack_end 符号。下面是导致code。或许你可以用它来写一个uClibc的回溯()功能。

I worked on a project where the version of glibc we were using did not provide a functional backtrace() for our ARM processor, so we developed our own outside of glibc using the __libc_stack_end symbol. Below is the resulting code. Perhaps you can use it to write a uclibc backtrace() function.

extern void * __libc_stack_end;

struct backtrace_frame_t
{
    void * fp;
    void * sp;
    void * lr;
    void * pc;
};

int backtrace(void ** array, int size)
{
    void * top_frame_p;
    void * current_frame_p;
    struct backtrace_frame_t * frame_p;
    int frame_count;

    top_frame_p = __builtin_frame_address(0);
    current_frame_p = top_frame_p;
    frame_p = (struct backtrace_frame_t*)((void**)(current_frame_p)-3);
    frame_count = 0;

    if (__builtin_return_address(0) != frame_p->lr)
    {
        fprintf(stderr, "backtrace error: __builtin_return_address(0) != frame_p->lr\n");
        return frame_count;
    }

    if (current_frame_p != NULL
        && current_frame_p > (void*)&frame_count
        && current_frame_p < __libc_stack_end)
    {
        while (frame_count < size
               && current_frame_p != NULL
               && current_frame_p > (void*)&frame_count
               && current_frame_p < __libc_stack_end)
        {
            frame_p = (struct backtrace_frame_t*)((void**)(current_frame_p)-3);
            array[frame_count] = frame_p->lr;
            frame_count++;
            current_frame_p = frame_p->fp;
        }
    }

    return frame_count;
}

注: __ libc_stack_end 符号不再出口较新版本的glibc的,我不知道它的存在,或uClibc的一个类似的符号

Note: The __libc_stack_end symbol is no longer exported in more recent versions of glibc and I'm not sure of the existence of it or a similar symbol in uclibc.

这篇关于任何可用的回溯对uClibc中的移植?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 16:18