MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_dump_stack

Function rte_dump_stack

dpdk/lib/eal/unix/eal_debug.c:49–120  ·  view source on GitHub ↗

* Dump the stack of the calling core * * To be safe in signal handler requires limiting what functions are * used in this code since may be called from inside libc or * when malloc poll is corrupt. * * Most of libc is therefore not safe, include RTE_LOG (calls syslog); * backtrace_symbols (calls malloc), etc. */

Source from the content-addressed store, hash-verified

47 * backtrace_symbols (calls malloc), etc.
48 */
49void rte_dump_stack(void)
50{
51 void *func[BACKTRACE_SIZE];
52 Dl_info info;
53 char buf1[8], buf2[32], buf3[32], buf4[32];
54 struct iovec iov[10];
55 int i, size;
56
57 size = backtrace(func, BACKTRACE_SIZE);
58
59 for (i = 0; i < size; i++) {
60 struct iovec *io = iov;
61 char *str;
62 uintptr_t base;
63 long offset;
64 void *pc = func[i];
65
66/*
67 * Macro to put string onto set of iovecs.
68 * cast is to suppress warnings about lose of const qualifier.
69 */
70#define PUSH_IOV(io, str) { \
71 (io)->iov_base = (char *)(uintptr_t)str; \
72 (io)->iov_len = strlen(str); \
73 ++io; }
74
75 /* output stack frame number */
76 str = safe_itoa(i, buf1, sizeof(buf1), 10);
77 PUSH_IOV(io, str); /* iov[0] */
78 PUSH_IOV(io, ": "); /* iov[1] */
79
80 /* Lookup the symbol information */
81 if (dladdr(pc, &info) == 0) {
82 PUSH_IOV(io, "?? [");
83 } else {
84 const char *fname;
85
86 if (info.dli_fname && *info.dli_fname)
87 fname = info.dli_fname;
88 else
89 fname = "(vdso)";
90 PUSH_IOV(io, fname); /* iov[2] */
91 PUSH_IOV(io, " ("); /* iov[3] */
92
93 if (info.dli_saddr != NULL) {
94 PUSH_IOV(io, info.dli_sname); /* iov[4] */
95 base = (uintptr_t)info.dli_saddr;
96 } else {
97 str = safe_itoa((unsigned long)info.dli_fbase,
98 buf3, sizeof(buf3), 16);
99 PUSH_IOV(io, str);
100 base = (uintptr_t)info.dli_fbase;
101 }
102
103 PUSH_IOV(io, "+0x"); /* iov[5] */
104
105 offset = (uintptr_t)pc - base;
106 str = safe_itoa(offset, buf4, sizeof(buf4), 16);

Callers 5

dummy_eth_rx_burstFunction · 0.50
dummy_eth_tx_burstFunction · 0.50
__rte_panicFunction · 0.50
test_debugFunction · 0.50

Calls 2

safe_itoaFunction · 0.85
writevFunction · 0.50

Tested by 1

test_debugFunction · 0.40