@@ -76,7 +76,6 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
76
76
if usesLR {
77
77
frame .lr = lr0
78
78
}
79
- waspanic := false
80
79
cgoCtxt := gp .cgoCtxt
81
80
printing := pcbuf == nil && callback == nil
82
81
@@ -121,7 +120,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
121
120
122
121
var cache pcvalueCache
123
122
124
- lastFuncID := funcID_normal
123
+ calleeFuncID := funcID_normal
125
124
n := 0
126
125
for n < max {
127
126
// Typically:
@@ -308,7 +307,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
308
307
// deferproc a second time (if the corresponding deferred func recovers).
309
308
// In the latter case, use a deferreturn call site as the continuation pc.
310
309
frame .continpc = frame .pc
311
- if waspanic {
310
+ if calleeFuncID == funcID_sigpanic {
312
311
if frame .fn .deferreturn != 0 {
313
312
frame .continpc = frame .fn .entry () + uintptr (frame .fn .deferreturn ) + 1
314
313
// Note: this may perhaps keep return variables alive longer than
@@ -346,7 +345,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
346
345
// See issue 34123.
347
346
// The pc can be at function entry when the frame is initialized without
348
347
// actually running code, like runtime.mstart.
349
- if (n == 0 && flags & _TraceTrap != 0 ) || waspanic || pc == f .entry () {
348
+ if (n == 0 && flags & _TraceTrap != 0 ) || calleeFuncID == funcID_sigpanic || pc == f .entry () {
350
349
pc ++
351
350
} else {
352
351
tracepc --
@@ -360,30 +359,29 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
360
359
if ix < 0 {
361
360
break
362
361
}
363
- if inltree [ix ].funcID == funcID_wrapper && elideWrapperCalling (lastFuncID ) {
362
+ if inltree [ix ].funcID == funcID_wrapper && elideWrapperCalling (calleeFuncID ) {
364
363
// ignore wrappers
365
364
} else if skip > 0 {
366
365
skip --
367
366
} else if n < max {
368
367
(* [1 << 20 ]uintptr )(unsafe .Pointer (pcbuf ))[n ] = pc
369
368
n ++
370
369
}
371
- lastFuncID = inltree [ix ].funcID
370
+ calleeFuncID = inltree [ix ].funcID
372
371
// Back up to an instruction in the "caller".
373
372
tracepc = frame .fn .entry () + uintptr (inltree [ix ].parentPc )
374
373
pc = tracepc + 1
375
374
}
376
375
}
377
376
// Record the main frame.
378
- if f .funcID == funcID_wrapper && elideWrapperCalling (lastFuncID ) {
377
+ if f .funcID == funcID_wrapper && elideWrapperCalling (calleeFuncID ) {
379
378
// Ignore wrapper functions (except when they trigger panics).
380
379
} else if skip > 0 {
381
380
skip --
382
381
} else if n < max {
383
382
(* [1 << 20 ]uintptr )(unsafe .Pointer (pcbuf ))[n ] = pc
384
383
n ++
385
384
}
386
- lastFuncID = f .funcID
387
385
n -- // offset n++ below
388
386
}
389
387
@@ -397,7 +395,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
397
395
398
396
// backup to CALL instruction to read inlining info (same logic as below)
399
397
tracepc := frame .pc
400
- if (n > 0 || flags & _TraceTrap == 0 ) && frame .pc > f .entry () && ! waspanic {
398
+ if (n > 0 || flags & _TraceTrap == 0 ) && frame .pc > f .entry () && calleeFuncID != funcID_sigpanic {
401
399
tracepc --
402
400
}
403
401
// If there is inlining info, print the inner frames.
@@ -417,19 +415,19 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
417
415
inlFunc .funcID = inltree [ix ].funcID
418
416
inlFunc .startLine = inltree [ix ].startLine
419
417
420
- if (flags & _TraceRuntimeFrames ) != 0 || showframe (inlFuncInfo , gp , nprint == 0 , inlFuncInfo .funcID , lastFuncID ) {
418
+ if (flags & _TraceRuntimeFrames ) != 0 || showframe (inlFuncInfo , gp , nprint == 0 , inlFuncInfo .funcID , calleeFuncID ) {
421
419
name := funcname (inlFuncInfo )
422
420
file , line := funcline (f , tracepc )
423
421
print (name , "(...)\n " )
424
422
print ("\t " , file , ":" , line , "\n " )
425
423
nprint ++
426
424
}
427
- lastFuncID = inltree [ix ].funcID
425
+ calleeFuncID = inltree [ix ].funcID
428
426
// Back up to an instruction in the "caller".
429
427
tracepc = frame .fn .entry () + uintptr (inltree [ix ].parentPc )
430
428
}
431
429
}
432
- if (flags & _TraceRuntimeFrames ) != 0 || showframe (f , gp , nprint == 0 , f .funcID , lastFuncID ) {
430
+ if (flags & _TraceRuntimeFrames ) != 0 || showframe (f , gp , nprint == 0 , f .funcID , calleeFuncID ) {
433
431
// Print during crash.
434
432
// main(0x1, 0x2, 0x3)
435
433
// /home/rsc/go/src/runtime/x.go:23 +0xf
@@ -453,7 +451,6 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
453
451
print ("\n " )
454
452
nprint ++
455
453
}
456
- lastFuncID = f .funcID
457
454
}
458
455
n ++
459
456
@@ -469,8 +466,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
469
466
}
470
467
}
471
468
472
- waspanic = f .funcID == funcID_sigpanic
473
- injectedCall := waspanic || f .funcID == funcID_asyncPreempt || f .funcID == funcID_debugCallV2
469
+ injectedCall := f .funcID == funcID_sigpanic || f .funcID == funcID_asyncPreempt || f .funcID == funcID_debugCallV2
474
470
475
471
// Do not unwind past the bottom of the stack.
476
472
if ! flr .valid () {
@@ -485,6 +481,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
485
481
}
486
482
487
483
// Unwind to next frame.
484
+ calleeFuncID = f .funcID
488
485
frame .fn = flr
489
486
frame .pc = frame .lr
490
487
frame .lr = 0
0 commit comments