277 # (CT) Note that this may also be None! |
277 # (CT) Note that this may also be None! |
278 self.botframe = frame.f_back |
278 self.botframe = frame.f_back |
279 return self.trace_dispatch |
279 return self.trace_dispatch |
280 |
280 |
281 if not (self.stop_here(frame) or |
281 if not (self.stop_here(frame) or |
282 self.break_anywhere(frame) or |
282 self.__checkBreakInFrame(frame) or |
283 Watch.watches != []): |
283 Watch.watches != []): |
284 # No need to trace this function |
284 # No need to trace this function |
285 return |
285 return |
286 if self.quitting: |
286 if self.quitting: |
287 raise bdb.BdbQuit |
287 raise bdb.BdbQuit |
407 fixedName = frame.f_code.co_filename |
407 fixedName = frame.f_code.co_filename |
408 # update cache |
408 # update cache |
409 self._fnCache[fn] = fixedName |
409 self._fnCache[fn] = fixedName |
410 return fixedName |
410 return fixedName |
411 |
411 |
|
412 def __checkBreakInFrame(self, frame): |
|
413 """ |
|
414 Private method to check if the function / method has a line number |
|
415 which is a breakpoint. |
|
416 @param frame the frame object |
|
417 @type frame object |
|
418 @return Flag indicating a function / method with breakpoint |
|
419 @rtype bool |
|
420 """ |
|
421 try: |
|
422 return Breakpoint.breakInFrameCache[ |
|
423 frame.f_globals.get('__file__'), |
|
424 frame.f_code.co_firstlineno] |
|
425 except KeyError: |
|
426 filename = self.fix_frame_filename(frame) |
|
427 if filename not in Breakpoint.breakInFile: |
|
428 Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'), |
|
429 frame.f_code.co_firstlineno] = False |
|
430 return False |
|
431 lineNo = frame.f_code.co_firstlineno |
|
432 lineNumbers = [lineNo] |
|
433 # No need to handle special case if a lot of lines between |
|
434 # (e.g. closure), because the additional lines won't cause a bp |
|
435 for co_lno in frame.f_code.co_lnotab[1::2]: |
|
436 lineNo += co_lno |
|
437 lineNumbers.append(lineNo) |
|
438 |
|
439 for bp in Breakpoint.breakInFile[filename]: |
|
440 if bp in lineNumbers: |
|
441 Breakpoint.breakInFrameCache[ |
|
442 frame.f_globals.get('__file__'), |
|
443 frame.f_code.co_firstlineno] = True |
|
444 return True |
|
445 Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'), |
|
446 frame.f_code.co_firstlineno] = False |
|
447 return False |
|
448 |
412 def break_here(self, frame): |
449 def break_here(self, frame): |
413 """ |
450 """ |
414 Public method reimplemented from bdb.py to fix the filename from the |
451 Public method reimplemented from bdb.py to fix the filename from the |
415 frame. |
452 frame. |
416 |
453 |
438 if flag and bp.temporary: |
475 if flag and bp.temporary: |
439 self.__do_clearWatch(bp.cond) |
476 self.__do_clearWatch(bp.cond) |
440 return True |
477 return True |
441 |
478 |
442 return False |
479 return False |
443 |
|
444 def break_anywhere(self, frame): |
|
445 """ |
|
446 Public method reimplemented from bdb.py to do some special things. |
|
447 |
|
448 These speciality is to fix the filename from the frame |
|
449 (see fix_frame_filename for more info). |
|
450 |
|
451 @param frame the frame object |
|
452 @param frame object |
|
453 @return flag indicating the break status |
|
454 @rtype bool |
|
455 """ |
|
456 return self.fix_frame_filename(frame) in Breakpoint.breakInFile |
|
457 |
480 |
458 def __do_clearBreak(self, filename, lineno): |
481 def __do_clearBreak(self, filename, lineno): |
459 """ |
482 """ |
460 Private method called to clear a temporary breakpoint. |
483 Private method called to clear a temporary breakpoint. |
461 |
484 |