use a bloom filter to speed up the debugger
This commit is contained in:
parent
a64d4dc35c
commit
5ac5bedc66
1 changed files with 8 additions and 11 deletions
|
|
@ -56,7 +56,7 @@ var
|
||||||
dbgState: TDbgState # state of debugger
|
dbgState: TDbgState # state of debugger
|
||||||
dbgBP: array[0..127, TDbgBreakpoint] # breakpoints
|
dbgBP: array[0..127, TDbgBreakpoint] # breakpoints
|
||||||
dbgBPlen: int
|
dbgBPlen: int
|
||||||
|
dbgBPbloom: int64 # we use a bloom filter to speed up breakpoint checking
|
||||||
dbgSkipToFrame: PFrame # frame to be skipped to
|
dbgSkipToFrame: PFrame # frame to be skipped to
|
||||||
|
|
||||||
dbgGlobalData: TExtendedFrame # this reserves much space, but
|
dbgGlobalData: TExtendedFrame # this reserves much space, but
|
||||||
|
|
@ -320,6 +320,7 @@ proc setBreakPoint(s: cstring, start: int) =
|
||||||
i = scanNumber(s, dbgBP[x].high, i)
|
i = scanNumber(s, dbgBP[x].high, i)
|
||||||
if dbgBP[x].high == 0: # set to low:
|
if dbgBP[x].high == 0: # set to low:
|
||||||
dbgBP[x].high = dbgBP[x].low
|
dbgBP[x].high = dbgBP[x].low
|
||||||
|
for line in dbgBP[x].low .. dbgBP[x].high: dbgBPbloom = dbgBPbloom or line
|
||||||
i = scanFilename(s, dbgTemp, i)
|
i = scanFilename(s, dbgTemp, i)
|
||||||
if dbgTemp.len != 0:
|
if dbgTemp.len != 0:
|
||||||
debugOut("[Warning] explicit filename for breakpoint not supported")
|
debugOut("[Warning] explicit filename for breakpoint not supported")
|
||||||
|
|
@ -506,8 +507,9 @@ proc endbStep() =
|
||||||
dbgShowExecutionPoint()
|
dbgShowExecutionPoint()
|
||||||
CommandPrompt()
|
CommandPrompt()
|
||||||
|
|
||||||
proc checkForBreakpoint() =
|
proc checkForBreakpoint(line: int) =
|
||||||
let i = dbgBreakpointReached(framePtr.line)
|
if (dbgBPbloom and line) != line: return
|
||||||
|
let i = dbgBreakpointReached(line)
|
||||||
if i >= 0:
|
if i >= 0:
|
||||||
write(stdout, "*** endb| reached ")
|
write(stdout, "*** endb| reached ")
|
||||||
write(stdout, dbgBP[i].name)
|
write(stdout, dbgBP[i].name)
|
||||||
|
|
@ -533,6 +535,7 @@ proc dbgRegisterBreakpoint(line: int,
|
||||||
dbgBP[x].filename = filename
|
dbgBP[x].filename = filename
|
||||||
dbgBP[x].low = line
|
dbgBP[x].low = line
|
||||||
dbgBP[x].high = line
|
dbgBP[x].high = line
|
||||||
|
dbgBPbloom = dbgBPbloom or line
|
||||||
|
|
||||||
proc dbgRegisterGlobal(name: cstring, address: pointer,
|
proc dbgRegisterGlobal(name: cstring, address: pointer,
|
||||||
typ: PNimType) {.compilerproc.} =
|
typ: PNimType) {.compilerproc.} =
|
||||||
|
|
@ -647,10 +650,6 @@ proc genericHashAux(dest: Pointer, mt: PNimType, shallow: bool,
|
||||||
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)
|
||||||
# hash the object header:
|
|
||||||
#const headerSize = sizeof(int)*2
|
|
||||||
#result = result !& hash(cast[pointer](cast[int](s) -% headerSize),
|
|
||||||
# headerSize)
|
|
||||||
else:
|
else:
|
||||||
result = h !& hash(dest, mt.size) # hash raw bits
|
result = h !& hash(dest, mt.size) # hash raw bits
|
||||||
|
|
||||||
|
|
@ -748,8 +747,6 @@ proc endb(line: int, file: cstring) {.compilerproc.} =
|
||||||
# Check if we are at an enabled breakpoint or "in the mood"
|
# Check if we are at an enabled breakpoint or "in the mood"
|
||||||
if framePtr == nil: return
|
if framePtr == nil: return
|
||||||
let oldState = dbgState
|
let oldState = dbgState
|
||||||
#dbgState = dbOff
|
|
||||||
#if oldState != dbOff:
|
|
||||||
checkWatchpoints()
|
checkWatchpoints()
|
||||||
framePtr.line = line # this is done here for smaller code size!
|
framePtr.line = line # this is done here for smaller code size!
|
||||||
framePtr.filename = file
|
framePtr.filename = file
|
||||||
|
|
@ -764,10 +761,10 @@ proc endb(line: int, file: cstring) {.compilerproc.} =
|
||||||
dbgShowExecutionPoint()
|
dbgShowExecutionPoint()
|
||||||
CommandPrompt()
|
CommandPrompt()
|
||||||
else: # breakpoints are wanted though (I guess)
|
else: # breakpoints are wanted though (I guess)
|
||||||
checkForBreakpoint()
|
checkForBreakpoint(line)
|
||||||
of dbBreakpoints:
|
of dbBreakpoints:
|
||||||
# debugger is only interested in breakpoints
|
# debugger is only interested in breakpoints
|
||||||
checkForBreakpoint()
|
checkForBreakpoint(line)
|
||||||
else: nil
|
else: nil
|
||||||
|
|
||||||
proc initDebugger {.inline.} =
|
proc initDebugger {.inline.} =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue