aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-caller.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2018-02-22 18:52:33 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-02-22 18:52:33 +0000
commitafedc99bd2e1f2c8b64e3deaf5ef4e1231a756af (patch)
tree5eca75e24abe6155adb44ab8c29ea40cb0bea840 /libgo/runtime/go-caller.c
parent35e7db41cab1a2b134b8ccd4407675ab20fde578 (diff)
downloadgcc-afedc99bd2e1f2c8b64e3deaf5ef4e1231a756af.zip
gcc-afedc99bd2e1f2c8b64e3deaf5ef4e1231a756af.tar.gz
gcc-afedc99bd2e1f2c8b64e3deaf5ef4e1231a756af.tar.bz2
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 From-SVN: r257913
Diffstat (limited to 'libgo/runtime/go-caller.c')
-rw-r--r--libgo/runtime/go-caller.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c
index ee8abdc..6b26ddc 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;
}