further steps for thread support; bootstrapping should require unzip C sources and ./build.sh

This commit is contained in:
Araq 2011-05-16 00:27:47 +02:00
commit 67a30d8371
21 changed files with 372 additions and 421 deletions

View file

@ -85,8 +85,7 @@ proc openAppend(filename: string): TFile =
write(result, "----------------------------------------\n")
proc dbgRepr(p: pointer, typ: PNimType): string =
var
cl: TReprClosure
var cl: TReprClosure
initReprClosure(cl)
cl.recDepth = maxDisplayRecDepth
# locks for the GC turned out to be a bad idea...
@ -139,8 +138,10 @@ proc dbgShowCurrentProc(dbgFramePointer: PFrame) =
write(stdout, "*** endb| (procedure name not available) ***\n")
proc dbgShowExecutionPoint() =
write(stdout, "*** endb| " & $framePtr.filename & "(" & $framePtr.line &
") " & $framePtr.procname & " ***\n")
ThreadGlobals()
write(stdout, "*** endb| " & $(||framePtr).filename &
"(" & $(||framePtr).line & ") " &
$(||framePtr).procname & " ***\n")
when defined(windows) or defined(dos) or defined(os2):
{.define: FileSystemCaseInsensitive.}
@ -171,9 +172,10 @@ 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 =
@ -255,6 +257,7 @@ 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:
@ -269,7 +272,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
@ -278,7 +281,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':
@ -347,9 +350,10 @@ 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:
@ -366,11 +370,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
@ -401,7 +405,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)
@ -442,16 +446,17 @@ proc endbStep() =
CommandPrompt()
proc checkForBreakpoint() =
var i = dbgBreakpointReached(framePtr.line)
ThreadGlobals()
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()
@ -482,7 +487,8 @@ 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"
framePtr.line = line # this is done here for smaller code size!
ThreadGlobals()
(||framePtr).line = line # this is done here for smaller code size!
if dbgLineHook != nil: dbgLineHook()
case dbgState
of dbStepInto:
@ -490,7 +496,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)