summary refs log tree commit diff stats
path: root/lib/system/debugger.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-06-26 20:17:19 +0200
committerAraq <rumpf_a@web.de>2011-06-26 20:17:19 +0200
commite25384db8907f846f3c053379cf5b431c4d28760 (patch)
tree73f9fcb73ff0b849805077e17889111314d1bf56 /lib/system/debugger.nim
parentc9d21164beef5850b8c3ebb4faf70b59139644d4 (diff)
downloadNim-e25384db8907f846f3c053379cf5b431c4d28760.tar.gz
improvements to get code size down for programs that don't use GC
Diffstat (limited to 'lib/system/debugger.nim')
-rwxr-xr-xlib/system/debugger.nim39
1 files changed, 16 insertions, 23 deletions
diff --git a/lib/system/debugger.nim b/lib/system/debugger.nim
index 2dccd8579..8f381585b 100755
--- a/lib/system/debugger.nim
+++ b/lib/system/debugger.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nimrod's Runtime Library
-#        (c) Copyright 2009 Andreas Rumpf
+#        (c) Copyright 2011 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -138,10 +138,8 @@ proc dbgShowCurrentProc(dbgFramePointer: PFrame) =
     write(stdout, "*** endb| (procedure name not available) ***\n")
 
 proc dbgShowExecutionPoint() =
-  ThreadGlobals()
-  write(stdout, "*** endb| " & $(||framePtr).filename & 
-                "(" & $(||framePtr).line & ") " & 
-                $(||framePtr).procname & " ***\n")
+  write(stdout, "*** endb| " & $framePtr.filename & 
+                "(" & $framePtr.line & ") " & $framePtr.procname & " ***\n")
 
 when defined(windows) or defined(dos) or defined(os2):
   {.define: FileSystemCaseInsensitive.}
@@ -172,10 +170,9 @@ proc fileMatches(c, bp: cstring): bool =
   return true
 
 proc dbgBreakpointReached(line: int): int =
-  ThreadGlobals()
   for i in 0..dbgBPlen-1:
     if line >= dbgBP[i].low and line <= dbgBP[i].high and
-        fileMatches((||framePtr).filename, dbgBP[i].filename): return i
+        fileMatches(framePtr.filename, dbgBP[i].filename): return i
   return -1
 
 proc scanAndAppendWord(src: string, a: var string, start: int): int =
@@ -257,7 +254,6 @@ proc hasExt(s: string): bool =
   return false
 
 proc setBreakPoint(s: string, start: int) =
-  ThreadGlobals()
   var dbgTemp: string
   var i = scanWord(s, dbgTemp, start)
   if i <= start:
@@ -272,7 +268,7 @@ proc setBreakPoint(s: string, start: int) =
   i = scanNumber(s, dbgBP[x].low, i)
   if dbgBP[x].low == 0:
     # set to current line:
-    dbgBP[x].low = (||framePtr).line
+    dbgBP[x].low = framePtr.line
   i = scanNumber(s, dbgBP[x].high, i)
   if dbgBP[x].high == 0: # set to low:
     dbgBP[x].high = dbgBP[x].low
@@ -281,7 +277,7 @@ proc setBreakPoint(s: string, start: int) =
     if not hasExt(dbgTemp): add(dbgTemp, ".nim")
     dbgBP[x].filename = dbgTemp
   else: # use current filename
-    dbgBP[x].filename = $(||framePtr).filename
+    dbgBP[x].filename = $framePtr.filename
   # skip whitespace:
   while s[i] in {' ', '\t'}: inc(i)
   if s[i] != '\0':
@@ -350,10 +346,9 @@ proc dbgStackFrame(s: string, start: int, currFrame: PExtendedFrame) =
 
 proc CommandPrompt() =
   # if we return from this routine, user code executes again
-  ThreadGlobals()
   var
     again = True
-    dbgFramePtr = ||framePtr # for going down and up the stack
+    dbgFramePtr = framePtr # for going down and up the stack
     dbgDown = 0 # how often we did go down
 
   while again:
@@ -370,11 +365,11 @@ proc CommandPrompt() =
       again = false
     of "n", "next":
       dbgState = dbStepOver
-      dbgSkipToFrame = ||framePtr
+      dbgSkipToFrame = framePtr
       again = false
     of "f", "skipcurrent":
       dbgState = dbSkipCurrent
-      dbgSkipToFrame = (||framePtr).prev
+      dbgSkipToFrame = framePtr.prev
       again = false
     of "c", "continue":
       dbgState = dbBreakpoints
@@ -405,7 +400,7 @@ proc CommandPrompt() =
       if dbgDown <= 0:
         debugOut("[Warning] cannot go up any further ")
       else:
-        dbgFramePtr = ||framePtr
+        dbgFramePtr = framePtr
         for j in 0 .. dbgDown-2: # BUGFIX
           dbgFramePtr = dbgFramePtr.prev
         dec(dbgDown)
@@ -446,17 +441,16 @@ proc endbStep() =
   CommandPrompt()
 
 proc checkForBreakpoint() =
-  ThreadGlobals()
-  var i = dbgBreakpointReached((||framePtr).line)
+  var i = dbgBreakpointReached(framePtr.line)
   if i >= 0:
     write(stdout, "*** endb| reached ")
     write(stdout, dbgBP[i].name)
     write(stdout, " in ")
-    write(stdout, (||framePtr).filename)
+    write(stdout, framePtr.filename)
     write(stdout, "(")
-    write(stdout, (||framePtr).line)
+    write(stdout, framePtr.line)
     write(stdout, ") ")
-    write(stdout, (||framePtr).procname)
+    write(stdout, framePtr.procname)
     write(stdout, " ***\n")
     CommandPrompt()
 
@@ -487,8 +481,7 @@ proc endb(line: int) {.compilerproc.} =
   # Thus, it must have as few parameters as possible to keep the
   # code size small!
   # Check if we are at an enabled breakpoint or "in the mood"
-  ThreadGlobals()
-  (||framePtr).line = line # this is done here for smaller code size!
+  framePtr.line = line # this is done here for smaller code size!
   if dbgLineHook != nil: dbgLineHook()
   case dbgState
   of dbStepInto:
@@ -496,7 +489,7 @@ proc endb(line: int) {.compilerproc.} =
     dbgShowExecutionPoint()
     CommandPrompt()
   of dbSkipCurrent, dbStepOver: # skip current routine
-    if ||framePtr == dbgSkipToFrame:
+    if framePtr == dbgSkipToFrame:
       dbgShowExecutionPoint()
       CommandPrompt()
     else: # breakpoints are wanted though (I guess)