aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-10-16 14:44:55 -0400
committerRuss Cox <rsc@golang.org>2014-10-16 14:44:55 -0400
commit7ed8723d49f93b0b983a0a89504a03e455e07537 (patch)
treec99025d9e2021b7637006d511d601e96e4d4e2a0 /src/runtime/proc.c
parent8f47c837fd4f550c5b3f25f3725c7101c281e363 (diff)
downloadgo-7ed8723d49f93b0b983a0a89504a03e455e07537.tar.xz
runtime: make pprof a little nicer
Update #8942 This does not fully address issue 8942 but it does make the profiles much more useful, until that issue can be fixed completely. LGTM=dvyukov R=r, dvyukov CC=golang-codereviews https://golang.org/cl/159990043
Diffstat (limited to 'src/runtime/proc.c')
-rw-r--r--src/runtime/proc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/runtime/proc.c b/src/runtime/proc.c
index 1426790f40..332121e903 100644
--- a/src/runtime/proc.c
+++ b/src/runtime/proc.c
@@ -2436,7 +2436,7 @@ extern byte runtime·etext[];
void
runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp, M *mp)
{
- int32 n;
+ int32 n, off;
bool traceback;
// Do not use global m in this function, use mp instead.
// On windows one m is sending reports about all the g's, so m means a wrong thing.
@@ -2530,9 +2530,20 @@ runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp, M *mp)
((uint8*)runtime·gogo <= pc && pc < (uint8*)runtime·gogo + RuntimeGogoBytes))
traceback = false;
+ off = 0;
+ if(gp == mp->g0 && mp->curg != nil) {
+ stk[0] = (uintptr)pc;
+ off = 1;
+ gp = mp->curg;
+ pc = (uint8*)gp->sched.pc;
+ sp = (uint8*)gp->sched.sp;
+ lr = 0;
+ traceback = true;
+ }
+
n = 0;
if(traceback)
- n = runtime·gentraceback((uintptr)pc, (uintptr)sp, (uintptr)lr, gp, 0, stk, nelem(stk), nil, nil, false);
+ n = runtime·gentraceback((uintptr)pc, (uintptr)sp, (uintptr)lr, gp, 0, stk+off, nelem(stk)-off, nil, nil, false);
if(!traceback || n <= 0) {
// Normal traceback is impossible or has failed.
// See if it falls into several common cases.