DebugClients/Python/DebugBase.py

branch
debugger speed
changeset 5045
50862a6a2c63
parent 5044
630b9f290a77
child 5046
d57f18f15f1a
equal deleted inserted replaced
5044:630b9f290a77 5045:50862a6a2c63
276 # (CT) Note that this may also be None! 276 # (CT) Note that this may also be None!
277 self.botframe = frame.f_back 277 self.botframe = frame.f_back
278 return self.trace_dispatch 278 return self.trace_dispatch
279 279
280 if not (self.stop_here(frame) or 280 if not (self.stop_here(frame) or
281 self.break_anywhere(frame) or 281 self.__checkBreakInFrame(frame) or
282 Watch.watches != []): 282 Watch.watches != []):
283 # No need to trace this function 283 # No need to trace this function
284 return 284 return
285 if self.quitting: 285 if self.quitting:
286 raise bdb.BdbQuit 286 raise bdb.BdbQuit
387 fixedName = frame.f_code.co_filename 387 fixedName = frame.f_code.co_filename
388 # update cache 388 # update cache
389 self._fnCache[fn] = fixedName 389 self._fnCache[fn] = fixedName
390 return fixedName 390 return fixedName
391 391
392 def __checkBreakInFrame(self, frame):
393 """
394 Private method to check if the function / method has a line number
395 which is a breakpoint.
396 @param frame the frame object
397 @type frame object
398 @return Flag indicating a function / method with breakpoint
399 @rtype bool
400 """
401 try:
402 return Breakpoint.breakInFrameCache[
403 frame.f_globals.get('__file__'),
404 frame.f_code.co_firstlineno]
405 except KeyError:
406 filename = self.fix_frame_filename(frame)
407 if filename not in Breakpoint.breakInFile:
408 Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'),
409 frame.f_code.co_firstlineno] = False
410 return False
411 lineNo = frame.f_code.co_firstlineno
412 lineNumbers = [lineNo]
413 # No need to handle special case if a lot of lines between
414 # (e.g. closure), because the additional lines won't cause a bp
415 for co_lno in frame.f_code.co_lnotab[1::2]:
416 lineNo += ord(co_lno)
417 lineNumbers.append(lineNo)
418
419 for bp in Breakpoint.breakInFile[filename]:
420 if bp in lineNumbers:
421 Breakpoint.breakInFrameCache[
422 frame.f_globals.get('__file__'),
423 frame.f_code.co_firstlineno] = True
424 return True
425 Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'),
426 frame.f_code.co_firstlineno] = False
427 return False
428
392 def break_here(self, frame): 429 def break_here(self, frame):
393 """ 430 """
394 Public method reimplemented from bdb.py to fix the filename from the 431 Public method reimplemented from bdb.py to fix the filename from the
395 frame. 432 frame.
396 433
418 if flag and bp.temporary: 455 if flag and bp.temporary:
419 self.__do_clearWatch(bp.cond) 456 self.__do_clearWatch(bp.cond)
420 return True 457 return True
421 458
422 return False 459 return False
423
424 def break_anywhere(self, frame):
425 """
426 Public method reimplemented from bdb.py to do some special things.
427
428 These speciality is to fix the filename from the frame
429 (see fix_frame_filename for more info).
430
431 @param frame the frame object
432 @type frame object
433 @return flag indicating the break status
434 @rtype bool
435 """
436 return self.fix_frame_filename(frame) in Breakpoint.breakInFile
437 460
438 def __do_clearBreak(self, filename, lineno): 461 def __do_clearBreak(self, filename, lineno):
439 """ 462 """
440 Private method called to clear a temporary breakpoint. 463 Private method called to clear a temporary breakpoint.
441 464

eric ide

mercurial