ENDB compiles again

This commit is contained in:
Araq 2014-08-31 11:40:25 +02:00
commit 2d1b9d1f9d
3 changed files with 38 additions and 38 deletions

View file

@ -157,8 +157,8 @@ type
oldValue: THash oldValue: THash
var var
Watchpoints: array [0..99, TWatchpoint] watchpoints: array [0..99, TWatchpoint]
WatchpointsLen: int watchpointsLen: int
proc `!&`(h: THash, val: int): THash {.inline.} = proc `!&`(h: THash, val: int): THash {.inline.} =
result = h +% val result = h +% val
@ -189,7 +189,7 @@ proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool,
h: THash): THash h: THash): THash
proc genericHashAux(dest: pointer, n: ptr TNimNode, shallow: bool, proc genericHashAux(dest: pointer, n: ptr TNimNode, shallow: bool,
h: THash): THash = h: THash): THash =
var d = cast[TAddress](dest) var d = cast[ByteAddress](dest)
case n.kind case n.kind
of nkSlot: of nkSlot:
result = genericHashAux(cast[pointer](d +% n.offset), n.typ, shallow, h) result = genericHashAux(cast[pointer](d +% n.offset), n.typ, shallow, h)
@ -206,9 +206,9 @@ proc genericHashAux(dest: pointer, n: ptr TNimNode, shallow: bool,
proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool, proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool,
h: THash): THash = h: THash): THash =
sysAssert(mt != nil, "genericHashAux 2") sysAssert(mt != nil, "genericHashAux 2")
case mt.Kind case mt.kind
of tyString: of tyString:
var x = cast[ppointer](dest)[] var x = cast[PPointer](dest)[]
result = h result = h
if x != nil: if x != nil:
let s = cast[NimString](x) let s = cast[NimString](x)
@ -217,29 +217,29 @@ proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool,
else: else:
result = result !& hash(x, s.len) result = result !& hash(x, s.len)
of tySequence: of tySequence:
var x = cast[ppointer](dest) var x = cast[PPointer](dest)
var dst = cast[taddress](cast[ppointer](dest)[]) var dst = cast[ByteAddress](cast[PPointer](dest)[])
result = h result = h
if dst != 0: if dst != 0:
when defined(trackGcHeaders): when defined(trackGcHeaders):
result = result !& hashGcHeader(cast[ppointer](dest)[]) result = result !& hashGcHeader(cast[PPointer](dest)[])
else: else:
for i in 0..cast[pgenericseq](dst).len-1: for i in 0..cast[PGenericSeq](dst).len-1:
result = result !& genericHashAux( result = result !& genericHashAux(
cast[pointer](dst +% i*% mt.base.size +% GenericSeqSize), cast[pointer](dst +% i*% mt.base.size +% GenericSeqSize),
mt.Base, shallow, result) mt.base, shallow, result)
of tyObject, tyTuple: of tyObject, tyTuple:
# we don't need to copy m_type field for tyObject, as they are equal anyway # we don't need to copy m_type field for tyObject, as they are equal anyway
result = genericHashAux(dest, mt.node, shallow, h) result = genericHashAux(dest, mt.node, shallow, h)
of tyArray, tyArrayConstr: of tyArray, tyArrayConstr:
let d = cast[TAddress](dest) let d = cast[ByteAddress](dest)
result = h result = h
for i in 0..(mt.size div mt.base.size)-1: for i in 0..(mt.size div mt.base.size)-1:
result = result !& genericHashAux(cast[pointer](d +% i*% mt.base.size), result = result !& genericHashAux(cast[pointer](d +% i*% mt.base.size),
mt.base, shallow, result) mt.base, shallow, result)
of tyRef: of tyRef:
when defined(trackGcHeaders): when defined(trackGcHeaders):
var s = cast[ppointer](dest)[] var s = cast[PPointer](dest)[]
if s != nil: if s != nil:
result = result !& hashGcHeader(s) result = result !& hashGcHeader(s)
else: else:
@ -247,7 +247,7 @@ proc genericHashAux(dest: pointer, mt: PNimType, shallow: bool,
result = h !& hash(dest, mt.size) result = h !& hash(dest, mt.size)
else: else:
result = h result = h
var s = cast[ppointer](dest)[] var s = cast[PPointer](dest)[]
if s != nil: if s != nil:
result = result !& genericHashAux(s, mt.base, shallow, result) result = result !& genericHashAux(s, mt.base, shallow, result)
else: else:
@ -258,23 +258,23 @@ proc genericHash(dest: pointer, mt: PNimType): int =
proc dbgRegisterWatchpoint(address: pointer, name: cstring, proc dbgRegisterWatchpoint(address: pointer, name: cstring,
typ: PNimType) {.compilerproc.} = typ: PNimType) {.compilerproc.} =
let L = WatchpointsLen let L = watchPointsLen
for i in 0.. <L: for i in 0.. <L:
if Watchpoints[i].name == name: if watchPoints[i].name == name:
# address may have changed: # address may have changed:
Watchpoints[i].address = address watchPoints[i].address = address
return return
if L >= watchPoints.high: if L >= watchPoints.high:
#debugOut("[Warning] cannot register watchpoint") #debugOut("[Warning] cannot register watchpoint")
return return
Watchpoints[L].name = name watchPoints[L].name = name
Watchpoints[L].address = address watchPoints[L].address = address
Watchpoints[L].typ = typ watchPoints[L].typ = typ
Watchpoints[L].oldValue = genericHash(address, typ) watchPoints[L].oldValue = genericHash(address, typ)
inc WatchpointsLen inc watchPointsLen
proc dbgUnregisterWatchpoints*() = proc dbgUnregisterWatchpoints*() =
WatchpointsLen = 0 watchPointsLen = 0
var var
dbgLineHook*: proc () {.nimcall.} dbgLineHook*: proc () {.nimcall.}
@ -285,12 +285,12 @@ var
dbgWatchpointHook*: proc (watchpointName: cstring) {.nimcall.} dbgWatchpointHook*: proc (watchpointName: cstring) {.nimcall.}
proc checkWatchpoints = proc checkWatchpoints =
let L = WatchpointsLen let L = watchPointsLen
for i in 0.. <L: for i in 0.. <L:
let newHash = genericHash(Watchpoints[i].address, Watchpoints[i].typ) let newHash = genericHash(watchPoints[i].address, watchPoints[i].typ)
if newHash != Watchpoints[i].oldValue: if newHash != watchPoints[i].oldValue:
dbgWatchpointHook(Watchpoints[i].name) dbgWatchpointHook(watchPoints[i].name)
Watchpoints[i].oldValue = newHash watchPoints[i].oldValue = newHash
proc endb(line: int, file: cstring) {.compilerproc, noinline.} = proc endb(line: int, file: cstring) {.compilerproc, noinline.} =
# This proc is called before every Nim code line! # This proc is called before every Nim code line!

View file

@ -152,7 +152,7 @@ proc debugOut(msg: cstring) =
proc dbgFatal(msg: cstring) = proc dbgFatal(msg: cstring) =
debugOut(msg) debugOut(msg)
dbgAborting = True # the debugger wants to abort dbgAborting = true # the debugger wants to abort
quit(1) quit(1)
proc dbgShowCurrentProc(dbgFramePointer: PFrame) = proc dbgShowCurrentProc(dbgFramePointer: PFrame) =
@ -176,7 +176,7 @@ proc scanAndAppendWord(src: cstring, a: var TStaticStr, start: int): int =
result = start result = start
# skip whitespace: # skip whitespace:
while src[result] in {'\t', ' '}: inc(result) while src[result] in {'\t', ' '}: inc(result)
while True: while true:
case src[result] case src[result]
of 'a'..'z', '0'..'9': add(a, src[result]) of 'a'..'z', '0'..'9': add(a, src[result])
of '_': discard # just skip it of '_': discard # just skip it
@ -280,7 +280,7 @@ proc breakpointToggle(s: cstring, start: int) =
else: debugOut("[Warning] unknown breakpoint ") else: debugOut("[Warning] unknown breakpoint ")
proc dbgEvaluate(stream: TFile, s: cstring, start: int, f: PFrame) = proc dbgEvaluate(stream: TFile, s: cstring, start: int, f: PFrame) =
var dbgTemp: tstaticstr var dbgTemp: TStaticStr
var i = scanWord(s, dbgTemp, start) var i = scanWord(s, dbgTemp, start)
while s[i] in {' ', '\t'}: inc(i) while s[i] in {' ', '\t'}: inc(i)
var v: TVarSlot var v: TVarSlot
@ -299,10 +299,10 @@ proc dbgEvaluate(stream: TFile, s: cstring, start: int, f: PFrame) =
writeVariable(stream, v) writeVariable(stream, v)
proc dbgOut(s: cstring, start: int, currFrame: PFrame) = proc dbgOut(s: cstring, start: int, currFrame: PFrame) =
var dbgTemp: tstaticstr var dbgTemp: TStaticStr
var i = scanFilename(s, dbgTemp, start) var i = scanFilename(s, dbgTemp, start)
if dbgTemp.len == 0: if dbgTemp.len == 0:
InvalidCommand() invalidCommand()
return return
var stream = openAppend(dbgTemp.data) var stream = openAppend(dbgTemp.data)
if stream == nil: if stream == nil:
@ -326,7 +326,7 @@ proc dbgStackFrame(s: cstring, start: int, currFrame: PFrame) =
close(stream) close(stream)
proc readLine(f: TFile, line: var TStaticStr): bool = proc readLine(f: TFile, line: var TStaticStr): bool =
while True: while true:
var c = fgetc(f) var c = fgetc(f)
if c < 0'i32: if c < 0'i32:
if line.len > 0: break if line.len > 0: break
@ -355,7 +355,7 @@ proc dbgWriteStackTrace(f: PFrame)
proc commandPrompt() = proc commandPrompt() =
# if we return from this routine, user code executes again # if we return from this routine, user code executes again
var var
again = True 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 dbgDown = 0 # how often we did go down
dbgTemp: TStaticStr dbgTemp: TStaticStr
@ -390,7 +390,7 @@ proc commandPrompt() =
dbgHelp() dbgHelp()
elif ?"q" or ?"quit": elif ?"q" or ?"quit":
dbgState = dbQuiting dbgState = dbQuiting
dbgAborting = True dbgAborting = true
again = false again = false
quit(1) # BUGFIX: quit with error code > 0 quit(1) # BUGFIX: quit with error code > 0
elif ?"e" or ?"eval": elif ?"e" or ?"eval":
@ -402,9 +402,9 @@ proc commandPrompt() =
elif ?"w" or ?"where": elif ?"w" or ?"where":
dbgShowExecutionPoint() dbgShowExecutionPoint()
elif ?"l" or ?"locals": elif ?"l" or ?"locals":
ListLocals(stdout, dbgFramePtr) listLocals(stdout, dbgFramePtr)
elif ?"g" or ?"globals": elif ?"g" or ?"globals":
ListGlobals(stdout) listGlobals(stdout)
elif ?"u" or ?"up": elif ?"u" or ?"up":
if dbgDown <= 0: if dbgDown <= 0:
debugOut("[Warning] cannot go up any further ") debugOut("[Warning] cannot go up any further ")

View file

@ -326,7 +326,7 @@ when not defined(noSignalHandler):
template asgn(y: expr) = msg = y template asgn(y: expr) = msg = y
processSignal(sig, asgn) processSignal(sig, asgn)
showErrorMessage(msg) showErrorMessage(msg)
when defined(endb): dbgAborting = True when defined(endb): dbgAborting = true
quit(1) # always quit when SIGABRT quit(1) # always quit when SIGABRT
proc registerSignalHandler() = proc registerSignalHandler() =