[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Missing backtrace information on aarch64

From: Stephen Hemminger
Subject: Missing backtrace information on aarch64
Date: Wed, 18 Mar 2020 10:45:59 -0700

Trying to use libunwind on Arm64 and discovered that it is not working
as expected. Only one function is printed.

On x86 Debian 10 (1.2.1-9)
$ ./bt
^\Signal Quit recevied
#0 0x5640deb47308 (sigquit+0x29)
#1 0x7f4337b8587f (killpg+0x40)
#2 0x7f4337c146f4 (nanosleep+0x14)
#3 0x7f4337c1462a (sleep+0x3a)
#4 0x5640deb4732c (main+0x1f)
#5 0x7f4337b7209b (__libc_start_main+0xeb)
#6 0x564

On Arm64 

# /tmp/bt
^\Signal Quit recevied
#0 0xab9f2f927bf0 (sigquit+0x34)
Aborted (core dumped)

The test is not very complex.

#include <stdio.h>
#include <dlfcn.h>
#include <libunwind.h>
#include <string.h>

#include <unistd.h>
#include <stdlib.h>
#include <signal.h>

static void print_backtrace(void)
        unw_cursor_t cursor;
        unw_context_t ctx;
        unsigned int n = 0;

        unw_init_local(&cursor, &ctx);

        while (unw_step(&cursor) > 0) {
                unw_proc_info_t p_info;
                unw_word_t offset;
                char func_name[256] = "";
                void *addr;
                int rc;

                rc = unw_get_proc_info(&cursor, &p_info);
                if (rc != 0)
                        fprintf(stderr, "unw_get_proc_info ret %d\n", rc);
                else {
                        rc = unw_get_proc_name(&cursor, func_name,
                                               sizeof(func_name), &offset);
                        if (rc == -UNW_ENOINFO)
                                strcpy(func_name, "???");

                        addr = (void *)(p_info.start_ip + offset);
                        fprintf(stderr, "#%u %p (%s+%#lx)\n", n++,
                                addr, func_name, (unsigned long)offset);

static void sigquit(int signo)
        fprintf(stderr, "Signal %s recevied\n", strsignal(signo));

int main(int ac, char **av)
        signal(SIGQUIT, sigquit);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]