* libgo patch committed: Get missing function name from symbol table in funcfileline
@ 2018-02-22 18:52 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2018-02-22 18:52 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 337 bytes --]
This patch to libgo changes funcfileline to get missing a function
name from the symbol table if possible. This copies the idea of
https://golang.org/cl/92756 to funcfileline, which is used by
runtime.FuncForPC, runtime.(*Frames).Next, and others. Bootstrapped
and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3472 bytes --]
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 257911)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -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.
Index: libgo/runtime/go-caller.c
===================================================================
--- libgo/runtime/go-caller.c (revision 257527)
+++ libgo/runtime/go-caller.c (working copy)
@@ -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;
}
Index: libgo/runtime/go-callers.c
===================================================================
--- libgo/runtime/go-callers.c (revision 257527)
+++ libgo/runtime/go-callers.c (working copy)
@@ -145,16 +145,17 @@ callback (void *data, uintptr_t pc, cons
/* 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 *l
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;
Index: libgo/runtime/runtime.h
===================================================================
--- libgo/runtime/runtime.h (revision 257527)
+++ libgo/runtime/runtime.h (working copy)
@@ -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");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-02-22 18:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 18:52 libgo patch committed: Get missing function name from symbol table in funcfileline Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).