MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / stackutil_get_stack_str

Function stackutil_get_stack_str

util/stackutil.c:104–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104char *stackutil_get_stack_str(int id, char **type, int *nframes, int64_t *hits)
105{
106 char *str = NULL;
107#ifdef __GLIBC__
108 void *frames[MAX_STACK_FRAMES];
109 *type = NULL;
110 if (stackutil_get_stack(id, type, nframes, frames, hits) == 0) {
111 char **strings = NULL;
112 strings = backtrace_symbols(frames, *nframes);
113 strbuf *b = strbuf_new();
114 for (int j = 0, pr = 0; j < *nframes; j++) {
115 char *p = strchr(strings[j], '('), *q = strchr(strings[j], '+');
116 if (p && q) {
117 (*p) = (*q) = '\0';
118 p++;
119 q--;
120 if ((q - p) > 0) {
121 if (pr)
122 strbuf_append(b, " ");
123 strbuf_appendf(b, "%s", p);
124 pr = 1;
125 }
126 }
127 }
128 str = strbuf_disown(b);
129 free(strings);
130 }
131#endif
132 return str;
133}
134
135int stackutil_get_num_stacks(void)
136{

Callers 2

get_stacksFunction · 0.85
collectFunction · 0.85

Calls 6

stackutil_get_stackFunction · 0.85
freeFunction · 0.85
strbuf_newFunction · 0.70
strbuf_appendFunction · 0.70
strbuf_appendfFunction · 0.70
strbuf_disownFunction · 0.70

Tested by

no test coverage detected