43 """ |
42 """ |
44 global gRecursionLimit |
43 global gRecursionLimit |
45 gRecursionLimit = limit |
44 gRecursionLimit = limit |
46 |
45 |
47 |
46 |
48 class DebugBase(bdb.Bdb): |
47 class DebugBase(object): |
49 """ |
48 """ |
50 Class implementing base class of the debugger. |
49 Class implementing base class of the debugger. |
51 |
50 |
52 Provides simple wrapper methods around bdb for the 'owning' client to |
51 Provides methods for the 'owning' client to call to step etc. |
53 call to step etc. |
|
54 """ |
52 """ |
55 # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch |
53 # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch |
56 # on Windows |
54 # on Windows |
57 lib = os.path.dirname(bdb.__file__) |
55 lib = os.path.dirname(inspect.__file__) |
58 # tuple required because it's accessed a lot of times by startswith method |
56 # tuple required because it's accessed a lot of times by startswith method |
59 pathsToSkip = ('<', os.path.dirname(__file__), bdb.__file__[:-1]) |
57 pathsToSkip = ('<', os.path.dirname(__file__), inspect.__file__[:-1]) |
60 filesToSkip = {} |
58 filesToSkip = {} |
61 |
59 |
62 # cache for fixed file names |
60 # cache for fixed file names |
63 _fnCache = {} |
61 _fnCache = {} |
64 |
62 |
95 |
91 |
96 # provide a hook to perform a hard breakpoint |
92 # provide a hook to perform a hard breakpoint |
97 # Use it like this: |
93 # Use it like this: |
98 # if hasattr(sys, 'breakpoint): sys.breakpoint() |
94 # if hasattr(sys, 'breakpoint): sys.breakpoint() |
99 sys.breakpoint = self.set_trace |
95 sys.breakpoint = self.set_trace |
100 |
|
101 # initialize parent |
|
102 bdb.Bdb.reset(self) |
|
103 |
96 |
104 self.__recursionDepth = -1 |
97 self.__recursionDepth = -1 |
105 self.setRecursionDepth(inspect.currentframe()) |
98 self.setRecursionDepth(inspect.currentframe()) |
106 |
99 |
107 # background task to periodicaly check for client interactions |
100 # background task to periodicaly check for client interactions |
450 Public method to stop after one line of code. |
443 Public method to stop after one line of code. |
451 """ |
444 """ |
452 self._set_stopinfo(None, None) |
445 self._set_stopinfo(None, None) |
453 self.stop_everywhere = True |
446 self.stop_everywhere = True |
454 |
447 |
|
448 def set_next(self, frame): |
|
449 """ |
|
450 Public method to stop on the next line in or below the given frame. |
|
451 |
|
452 @param frame the frame object |
|
453 @type frame object |
|
454 """ |
|
455 self._set_stopinfo(frame, frame.f_back) |
|
456 frame.f_back.f_trace = self.trace_dispatch |
|
457 frame.f_trace = self.trace_dispatch |
|
458 |
|
459 def set_return(self, frame): |
|
460 """ |
|
461 Public method to stop when returning from the given frame. |
|
462 |
|
463 @param frame the frame object |
|
464 @type frame object |
|
465 """ |
|
466 self._set_stopinfo(None, frame.f_back) |
|
467 |
455 def set_quit(self): |
468 def set_quit(self): |
456 """ |
469 """ |
457 Public method to quit. |
470 Public method to quit. |
458 |
471 |
459 It wraps call to bdb to clear the current frame properly. |
472 Disables the trace functions and resets all frame pointer. |
460 """ |
473 """ |
461 self.currentFrame = None |
474 self.currentFrame = None |
462 sys.setprofile(None) |
475 sys.setprofile(None) |
463 bdb.Bdb.set_quit(self) |
476 sys.settrace(None) |
|
477 self.stopframe = None |
|
478 self.returnframe = None |
|
479 self.quitting = 1 |
464 |
480 |
465 def fix_frame_filename(self, frame): |
481 def fix_frame_filename(self, frame): |
466 """ |
482 """ |
467 Public method used to fixup the filename for a given frame. |
483 Public method used to fixup the filename for a given frame. |
468 |
484 |
794 self.currentFrame = frlist[0] |
810 self.currentFrame = frlist[0] |
795 |
811 |
796 for fr in frlist[self.skipFrames:]: |
812 for fr in frlist[self.skipFrames:]: |
797 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
813 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
798 |
814 |
799 if os.path.basename(filename).startswith("DebugClient") or \ |
815 if os.path.basename(filename).startswith("DebugClientBase"): |
800 os.path.basename(filename) == "bdb.py": |
|
801 break |
816 break |
802 |
817 |
803 linenr = fr.f_lineno |
818 linenr = fr.f_lineno |
804 ffunc = fr.f_code.co_name |
819 ffunc = fr.f_code.co_name |
805 |
820 |