230 |
229 |
231 This specialty is to check the connection to the debug server |
230 This specialty is to check the connection to the debug server |
232 for new events (i.e. new breakpoints) while we are going through |
231 for new events (i.e. new breakpoints) while we are going through |
233 the code. |
232 the code. |
234 |
233 |
235 @param frame The current stack frame. |
234 @param frame The current stack frame |
236 @param event The trace event (string) |
235 @type frame object |
|
236 @param event The trace event |
|
237 @type str |
237 @param arg The arguments |
238 @param arg The arguments |
|
239 @type depends on the previous event parameter |
238 @return local trace function |
240 @return local trace function |
|
241 @rtype trace function or None |
|
242 @exception bdb.BdbQuit |
239 """ |
243 """ |
240 if self.quitting: |
244 if self.quitting: |
241 return # None |
245 return # None |
242 |
246 |
243 # give the client a chance to push through new break points. |
247 # give the client a chance to push through new break points. |
244 self._dbgClient.eventPoll() |
248 self._dbgClient.eventPoll() |
245 |
249 |
246 self.__event == event |
|
247 self.__isBroken = False |
|
248 |
|
249 if event == 'line': |
250 if event == 'line': |
250 return self.dispatch_line(frame) |
251 if self.stop_here(frame) or self.break_here(frame): |
|
252 self.user_line(frame) |
|
253 if self.quitting: |
|
254 raise bdb.BdbQuit |
|
255 return |
|
256 |
251 if event == 'call': |
257 if event == 'call': |
252 return self.dispatch_call(frame, arg) |
258 if self.botframe is None: |
253 if event == 'return': |
259 # First call of dispatch since reset() |
254 return self.dispatch_return(frame, arg) |
260 # (CT) Note that this may also be None! |
255 if event == 'exception': |
261 self.botframe = frame.f_back |
256 return self.dispatch_exception(frame, arg) |
262 return self.trace_dispatch |
257 if event == 'c_call': |
263 |
258 return self.trace_dispatch |
264 if not (self.stop_here(frame) or self.break_anywhere(frame)): |
259 if event == 'c_exception': |
265 # No need to trace this function |
260 return self.trace_dispatch |
266 return |
261 if event == 'c_return': |
|
262 return self.trace_dispatch |
|
263 print 'DebugBase.trace_dispatch: unknown debugging event:', repr(event) # __IGNORE_WARNING__ |
|
264 return self.trace_dispatch |
|
265 |
|
266 def dispatch_line(self, frame): |
|
267 """ |
|
268 Public method reimplemented from bdb.py to do some special things. |
|
269 |
|
270 This speciality is to check the connection to the debug server |
|
271 for new events (i.e. new breakpoints) while we are going through |
|
272 the code. |
|
273 |
|
274 @param frame The current stack frame. |
|
275 @return local trace function |
|
276 @exception bdb.BdbQuit raised to indicate the end of the debug session |
|
277 """ |
|
278 if self.stop_here(frame) or self.break_here(frame): |
|
279 self.user_line(frame) |
|
280 if self.quitting: |
267 if self.quitting: |
281 raise bdb.BdbQuit |
268 raise bdb.BdbQuit |
282 return self.trace_dispatch |
269 return self.trace_dispatch |
283 |
270 |
284 def dispatch_return(self, frame, arg): |
271 if event == 'return': |
285 """ |
272 if self.stop_here(frame) or frame == self.returnframe: |
286 Public method reimplemented from bdb.py to handle passive mode cleanly. |
273 # The program has finished if we have just left the first frame |
287 |
274 if frame == self._dbgClient.mainFrame and \ |
288 @param frame The current stack frame. |
275 self._mainThread: |
289 @param arg The arguments |
276 atexit._run_exitfuncs() |
290 @return local trace function |
277 self._dbgClient.progTerminated(arg) |
291 @exception bdb.BdbQuit raised to indicate the end of the debug session |
278 elif frame is not self.stepFrame: |
292 """ |
279 self.stepFrame = None |
293 if self.stop_here(frame) or frame == self.returnframe: |
280 self.user_line(frame) |
294 self.user_return(frame, arg) |
281 |
295 if self.quitting and not self._dbgClient.passive: |
282 if self.quitting and not self._dbgClient.passive: |
296 raise bdb.BdbQuit |
283 raise bdb.BdbQuit |
297 return self.trace_dispatch |
284 return |
298 |
285 |
299 def dispatch_exception(self, frame, arg): |
286 if event == 'exception': |
300 """ |
287 if not self.__skipFrame(frame): |
301 Public method reimplemented from bdb.py to always call user_exception. |
288 self.user_exception(frame, arg) |
302 |
289 if self.quitting: |
303 @param frame The current stack frame. |
290 raise bdb.BdbQuit |
304 @param arg The arguments |
291 return |
305 @return local trace function |
292 |
306 @exception bdb.BdbQuit raised to indicate the end of the debug session |
293 if event == 'c_call': |
307 """ |
294 return |
308 if not self.__skipFrame(frame): |
295 if event == 'c_exception': |
309 self.user_exception(frame, arg) |
296 return |
310 if self.quitting: |
297 if event == 'c_return': |
311 raise bdb.BdbQuit |
298 return |
|
299 print 'DebugBase.trace_dispatch: unknown debugging event:', repr(event) # __IGNORE_WARNING__ |
312 return self.trace_dispatch |
300 return self.trace_dispatch |
313 |
301 |
314 def set_trace(self, frame=None): |
302 def set_trace(self, frame=None): |
315 """ |
303 """ |
316 Public method reimplemented from bdb.py to do some special setup. |
304 Public method reimplemented from bdb.py to do some special setup. |
830 stack.append(tb.tb_frame) |
820 stack.append(tb.tb_frame) |
831 tb = tb.tb_next |
821 tb = tb.tb_next |
832 tb = None |
822 tb = None |
833 return stack |
823 return stack |
834 |
824 |
835 def user_return(self, frame, retval): |
|
836 """ |
|
837 Public method reimplemented to report program termination to the debug |
|
838 server. |
|
839 |
|
840 @param frame the frame object |
|
841 @param retval the return value of the program |
|
842 """ |
|
843 # The program has finished if we have just left the first frame. |
|
844 if frame == self._dbgClient.mainFrame and \ |
|
845 self._mainThread: |
|
846 atexit._run_exitfuncs() |
|
847 self._dbgClient.progTerminated(retval) |
|
848 elif frame is not self.stepFrame: |
|
849 self.stepFrame = None |
|
850 self.user_line(frame) |
|
851 |
|
852 def stop_here(self, frame): |
825 def stop_here(self, frame): |
853 """ |
826 """ |
854 Public method reimplemented to filter out debugger files. |
827 Public method reimplemented to filter out debugger files. |
855 |
828 |
856 Tracing is turned off for files that are part of the |
829 Tracing is turned off for files that are part of the |