42 """ |
41 """ |
43 global gRecursionLimit |
42 global gRecursionLimit |
44 gRecursionLimit = limit |
43 gRecursionLimit = limit |
45 |
44 |
46 |
45 |
47 class DebugBase(bdb.Bdb): |
46 class DebugBase(object): |
48 """ |
47 """ |
49 Class implementing base class of the debugger. |
48 Class implementing base class of the debugger. |
50 |
49 |
51 Provides simple wrapper methods around bdb for the 'owning' client to |
50 Provides methods for the 'owning' client to call to step etc. |
52 call to step etc. |
|
53 """ |
51 """ |
54 # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch |
52 # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch |
55 # on Windows |
53 # on Windows |
56 lib = os.path.dirname(bdb.__file__) |
54 lib = os.path.dirname(inspect.__file__) |
57 # tuple required because it's accessed a lot of times by startswith method |
55 # tuple required because it's accessed a lot of times by startswith method |
58 pathsToSkip = ('<', os.path.dirname(__file__), bdb.__file__[:-1]) |
56 pathsToSkip = ('<', os.path.dirname(__file__), inspect.__file__[:-1]) |
59 filesToSkip = {} |
57 filesToSkip = {} |
60 |
58 |
61 # cache for fixed file names |
59 # cache for fixed file names |
62 _fnCache = {} |
60 _fnCache = {} |
63 |
61 |
94 |
90 |
95 # provide a hook to perform a hard breakpoint |
91 # provide a hook to perform a hard breakpoint |
96 # Use it like this: |
92 # Use it like this: |
97 # if hasattr(sys, 'breakpoint): sys.breakpoint() |
93 # if hasattr(sys, 'breakpoint): sys.breakpoint() |
98 sys.breakpoint = self.set_trace |
94 sys.breakpoint = self.set_trace |
99 |
|
100 # initialize parent |
|
101 bdb.Bdb.reset(self) |
|
102 |
95 |
103 self.__recursionDepth = -1 |
96 self.__recursionDepth = -1 |
104 self.setRecursionDepth(inspect.currentframe()) |
97 self.setRecursionDepth(inspect.currentframe()) |
105 |
98 |
106 # background task to periodicaly check for client interactions |
99 # background task to periodicaly check for client interactions |
432 Public method to stop after one line of code. |
425 Public method to stop after one line of code. |
433 """ |
426 """ |
434 self._set_stopinfo(None, None) |
427 self._set_stopinfo(None, None) |
435 self.stop_everywhere = True |
428 self.stop_everywhere = True |
436 |
429 |
|
430 def set_next(self, frame): |
|
431 """ |
|
432 Public method to stop on the next line in or below the given frame. |
|
433 |
|
434 @param frame the frame object |
|
435 @type frame object |
|
436 """ |
|
437 self._set_stopinfo(frame, frame.f_back) |
|
438 frame.f_back.f_trace = self.trace_dispatch |
|
439 frame.f_trace = self.trace_dispatch |
|
440 |
|
441 def set_return(self, frame): |
|
442 """ |
|
443 Public method to stop when returning from the given frame. |
|
444 |
|
445 @param frame the frame object |
|
446 @type frame object |
|
447 """ |
|
448 self._set_stopinfo(None, frame.f_back) |
|
449 |
437 def set_quit(self): |
450 def set_quit(self): |
438 """ |
451 """ |
439 Public method to quit. |
452 Public method to quit. |
440 |
453 |
441 It wraps call to bdb to clear the current frame properly. |
454 Disables the trace functions and resets all frame pointer. |
442 """ |
455 """ |
443 self.currentFrame = None |
456 self.currentFrame = None |
444 sys.setprofile(None) |
457 sys.setprofile(None) |
445 bdb.Bdb.set_quit(self) |
458 sys.settrace(None) |
|
459 self.stopframe = None |
|
460 self.returnframe = None |
|
461 self.quitting = 1 |
446 |
462 |
447 def fix_frame_filename(self, frame): |
463 def fix_frame_filename(self, frame): |
448 """ |
464 """ |
449 Public method used to fixup the filename for a given frame. |
465 Public method used to fixup the filename for a given frame. |
450 |
466 |
770 self.currentFrame = frlist[0] |
786 self.currentFrame = frlist[0] |
771 |
787 |
772 for fr in frlist[self.skipFrames:]: |
788 for fr in frlist[self.skipFrames:]: |
773 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
789 filename = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
774 |
790 |
775 if os.path.basename(filename).startswith("DebugClient") or \ |
791 if os.path.basename(filename).startswith("DebugClientBase"): |
776 os.path.basename(filename) == "bdb.py": |
|
777 break |
792 break |
778 |
793 |
779 linenr = fr.f_lineno |
794 linenr = fr.f_lineno |
780 ffunc = fr.f_code.co_name |
795 ffunc = fr.f_code.co_name |
781 |
796 |