[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] libunwind and split debug files
From: |
Norbert Lange |
Subject: |
[Libunwind-devel] libunwind and split debug files |
Date: |
Thu, 2 Feb 2017 09:58:49 +0100 |
Hello,
I want to display stacktraces in cases of crashes, and libunwind is
incapable of following the gnu_debuglink for debug information, and
cant resolve function names. The configure option --enable-debug-frame
*does resolve the right debug file*, but only seems to use it for
something else.
Is this supposed to not work? Debug-infos can easily take dozens of
MB, so not stripping them is a annoying handicap.
I am running on Debian Stretch AMD64, taken the libunwind sources from
https://packages.debian.org/source/stretch/amd64/libunwind
libunwind 1.1 is configured and build with these options:
--with-pic --enable-cxx-exceptions --enable-minidebuginfo --enable-debug-frame
cat > unwind.cpp << 'EOF'
#include <cstdio>
#define UNW_LOCAL_ONLY
#include <libunwind.h>
static void show_backtrace (void) {
unw_cursor_t cursor; unw_context_t uc;
unw_word_t ip, sp;
unw_getcontext(&uc);
unw_init_local(&cursor, &uc);
while (unw_step(&cursor) > 0) {
unw_get_reg(&cursor, UNW_REG_IP, &ip);
unw_get_reg(&cursor, UNW_REG_SP, &sp);
char buffer[512];
unw_word_t off = 0;
if (unw_get_proc_name(&cursor, buffer, sizeof(buffer), &off) != 0)
buffer[0] = '\0';
printf ("ip = %lx, sp = %lx. %s (+%lu)\n", (long) ip, (long) sp,
buffer, (unsigned long)off);
}
}
void foo2()
{
show_backtrace();
}
void foo1()
{
foo2();
}
int main(int argc, char **argv)
{
foo1();
}
EOF
cat > Makefile << 'EOF'
all: unwind unwind_split unwind_split.dbg
unwind: unwind.cpp
$(CXX) $(CXXFLAGS) -lunwind -o "$@" $^
unwind_split unwind_split.dbg: unwind
objcopy --only-keep-debug "$<" unwind_split.dbg && \
objcopy --strip-debug --strip-unneeded
--add-gnu-debuglink=unwind_split.dbg "$<" unwind_split || \
rm -f unwind_split unwind_split.dbg
clean:
rm -f unwind unwind_split unwind_split.dbg
EOF
- [Libunwind-devel] libunwind and split debug files,
Norbert Lange <=