DebugClients/Python/DebugClientBase.py

branch
debugger speed
changeset 5207
7283629b02c0
parent 5206
997064ba25d6
child 5221
960afd19c1b6
equal deleted inserted replaced
5206:997064ba25d6 5207:7283629b02c0
186 Constructor 186 Constructor
187 """ 187 """
188 self.breakpoints = {} 188 self.breakpoints = {}
189 self.redirect = True 189 self.redirect = True
190 self.__receiveBuffer = "" 190 self.__receiveBuffer = ""
191
192 # The next couple of members are needed for the threaded version.
193 # For this base class they contain static values for the non threaded
194 # debugger
195
196 # dictionary of all threads running
197 self.threads = {}
198
199 # the "current" thread, basically the thread we are at a breakpoint
200 # for.
201 self.currentThread = self
202 191
203 # special objects representing the main scripts thread and frame 192 # special objects representing the main scripts thread and frame
204 self.mainThread = self 193 self.mainThread = self
205 self.framenr = 0 194 self.framenr = 0
206 195
276 m = self.coding_re.search(line) 265 m = self.coding_re.search(line)
277 if m: 266 if m:
278 self.__coding = m.group(1) 267 self.__coding = m.group(1)
279 return 268 return
280 self.__coding = default 269 self.__coding = default
281 270
282 def attachThread(self, target=None, args=None, kwargs=None,
283 mainThread=False):
284 """
285 Public method to setup a thread for DebugClient to debug.
286
287 If mainThread is True, then we are attaching to the already
288 started mainthread of the app and the rest of the args are ignored.
289
290 @param target the start function of the target thread (i.e. the user
291 code)
292 @param args arguments to pass to target
293 @param kwargs keyword arguments to pass to target
294 @param mainThread True, if we are attaching to the already
295 started mainthread of the app
296 """
297 pass
298
299 def __dumpThreadList(self):
300 """
301 Private method to send the list of threads.
302 """
303 threadList = []
304 if self.threads and self.currentThread:
305 # indication for the threaded debugger
306 currentId = self.currentThread.get_ident()
307 for t in self.threads.values():
308 d = {}
309 d["id"] = t.get_ident()
310 d["name"] = t.get_name()
311 d["broken"] = t.isBroken
312 threadList.append(d)
313 else:
314 currentId = -1
315 d = {}
316 d["id"] = -1
317 d["name"] = "MainThread"
318 if hasattr(self, "isBroken"):
319 d["broken"] = self.isBroken
320 else:
321 d["broken"] = False
322 threadList.append(d)
323
324 self.sendJsonCommand("ResponseThreadList", {
325 "currentID": currentId,
326 "threadList": threadList,
327 })
328
329 def raw_input(self, prompt, echo): 271 def raw_input(self, prompt, echo):
330 """ 272 """
331 Public method to implement raw_input() / input() using the event loop. 273 Public method to implement raw_input() / input() using the event loop.
332 274
333 @param prompt the prompt to be shown (string) 275 @param prompt the prompt to be shown (string)
456 self.__dumpVariable( 398 self.__dumpVariable(
457 params["variable"], params["frameNumber"], 399 params["variable"], params["frameNumber"],
458 params["scope"], params["filters"]) 400 params["scope"], params["filters"])
459 401
460 elif method == "RequestThreadList": 402 elif method == "RequestThreadList":
461 self.__dumpThreadList() 403 self.dumpThreadList()
462 404
463 elif method == "RequestThreadSet": 405 elif method == "RequestThreadSet":
464 if params["threadID"] in self.threads: 406 if params["threadID"] in self.threads:
465 self.setCurrentThread(params["threadID"]) 407 self.setCurrentThread(params["threadID"])
466 self.sendJsonCommand("ResponseThreadSet", {}) 408 self.sendJsonCommand("ResponseThreadSet", {})

eric ide

mercurial