Skip to content

Commit be5d2d4

Browse files
committed
runtime: Print elision message if we skipped frames on traceback.
Fixes bug 7180 R=golang-codereviews, dvyukov CC=golang-codereviews, gri https://golang.org/cl/55810044
1 parent 0ad2cd0 commit be5d2d4

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/pkg/runtime/runtime.h

+5
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,11 @@ void runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G* gp);
716716
void runtime·tracebackothers(G*);
717717
bool runtime·haszeroargs(uintptr pc);
718718
bool runtime·topofstack(Func*);
719+
enum
720+
{
721+
// The maximum number of frames we print for a traceback
722+
TracebackMaxFrames = 100,
723+
};
719724

720725
/*
721726
* external data

src/pkg/runtime/traceback_arm.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ runtime·printcreatedby(G *gp)
231231
void
232232
runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
233233
{
234+
int32 n;
235+
234236
if(gp->status == Gsyscall) {
235237
// Override signal registers if blocked in system call.
236238
pc = gp->syscallpc;
@@ -240,8 +242,11 @@ runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
240242

241243
// Print traceback. By default, omits runtime frames.
242244
// If that means we print nothing at all, repeat forcing all frames printed.
243-
if(runtime·gentraceback(pc, sp, lr, gp, 0, nil, 100, nil, nil, false) == 0)
244-
runtime·gentraceback(pc, sp, lr, gp, 0, nil, 100, nil, nil, true);
245+
n = runtime·gentraceback(pc, sp, lr, gp, 0, nil, TracebackMaxFrames, nil, nil, false);
246+
if(n == 0)
247+
runtime·gentraceback(pc, sp, lr, gp, 0, nil, TracebackMaxFrames, nil, nil, true);
248+
if(n == TracebackMaxFrames)
249+
runtime·printf("...additional frames elided...\n");
245250
runtime·printcreatedby(gp);
246251
}
247252

src/pkg/runtime/traceback_x86.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ runtime·printcreatedby(G *gp)
232232
void
233233
runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
234234
{
235+
int32 n;
236+
235237
USED(lr);
236238

237239
if(gp->status == Gsyscall) {
@@ -242,8 +244,11 @@ runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G *gp)
242244

243245
// Print traceback. By default, omits runtime frames.
244246
// If that means we print nothing at all, repeat forcing all frames printed.
245-
if(runtime·gentraceback(pc, sp, 0, gp, 0, nil, 100, nil, nil, false) == 0)
246-
runtime·gentraceback(pc, sp, 0, gp, 0, nil, 100, nil, nil, true);
247+
n = runtime·gentraceback(pc, sp, 0, gp, 0, nil, TracebackMaxFrames, nil, nil, false);
248+
if(n == 0)
249+
n = runtime·gentraceback(pc, sp, 0, gp, 0, nil, TracebackMaxFrames, nil, nil, true);
250+
if(n == TracebackMaxFrames)
251+
runtime·printf("...additional frames elided...\n");
247252
runtime·printcreatedby(gp);
248253
}
249254

0 commit comments

Comments
 (0)