summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-11-15 01:27:25 +0100
committerAraq <rumpf_a@web.de>2012-11-15 01:27:25 +0100
commit814fcb263939e8127eb89c379c448f481df14dbd (patch)
treeffbe247e03da9373caad8d1d079e21b314bf4cb1 /lib
parentc439010d5275e4f6c41573f2679a298e73d128cc (diff)
downloadNim-814fcb263939e8127eb89c379c448f481df14dbd.tar.gz
bugfix: stack traces; first class iterators almost working
Diffstat (limited to 'lib')
-rwxr-xr-xlib/system/debugger.nim18
-rwxr-xr-xlib/system/excpt.nim18
2 files changed, 24 insertions, 12 deletions
diff --git a/lib/system/debugger.nim b/lib/system/debugger.nim
index 2add37740..68fbccef6 100755
--- a/lib/system/debugger.nim
+++ b/lib/system/debugger.nim
@@ -675,21 +675,27 @@ proc dbgWriteStackTrace(f: PFrame) =
     i = 0
     total = 0
     tempFrames: array [0..127, PFrame]
-  while it != nil and i <= high(tempFrames)-(firstCalls-1):
-    # the (-1) is for a nil entry that marks where the '...' should occur
+  # setup long head:
+  while it != nil and i <= high(tempFrames)-firstCalls:
     tempFrames[i] = it
     inc(i)
     inc(total)
     it = it.prev
+  # go up the stack to count 'total':
   var b = it
   while it != nil:
     inc(total)
     it = it.prev
-  for j in 1..total-i-(firstCalls-1): 
-    if b != nil: b = b.prev
-  if total != i:
+  var skipped = 0
+  if total > len(tempFrames):
+    # skip N
+    skipped = total-i-firstCalls+1
+    for j in 1..skipped:
+      if b != nil: b = b.prev
+    # create '...' entry:
     tempFrames[i] = nil
     inc(i)
+  # setup short tail:
   while b != nil and i <= high(tempFrames):
     tempFrames[i] = b
     inc(i)
@@ -697,7 +703,7 @@ proc dbgWriteStackTrace(f: PFrame) =
   for j in countdown(i-1, 0):
     if tempFrames[j] == nil: 
       write(stdout, "(")
-      write(stdout, (total-i-1))
+      write(stdout, skipped)
       write(stdout, " calls omitted) ...")
     else:
       write(stdout, tempFrames[j].filename)
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index fa2622435..9fbdecbb2 100755
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -135,21 +135,27 @@ proc auxWriteStackTrace(f: PFrame, s: var string) =
     it = f
     i = 0
     total = 0
-  while it != nil and i <= high(tempFrames)-(firstCalls-1):
-    # the (-1) is for a nil entry that marks where the '...' should occur
+  # setup long head:
+  while it != nil and i <= high(tempFrames)-firstCalls:
     tempFrames[i] = it
     inc(i)
     inc(total)
     it = it.prev
+  # go up the stack to count 'total':
   var b = it
   while it != nil:
     inc(total)
     it = it.prev
-  for j in 1..total-i-(firstCalls-1): 
-    if b != nil: b = b.prev
-  if total != i:
+  var skipped = 0
+  if total > len(tempFrames):
+    # skip N
+    skipped = total-i-firstCalls+1
+    for j in 1..skipped:
+      if b != nil: b = b.prev
+    # create '...' entry:
     tempFrames[i] = nil
     inc(i)
+  # setup short tail:
   while b != nil and i <= high(tempFrames):
     tempFrames[i] = b
     inc(i)
@@ -157,7 +163,7 @@ proc auxWriteStackTrace(f: PFrame, s: var string) =
   for j in countdown(i-1, 0):
     if tempFrames[j] == nil: 
       add(s, "(")
-      add(s, $(total-i-1))
+      add(s, $skipped)
       add(s, " calls omitted) ...")
     else:
       var oldLen = s.len