#include "crash-stack.h"
+#include <elfutils/libdwfl.h>
+
+static int frame_callback (Dwfl_Frame *state, void *arg)
+{
+ Callstack *callstack = (Callstack*)arg;
+ Dwarf_Addr address;
+ dwfl_frame_pc (state, &address, NULL);
+ callstack->tab[callstack->elems++] = address;
+ return callstack->elems < MAX_CALLSTACK_LEN ? DWARF_CB_OK : DWARF_CB_ABORT;
+}
+
+static int thread_callback (Dwfl_Thread *thread, void *thread_arg)
+{
+ dwfl_thread_getframes (thread, frame_callback, thread_arg);
+ return DWARF_CB_ABORT;
+}
Regs *get_regs_struct (void)
{
void create_crash_stack (Regs *regs, Dwfl *dwfl, Elf *core, Callstack *callstack)
{
+ callstack->elems = 0;
+ dwfl_getthreads (dwfl, thread_callback, callstack);
}
for (it = 0; it != callstack.elems; ++it)
{
if (sizeof (callstack.tab[0]) > 4)
- printf ("0x%016llx: ", (int64_t)callstack.tab[it]);
+ printf ("0x%016llx: ", (long long)callstack.tab[it]);
else
printf ("0x%08x: ", (int32_t)callstack.tab[it]);
Dwfl_Module *module = dwfl_addrmodule (dwfl, callstack.tab[it]);