@@ -210,7 +210,7 @@ when defined(nativeStacktrace) and nativeStackTraceSupported:
210210 # interested in
211211 enabled = true
212212
213- when not hasThreadSupport:
213+ when hasSomeStackTrace and not hasThreadSupport:
214214 var
215215 tempFrames: array [0 .. 127 , PFrame ] # should not be alloc'd on stack
216216
@@ -261,52 +261,53 @@ proc `$`(s: seq[StackTraceEntry]): string =
261261 elif s[i].line == reraisedFromEnd: result .add " ]]\n "
262262 else : addFrameEntry (result , s[i])
263263
264- proc auxWriteStackTrace (f: PFrame , s: var string ) =
265- when hasThreadSupport:
264+ when hasSomeStackTrace:
265+
266+ proc auxWriteStackTrace (f: PFrame , s: var string ) =
267+ when hasThreadSupport:
268+ var
269+ tempFrames: array [0 .. 127 , PFrame ] # but better than a threadvar
270+ const
271+ firstCalls = 32
266272 var
267- tempFrames: array [0 .. 127 , PFrame ] # but better than a threadvar
268- const
269- firstCalls = 32
270- var
271- it = f
272- i = 0
273- total = 0
274- # setup long head:
275- while it != nil and i <= high (tempFrames)- firstCalls:
276- tempFrames[i] = it
277- inc (i)
278- inc (total)
279- it = it.prev
280- # go up the stack to count 'total':
281- var b = it
282- while it != nil :
283- inc (total)
284- it = it.prev
285- var skipped = 0
286- if total > len (tempFrames):
287- # skip N
288- skipped = total- i- firstCalls+ 1
289- for j in 1 .. skipped:
290- if b != nil : b = b.prev
291- # create '...' entry:
292- tempFrames[i] = nil
293- inc (i)
294- # setup short tail:
295- while b != nil and i <= high (tempFrames):
296- tempFrames[i] = b
297- inc (i)
298- b = b.prev
299- for j in countdown (i- 1 , 0 ):
300- if tempFrames[j] == nil :
301- add (s, " (" )
302- add (s, $ skipped)
303- add (s, " calls omitted) ...\n " )
304- else :
305- addFrameEntry (s, tempFrames[j])
273+ it = f
274+ i = 0
275+ total = 0
276+ # setup long head:
277+ while it != nil and i <= high (tempFrames)- firstCalls:
278+ tempFrames[i] = it
279+ inc (i)
280+ inc (total)
281+ it = it.prev
282+ # go up the stack to count 'total':
283+ var b = it
284+ while it != nil :
285+ inc (total)
286+ it = it.prev
287+ var skipped = 0
288+ if total > len (tempFrames):
289+ # skip N
290+ skipped = total- i- firstCalls+ 1
291+ for j in 1 .. skipped:
292+ if b != nil : b = b.prev
293+ # create '...' entry:
294+ tempFrames[i] = nil
295+ inc (i)
296+ # setup short tail:
297+ while b != nil and i <= high (tempFrames):
298+ tempFrames[i] = b
299+ inc (i)
300+ b = b.prev
301+ for j in countdown (i- 1 , 0 ):
302+ if tempFrames[j] == nil :
303+ add (s, " (" )
304+ add (s, $ skipped)
305+ add (s, " calls omitted) ...\n " )
306+ else :
307+ addFrameEntry (s, tempFrames[j])
306308
307- proc stackTraceAvailable * (): bool
309+ proc stackTraceAvailable * (): bool
308310
309- when hasSomeStackTrace:
310311 proc rawWriteStackTrace (s: var string ) =
311312 when defined (nimStackTraceOverride):
312313 add (s, " Traceback (most recent call last, using override)\n " )
@@ -425,14 +426,6 @@ when gotoBasedExceptions:
425426 currException = nil
426427 quit (1 )
427428
428- addQuitProc (proc () {.noconv .} =
429- if currException != nil :
430- reportUnhandledError (currException)
431- # emulate: ``programResult = 1`` via abort() and a nop signal handler.
432- c_signal (SIGABRT , (proc (sign: cint ) {.noconv , benign .} = discard ))
433- c_abort ()
434- )
435-
436429proc raiseExceptionAux (e: sink (ref Exception )) {.nodestroy .} =
437430 if localRaiseHook != nil :
438431 if not localRaiseHook (e): return
0 commit comments