summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-22 18:52:33 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-22 18:52:33 +0000
commit48cd836f73a91f430cc8088d7be8159a08162f8c (patch)
tree5eca75e24abe6155adb44ab8c29ea40cb0bea840
parentac58a228df4ae9b2d7752e89f6323600e1ecac53 (diff)
downloadgcc-48cd836f73a91f430cc8088d7be8159a08162f8c.tar.gz
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
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--libgo/runtime/go-caller.c14
-rw-r--r--libgo/runtime/go-callers.c19
-rw-r--r--libgo/runtime/runtime.h3
4 files changed, 24 insertions, 14 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index f5d71f57d33..b708cb7c603 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-b4d61f028dd1623142df4130b6c660bb77474b7b
+ed8647cc99652db2d689215c05f31ad038438a7e
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
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;
}
diff --git a/libgo/runtime/go-callers.c b/libgo/runtime/go-callers.c
index 590315376e3..b16ae0c4036 100644
--- a/libgo/runtime/go-callers.c
+++ b/libgo/runtime/go-callers.c
@@ -145,16 +145,17 @@ callback (void *data, uintptr_t pc, const char *filename, int lineno,
/* Syminfo callback. */
-static void
-syminfo_fnname_callback (void *data, uintptr_t pc __attribute__ ((unused)),
- const char *symname,
- uintptr_t address __attribute__ ((unused)),
- uintptr_t size __attribute__ ((unused)))
+void
+__go_syminfo_fnname_callback (void *data,
+ uintptr_t pc __attribute__ ((unused)),
+ const char *symname,
+ uintptr_t address __attribute__ ((unused)),
+ uintptr_t size __attribute__ ((unused)))
{
- Location* locptr = (Location*) data;
+ String* strptr = (String*) data;
if (symname != NULL)
- locptr->function = runtime_gostringnocopy ((const byte *) symname);
+ *strptr = runtime_gostringnocopy ((const byte *) symname);
}
/* Error callback. */
@@ -228,8 +229,8 @@ runtime_callers (int32 skip, Location *locbuf, int32 m, bool keep_thunks)
for (i = 0; i < data.index; ++i)
{
if (locbuf[i].function.len == 0 && locbuf[i].pc != 0)
- backtrace_syminfo (state, locbuf[i].pc, syminfo_fnname_callback,
- error_callback, &locbuf[i]);
+ backtrace_syminfo (state, locbuf[i].pc, __go_syminfo_fnname_callback,
+ error_callback, &locbuf[i].function);
}
return data.index;
diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h
index 0fafe821441..0ffcf4bde9e 100644
--- a/libgo/runtime/runtime.h
+++ b/libgo/runtime/runtime.h
@@ -456,7 +456,8 @@ extern uintptr runtime_stacks_sys;
struct backtrace_state;
extern struct backtrace_state *__go_get_backtrace_state(void);
-extern _Bool __go_file_line(uintptr, int, String*, String*, intgo *);
+extern void __go_syminfo_fnname_callback(void*, uintptr_t, const char*,
+ uintptr_t, uintptr_t);
extern void runtime_main(void*)
__asm__(GOSYM_PREFIX "runtime.main");