MCPcopy Create free account
hub / github.com/acl-dev/acl / stacktrace

Function stacktrace

test/libmm/libmm.cpp:10–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "libmm.h"
9
10static void stacktrace(void)
11{
12 unw_cursor_t cursor;
13 unw_word_t off, pc;
14 char name[128];
15 int ret;
16 ucontext_t context;
17
18 if (getcontext(&context) < 0) {
19 printf("getcontext error\r\n");
20 return;
21 }
22
23 ret = unw_init_local(&cursor, (unw_context_t*) &context);
24 if (ret != 0) {
25 printf("unw_init_local error, ret=%d\r\n", ret);
26 return;
27 }
28
29 while (unw_step(&cursor) > 0) {
30 ret = unw_get_proc_name(&cursor, name, sizeof(name), &off);
31 if (ret != 0) {
32 printf("unw_get_proc_name error =%d\n", ret);
33 } else {
34 unw_get_reg(&cursor, UNW_REG_IP, &pc);
35 printf("0x%lx:(%s()+0x%lx)\n", pc, name, off);
36 }
37 }
38}
39
40static size_t total_size = 0;
41static bool __check = false;

Callers 4

stackshowMethod · 0.85
showMethod · 0.85
runMethod · 0.85
mallocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…