Hi Dave,

Thanks for the missing .h file for the mips.  With that file, I was able to 
successfully build the libunwind library files for mips.  I have verified that 
the libraries built are all MIPS. However, when I go to test the backtrace with 
the same application as I had tested successfully with arm, it causes the app 
to SEGV fault (signal 11).   Was the mips implementation validated with the 1.2 
release?  I am running GNU/linux 2.6.36.  I used -g -O0 options when compiling 
libraries and the app, which should turn off all optimization.

I have attached a copy of the app's backtrace.c which I am using to do the 
backtrace using libunwind.

I am interested in knowing what you think?  I would like to hear if anyone else 
is seeing issue with the Mips implementation?

Thanks,

John Knight
[email protected]
__________________________________________________________________ Confidential 
This e-mail and any files transmitted with it are the property of Belkin 
International, Inc. and/or its affiliates, are confidential, and are intended 
solely for the use of the individual or entity to whom this e-mail is 
addressed. If you are not one of the named recipients or otherwise have reason 
to believe that you have received this e-mail in error, please notify the 
sender and delete this message immediately from your computer. Any other use, 
retention, dissemination, forwarding, printing or copying of this e-mail is 
strictly prohibited. Pour la version fran?aise: 
http://www.belkin.com/email-notice/French.html F?r die deutsche ?bersetzung: 
http://www.belkin.com/email-notice/German.html 
__________________________________________________________________
/*******************************************************************
 Print a backtrace of the stack to the debug log. 
********************************************************************/

#include "debug.h"
#include "config.h"
#include "util.h"

#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>

// HAVE_LIBUNWIND passed in from Makefile
#ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif

#ifdef HAVE_LIBUNWIND
void log_stack_trace(char * program_name)
{
        unw_cursor_t cursor; unw_context_t uc;
        unw_word_t ip, sp, off;
        int status;
        unsigned i = 0;
        char procname[256];
        
        procname[sizeof(procname) - 1] = '\0';

        if (unw_getcontext(&uc) != 0) {
                INFO("unable to produce a stack trace with libunwind; 
unw_getcontext failure\n");
                return;
        }

        if (unw_init_local(&cursor, &uc) != 0) {
                INFO("unable to produce a stack trace with libunwind; 
unw_init_local failure\n");
                return;
        }

        INFO("%s: BACKTRACE:\n", program_name);

        while(1) {
            status = unw_step(&cursor);
            if(status == 0) {
                // INFO("unw_step: returned %d\n", status);
                break;
            }
            if(status < 0) {
                INFO("unw_step error: %d\n", status);
                break;
            }
            // we got a valid stack frame to display
            ip = sp = 0;
            unw_get_reg(&cursor, UNW_REG_IP, &ip);
            unw_get_reg(&cursor, UNW_REG_SP, &sp);

            switch (unw_get_proc_name(&cursor, procname, sizeof(procname) - 1, 
&off)) 
            {
                case 0:
                    /* Name found. */
                case -UNW_ENOMEM:
                    /* Name truncated. */
                    INFO(" #%u %s + %#lx [ip=%#lx] [sp=%#lx]\n",
                         i, procname, (unsigned long)off,
                         (unsigned long)ip, (unsigned long) sp);
                    break;
                default:
                    /* case -UNW_ENOINFO: */
                    /* case -UNW_EUNSPEC: */
                    /* No symbol name found. */
                    INFO(" #%u %s [ip=%#lx] [sp=%#lx]\n",
                         i, "<unknown symbol>",
                         (unsigned long)ip, (unsigned long) sp);
            }
            i++;
        }
        return;
}

#else

// If we don't have libunwind, then we can't do a stack backtrace
void log_stack_trace(char * program_name)
{
        INFO("%s: unable to produce a stack trace on this platform; Need 
libunwind\n", program_name);
}

#endif


_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to