From 48cd836f73a91f430cc8088d7be8159a08162f8c Mon Sep 17 00:00:00 2001 From: ian Date: Thu, 22 Feb 2018 18:52:33 +0000 Subject: runtime: funcfileline: get missing function name from symbol table Copy the idea of https://golang.org/cl/92756 to funcfileline, which is used by runtime.FuncForPC, runtime.(*Frames).Next, and others. Reviewed-on: https://go-review.googlesource.com/96175 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257913 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/runtime/go-caller.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libgo/runtime/go-caller.c') diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c index ee8abdc67fe..6b26ddccbcf 100644 --- a/libgo/runtime/go-caller.c +++ b/libgo/runtime/go-caller.c @@ -129,18 +129,26 @@ __go_get_backtrace_state () is the entry on the stack of inlined functions; -1 means the last one. */ -_Bool +static _Bool __go_file_line (uintptr pc, int index, String *fn, String *file, intgo *line) { struct caller c; + struct backtrace_state *state; runtime_memclr (&c, sizeof c); c.index = index; - backtrace_pcinfo (__go_get_backtrace_state (), pc, callback, - error_callback, &c); + state = __go_get_backtrace_state (); + backtrace_pcinfo (state, pc, callback, error_callback, &c); *fn = c.fn; *file = c.file; *line = c.line; + + // If backtrace_pcinfo didn't get the function name from the debug + // info, try to get it from the symbol table. + if (fn->len == 0) + backtrace_syminfo (state, pc, __go_syminfo_fnname_callback, + error_callback, fn); + return c.file.len > 0; } -- cgit v1.2.1