]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Print elision message if we skipped frames on traceback.
authorKeith Randall <khr@golang.org>
Thu, 23 Jan 2014 20:47:30 +0000 (12:47 -0800)
committerKeith Randall <khr@golang.org>
Thu, 23 Jan 2014 20:47:30 +0000 (12:47 -0800)
Fixes bug 7180

R=golang-codereviews, dvyukov
CC=golang-codereviews, gri
https://golang.org/cl/55810044

src/pkg/runtime/runtime.h
src/pkg/runtime/traceback_arm.c
src/pkg/runtime/traceback_x86.c

index c4c47964b92e88e671808a1cf7070014c61b4b19..13fb55454754e943b94a4b361f93557e573235a7 100644 (file)
@@ -716,6 +716,11 @@ void       runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G* gp);
 void   runtime·tracebackothers(G*);
 bool   runtime·haszeroargs(uintptr pc);
 bool   runtime·topofstack(Func*);
+enum
+{
+       // The maximum number of frames we print for a traceback
+       TracebackMaxFrames = 100,
+};
 
 /*
  * external data
index 8a3685e76c508ee3d0ffa251bfdba5a88aaf3eee..3c23cd9fcd3156bfa1b33790ed79291a67ff7722 100644 (file)
@@ -231,6 +231,8 @@ runtime·printcreatedby(G *gp)
 void
 runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
 {
+       int32 n;
+
        if(gp->status == Gsyscall) {
                // Override signal registers if blocked in system call.
                pc = gp->syscallpc;
@@ -240,8 +242,11 @@ runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
 
        // Print traceback. By default, omits runtime frames.
        // If that means we print nothing at all, repeat forcing all frames printed.
-       if(runtime·gentraceback(pc, sp, lr, gp, 0, nil, 100, nil, nil, false) == 0)
-               runtime·gentraceback(pc, sp, lr, gp, 0, nil, 100, nil, nil, true);
+       n = runtime·gentraceback(pc, sp, lr, gp, 0, nil, TracebackMaxFrames, nil, nil, false);
+       if(n == 0)
+               runtime·gentraceback(pc, sp, lr, gp, 0, nil, TracebackMaxFrames, nil, nil, true);
+       if(n == TracebackMaxFrames)
+               runtime·printf("...additional frames elided...\n");
        runtime·printcreatedby(gp);
 }
 
index 8e3063f43a64a89fe23f064d95059ef89795b4a3..fa46d547a837222f2872ff5fb97c394aa92d0e02 100644 (file)
@@ -232,6 +232,8 @@ runtime·printcreatedby(G *gp)
 void
 runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
 {
+       int32 n;
+
        USED(lr);
 
        if(gp->status == Gsyscall) {
@@ -242,8 +244,11 @@ runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
        
        // Print traceback. By default, omits runtime frames.
        // If that means we print nothing at all, repeat forcing all frames printed.
-       if(runtime·gentraceback(pc, sp, 0, gp, 0, nil, 100, nil, nil, false) == 0)
-               runtime·gentraceback(pc, sp, 0, gp, 0, nil, 100, nil, nil, true);
+       n = runtime·gentraceback(pc, sp, 0, gp, 0, nil, TracebackMaxFrames, nil, nil, false);
+       if(n == 0)
+               n = runtime·gentraceback(pc, sp, 0, gp, 0, nil, TracebackMaxFrames, nil, nil, true);
+       if(n == TracebackMaxFrames)
+               runtime·printf("...additional frames elided...\n");
        runtime·printcreatedby(gp);
 }