68 This function works with the split debugger. |
68 This function works with the split debugger. |
69 |
69 |
70 @param prompt prompt to be shown (string) |
70 @param prompt prompt to be shown (string) |
71 @return result of the input() call |
71 @return result of the input() call |
72 """ |
72 """ |
73 if DebugClientInstance is None or DebugClientInstance.redirect == 0: |
73 if DebugClientInstance is None or not DebugClientInstance.redirect: |
74 return DebugClientOrigInput(prompt) |
74 return DebugClientOrigInput(prompt) |
75 |
75 |
76 return DebugClientInstance.input(prompt) |
76 return DebugClientInstance.input(prompt) |
77 |
77 |
78 # Use our own input(). |
78 # Use our own input(). |
177 # debugger |
177 # debugger |
178 |
178 |
179 # dictionary of all threads running |
179 # dictionary of all threads running |
180 self.threads = {} |
180 self.threads = {} |
181 |
181 |
182 # the "current" thread, basically the thread we are at a |
182 # the "current" thread, basically the thread we are at a breakpoint |
183 # breakpoint for. |
183 # for. |
184 self.currentThread = self |
184 self.currentThread = self |
185 |
185 |
186 # special objects representing the main scripts thread and frame |
186 # special objects representing the main scripts thread and frame |
187 self.mainThread = self |
187 self.mainThread = self |
188 self.mainFrame = None |
188 self.mainFrame = None |
223 self.variant = 'You should not see this' |
223 self.variant = 'You should not see this' |
224 |
224 |
225 # commandline completion stuff |
225 # commandline completion stuff |
226 self.complete = Completer(self.debugMod.__dict__).complete |
226 self.complete = Completer(self.debugMod.__dict__).complete |
227 |
227 |
228 if sys.hexversion < 0x2020000: |
228 self.compile_command = codeop.CommandCompiler() |
229 self.compile_command = codeop.compile_command |
|
230 else: |
|
231 self.compile_command = codeop.CommandCompiler() |
|
232 |
229 |
233 self.coding_re = re.compile(r"coding[:=]\s*([-\w_.]+)") |
230 self.coding_re = re.compile(r"coding[:=]\s*([-\w_.]+)") |
234 self.defaultCoding = 'utf-8' |
231 self.defaultCoding = 'utf-8' |
235 self.__coding = self.defaultCoding |
232 self.__coding = self.defaultCoding |
236 self.noencoding = False |
233 self.noencoding = False |
268 if m: |
265 if m: |
269 self.__coding = m.group(1) |
266 self.__coding = m.group(1) |
270 return |
267 return |
271 self.__coding = default |
268 self.__coding = default |
272 |
269 |
273 def attachThread(self, target=None, args=None, kwargs=None, mainThread=0): |
270 def attachThread(self, target=None, args=None, kwargs=None, |
|
271 mainThread=False): |
274 """ |
272 """ |
275 Public method to setup a thread for DebugClient to debug. |
273 Public method to setup a thread for DebugClient to debug. |
276 |
274 |
277 If mainThread is non-zero, then we are attaching to the already |
275 If mainThread is True, then we are attaching to the already |
278 started mainthread of the app and the rest of the args are ignored. |
276 started mainthread of the app and the rest of the args are ignored. |
279 |
|
280 This is just an empty function and is overridden in the threaded |
|
281 debugger. |
|
282 |
277 |
283 @param target the start function of the target thread (i.e. the user |
278 @param target the start function of the target thread (i.e. the user |
284 code) |
279 code) |
285 @param args arguments to pass to target |
280 @param args arguments to pass to target |
286 @param kwargs keyword arguments to pass to target |
281 @param kwargs keyword arguments to pass to target |
287 @param mainThread non-zero, if we are attaching to the already |
282 @param mainThread True, if we are attaching to the already |
288 started mainthread of the app |
283 started mainthread of the app |
289 """ |
284 """ |
290 if self.debugging: |
285 if self.debugging: |
291 sys.setprofile(self.profile) |
286 sys.setprofile(self.profile) |
292 |
287 |
1358 Private method to return the variables of a frame to the debug server. |
1353 Private method to return the variables of a frame to the debug server. |
1359 |
1354 |
1360 @param frmnr distance of frame reported on. 0 is the current frame |
1355 @param frmnr distance of frame reported on. 0 is the current frame |
1361 (int) |
1356 (int) |
1362 @param scope 1 to report global variables, 0 for local variables (int) |
1357 @param scope 1 to report global variables, 0 for local variables (int) |
1363 @param filter the indices of variable types to be filtered (list of |
1358 @param filter the indices of variable types to be filtered |
1364 int) |
1359 (list of int) |
1365 """ |
1360 """ |
1366 if self.currentThread is None: |
1361 if self.currentThread is None: |
1367 return |
1362 return |
1368 |
1363 |
1369 if scope == 0: |
1364 if scope == 0: |
2059 |
2054 |
2060 self.passive = True |
2055 self.passive = True |
2061 self.sendPassiveStartup(self.running, exceptions) |
2056 self.sendPassiveStartup(self.running, exceptions) |
2062 self.__interact() |
2057 self.__interact() |
2063 |
2058 |
2064 self.attachThread(mainThread=1) |
2059 self.attachThread(mainThread=True) |
2065 self.mainThread.tracePython = tracePython |
2060 self.mainThread.tracePython = tracePython |
2066 |
2061 |
2067 # set the system exception handling function to ensure, that |
2062 # set the system exception handling function to ensure, that |
2068 # we report on all unhandled exceptions |
2063 # we report on all unhandled exceptions |
2069 sys.excepthook = self.__unhandled_exception |
2064 sys.excepthook = self.__unhandled_exception |
2087 @param scriptname name of the script to be debugged (string) |
2082 @param scriptname name of the script to be debugged (string) |
2088 @param func function to be called |
2083 @param func function to be called |
2089 @param *args arguments being passed to func |
2084 @param *args arguments being passed to func |
2090 @return result of the function call |
2085 @return result of the function call |
2091 """ |
2086 """ |
2092 self.startDebugger(scriptname, enableTrace=0) |
2087 self.startDebugger(scriptname, enableTrace=False) |
2093 res = self.mainThread.runcall(func, *args) |
2088 res = self.mainThread.runcall(func, *args) |
2094 self.progTerminated(res) |
2089 self.progTerminated(res) |
2095 return res |
2090 return res |
2096 |
2091 |
2097 def __resolveHost(self, host): |
2092 def __resolveHost(self, host): |
2206 else: |
2201 else: |
2207 print "No network port given. Aborting..." # __IGNORE_WARNING__ |
2202 print "No network port given. Aborting..." # __IGNORE_WARNING__ |
2208 |
2203 |
2209 def fork(self): |
2204 def fork(self): |
2210 """ |
2205 """ |
2211 Public method implementing a fork routine deciding which branch to |
2206 Public method implementing a fork routine deciding which branch |
2212 follow. |
2207 to follow. |
2213 |
2208 |
2214 @return process ID (integer) |
2209 @return process ID (integer) |
2215 """ |
2210 """ |
2216 if not self.fork_auto: |
2211 if not self.fork_auto: |
2217 self.sendJsonCommand("RequestForkTo", {}) |
2212 self.sendJsonCommand("RequestForkTo", {}) |