aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-callers.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-03-07 01:16:20 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-03-07 01:16:20 +0000
commit0effc3f961337abd0edb7c1a3dcd4b98636c085c (patch)
tree28d4e50a31f7428050763b36e3c7bbdeeb541a0f /libgo/runtime/go-callers.c
parent1f3d0afc2623f1728a73971d415ca2991f7b9c18 (diff)
downloadgcc-0effc3f961337abd0edb7c1a3dcd4b98636c085c.zip
gcc-0effc3f961337abd0edb7c1a3dcd4b98636c085c.tar.gz
gcc-0effc3f961337abd0edb7c1a3dcd4b98636c085c.tar.bz2
libgo: Implement and use runtime.Caller, runtime.Func.FileLine.
From-SVN: r185025
Diffstat (limited to 'libgo/runtime/go-callers.c')
-rw-r--r--libgo/runtime/go-callers.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libgo/runtime/go-callers.c b/libgo/runtime/go-callers.c
index 0089c67..09556c3 100644
--- a/libgo/runtime/go-callers.c
+++ b/libgo/runtime/go-callers.c
@@ -25,8 +25,13 @@ backtrace (struct _Unwind_Context *context, void *varg)
{
struct callers_data *arg = (struct callers_data *) varg;
uintptr pc;
+ int ip_before_insn = 0;
+#ifdef HAVE_GETIPINFO
+ pc = _Unwind_GetIPInfo (context, &ip_before_insn);
+#else
pc = _Unwind_GetIP (context);
+#endif
/* FIXME: If PC is in the __morestack routine, we should ignore
it. */
@@ -37,6 +42,11 @@ backtrace (struct _Unwind_Context *context, void *varg)
return _URC_END_OF_STACK;
else
{
+ /* Here PC will be the return address. We actually want the
+ address of the call instruction, so back up one byte and
+ count on the lookup routines handling that correctly. */
+ if (!ip_before_insn)
+ --pc;
arg->pcbuf[arg->index] = pc;
++arg->index;
}
@@ -48,7 +58,7 @@ runtime_callers (int32 skip, uintptr *pcbuf, int32 m)
{
struct callers_data arg;
- arg.skip = skip;
+ arg.skip = skip + 1;
arg.pcbuf = pcbuf;
arg.index = 0;
arg.max = m;