diff --git a/source/posix/system_info.c b/source/posix/system_info.c index 2f42c3882..795854c70 100644 --- a/source/posix/system_info.c +++ b/source/posix/system_info.c @@ -164,7 +164,7 @@ void s_resolve_cmd(char *cmd, size_t len, struct aws_stack_frame_info *frame) { } # else int s_parse_symbol(const char *symbol, void *addr, struct aws_stack_frame_info *frame) { - /* symbols look like: () [0x] + /* symbols look like: (+) [0x] * or: [0x] */ (void)addr; @@ -182,16 +182,28 @@ int s_parse_symbol(const char *symbol, void *addr, struct aws_stack_frame_info * ptrdiff_t exe_len = exe_end - symbol; strncpy(frame->exe, symbol, exe_len); - const char *addr_start = strstr(exe_end, "[") + 1; - char *addr_end = strstr(addr_start, "]"); - if (!addr_end) { - return AWS_OP_ERR; - } - strncpy(frame->addr, addr_start, addr_end - addr_start); - long function_len = (open_paren && close_paren) ? close_paren - open_paren - 1 : 0; if (function_len > 0) { /* dynamic symbol was found */ - strncpy(frame->function, open_paren + 1, function_len); + /* there might be (+) or just () */ + const char *function_start = open_paren + 1; + const char *plus = strstr(function_start, "+"); + const char *function_end = (plus) ? plus : close_paren; + if (function_end > function_start) { + function_len = function_end - function_start; + strncpy(frame->function, function_start, function_len); + } else if (plus) { + long addr_len = close_paren - plus - 1; + strncpy(frame->addr, plus + 1, addr_len); + } + } + if (frame->addr[0] == 0) { + /* use the address in []'s, since it's all we have */ + const char *addr_start = strstr(exe_end, "[") + 1; + char *addr_end = strstr(addr_start, "]"); + if (!addr_end) { + return AWS_OP_ERR; + } + strncpy(frame->addr, addr_start, addr_end - addr_start); } return AWS_OP_SUCCESS; @@ -218,7 +230,7 @@ void aws_backtrace_print(FILE *fp, void *call_site_data) { return; } - /* symbols look like: () [0x] + /* symbols look like: (+) [0x] * or: [0x] * start at 1 to skip the current frame (this function) */ for (int frame_idx = 1; frame_idx < stack_depth; ++frame_idx) {