DebugClients/Python/DebugBase.py

changeset 2171
c7dd548d67d8
parent 2166
15b4e58d61d7
child 2302
f29e9405c851
equal deleted inserted replaced
2170:f4e0f6133ace 2171:c7dd548d67d8
13 import types 13 import types
14 import atexit 14 import atexit
15 import inspect 15 import inspect
16 16
17 from DebugProtocol import ResponseClearWatch, ResponseClearBreak, ResponseLine, \ 17 from DebugProtocol import ResponseClearWatch, ResponseClearBreak, ResponseLine, \
18 ResponseSyntax, ResponseException 18 ResponseSyntax, ResponseException, CallTrace
19 19
20 gRecursionLimit = 64 20 gRecursionLimit = 64
21 21
22 22
23 def printerr(s): 23 def printerr(s):
152 @param arg The arguments 152 @param arg The arguments
153 """ 153 """
154 if event == 'return': 154 if event == 'return':
155 self.cFrame = frame.f_back 155 self.cFrame = frame.f_back
156 self.__recursionDepth -= 1 156 self.__recursionDepth -= 1
157 self.__sendCallTrace(event, frame, self.cFrame)
157 elif event == 'call': 158 elif event == 'call':
159 self.__sendCallTrace(event, self.cFrame, frame)
158 self.cFrame = frame 160 self.cFrame = frame
159 self.__recursionDepth += 1 161 self.__recursionDepth += 1
160 if self.__recursionDepth > gRecursionLimit: 162 if self.__recursionDepth > gRecursionLimit:
161 raise RuntimeError('maximum recursion depth exceeded\n' 163 raise RuntimeError('maximum recursion depth exceeded\n'
162 '(offending frame is two down the stack)') 164 '(offending frame is two down the stack)')
165
166 def __sendCallTrace(self, event, fromFrame, toFrame):
167 """
168 Private method to send a call/return trace.
169
170 @param event trace event (string)
171 @param fromFrame originating frame (frame)
172 @param toFrame destination frame (frame)
173 """
174 if self._dbgClient.callTraceEnabled:
175 if not self.__skip_it(fromFrame) and not self.__skip_it(toFrame):
176 if event in ["call", "return"]:
177 fr = fromFrame
178 fromStr = "%s:%s:%s" % (
179 self._dbgClient.absPath(self.fix_frame_filename(fr)),
180 fr.f_lineno,
181 fr.f_code.co_name)
182 fr = toFrame
183 toStr = "%s:%s:%s" % (
184 self._dbgClient.absPath(self.fix_frame_filename(fr)),
185 fr.f_lineno,
186 fr.f_code.co_name)
187 self._dbgClient.write("%s%s@@%s@@%s\n" % (
188 CallTrace, event[0], fromStr, toStr))
163 189
164 def trace_dispatch(self, frame, event, arg): 190 def trace_dispatch(self, frame, event, arg):
165 """ 191 """
166 Reimplemented from bdb.py to do some special things. 192 Reimplemented from bdb.py to do some special things.
167 193
698 debugger that are called from the application being debugged. 724 debugger that are called from the application being debugged.
699 725
700 @param frame the frame object 726 @param frame the frame object
701 @return flag indicating whether the debugger should skip this frame 727 @return flag indicating whether the debugger should skip this frame
702 """ 728 """
729 if frame is None:
730 return 1
731
703 fn = self.fix_frame_filename(frame) 732 fn = self.fix_frame_filename(frame)
704 733
705 # Eliminate things like <string> and <stdin>. 734 # Eliminate things like <string> and <stdin>.
706 if fn[0] == '<': 735 if fn[0] == '<':
707 return 1 736 return 1

eric ide

mercurial