src/eric7/DebugClients/Python/DebugBase.py

branch
eric7
changeset 10417
c6011e501282
parent 10331
c1a2ff7e3575
child 10423
299802979277
equal deleted inserted replaced
10416:5d807e997391 10417:c6011e501282
35 def printerr(s): 35 def printerr(s):
36 """ 36 """
37 Module function used for debugging the debug client. 37 Module function used for debugging the debug client.
38 38
39 @param s data to be printed 39 @param s data to be printed
40 @type str
40 """ 41 """
41 sys.__stderr__.write("{0!s}\n".format(s)) 42 sys.__stderr__.write("{0!s}\n".format(s))
42 sys.__stderr__.flush() 43 sys.__stderr__.flush()
43 44
44 45
45 def setRecursionLimit(limit): 46 def setRecursionLimit(limit):
46 """ 47 """
47 Module function to set the recursion limit. 48 Module function to set the recursion limit.
48 49
49 @param limit recursion limit (integer) 50 @param limit recursion limit
51 @type int
50 """ 52 """
51 global gRecursionLimit 53 global gRecursionLimit
52 gRecursionLimit = limit 54 gRecursionLimit = limit
53 55
54 56
73 def __init__(self, dbgClient): 75 def __init__(self, dbgClient):
74 """ 76 """
75 Constructor 77 Constructor
76 78
77 @param dbgClient the owning client 79 @param dbgClient the owning client
80 @type DebugClient
78 """ 81 """
79 self._dbgClient = dbgClient 82 self._dbgClient = dbgClient
80 83
81 # Some informations about the thread 84 # Some informations about the thread
82 self.isMainThread = False 85 self.isMainThread = False
149 """ 152 """
150 Public method to return the locals dictionary of the current frame 153 Public method to return the locals dictionary of the current frame
151 or a frame below. 154 or a frame below.
152 155
153 @param frmnr distance of frame to get locals dictionary of. 0 is 156 @param frmnr distance of frame to get locals dictionary of. 0 is
154 the current frame (int) 157 the current frame
158 @type int
155 @return locals dictionary of the frame 159 @return locals dictionary of the frame
160 @rtype dict
156 """ 161 """
157 try: 162 try:
158 f = self.frameList[frmnr] 163 f = self.frameList[frmnr]
159 return f.f_locals 164 return f.f_locals
160 except IndexError: 165 except IndexError:
164 """ 169 """
165 Public method to store the locals into the frame, so an access to 170 Public method to store the locals into the frame, so an access to
166 frame.f_locals returns the last data. 171 frame.f_locals returns the last data.
167 172
168 @param frmnr distance of frame to store locals dictionary to. 0 is 173 @param frmnr distance of frame to store locals dictionary to. 0 is
169 the current frame (int) 174 the current frame
175 @type int
170 """ 176 """
171 with contextlib.suppress(IndexError): 177 with contextlib.suppress(IndexError):
172 cf = self.frameList[frmnr] 178 cf = self.frameList[frmnr]
173 179
174 with contextlib.suppress(ImportError, AttributeError): 180 with contextlib.suppress(ImportError, AttributeError):
184 """ 190 """
185 Public method to perform a step operation in this thread. 191 Public method to perform a step operation in this thread.
186 192
187 @param traceMode If it is True, then the step is a step into, 193 @param traceMode If it is True, then the step is a step into,
188 otherwise it is a step over. 194 otherwise it is a step over.
195 @type bool
189 """ 196 """
190 if traceMode: 197 if traceMode:
191 self.set_step() 198 self.set_step()
192 else: 199 else:
193 self.set_next(self.currentFrame) 200 self.set_next(self.currentFrame)
203 Public method to resume the thread. 210 Public method to resume the thread.
204 211
205 It resumes the thread stopping only at breakpoints or exceptions. 212 It resumes the thread stopping only at breakpoints or exceptions.
206 213
207 @param special flag indicating a special continue operation 214 @param special flag indicating a special continue operation
215 @type bool
208 """ 216 """
209 self.set_continue(special) 217 self.set_continue(special)
210 218
211 def setRecursionDepth(self, frame): 219 def setRecursionDepth(self, frame):
212 """ 220 """
213 Public method to determine the current recursion depth. 221 Public method to determine the current recursion depth.
214 222
215 @param frame The current stack frame. 223 @param frame The current stack frame.
224 @type frame object
216 """ 225 """
217 self.__recursionDepth = 0 226 self.__recursionDepth = 0
218 while frame is not None: 227 while frame is not None:
219 self.__recursionDepth += 1 228 self.__recursionDepth += 1
220 frame = frame.f_back 229 frame = frame.f_back
839 def user_line(self, frame): 848 def user_line(self, frame):
840 """ 849 """
841 Public method reimplemented to handle the program about to execute a 850 Public method reimplemented to handle the program about to execute a
842 particular line. 851 particular line.
843 852
844 @param frame the frame object 853 @param frame reference to the frame object
854 @type frame object
845 """ 855 """
846 # We never stop on line 0. 856 # We never stop on line 0.
847 if frame.f_lineno == 0: 857 if frame.f_lineno == 0:
848 return 858 return
849 859
1000 """ 1010 """
1001 Private method to extract the exception name given the exception 1011 Private method to extract the exception name given the exception
1002 type object. 1012 type object.
1003 1013
1004 @param exctype type of the exception 1014 @param exctype type of the exception
1005 @return exception name (string) 1015 @type type
1016 @return exception name
1017 @rtype str
1006 """ 1018 """
1007 return str(exctype).replace("<class '", "").replace("'>", "") 1019 return str(exctype).replace("<class '", "").replace("'>", "")
1008 1020
1009 def __extract_stack(self, exctb): 1021 def __extract_stack(self, exctb):
1010 """ 1022 """
1011 Private member to return a list of stack frames. 1023 Private member to return a list of stack frames.
1012 1024
1013 @param exctb exception traceback 1025 @param exctb exception traceback
1026 @type traceback
1014 @return list of stack frames 1027 @return list of stack frames
1028 @rtype list of frame
1015 """ 1029 """
1016 tb = exctb 1030 tb = exctb
1017 stack = [] 1031 stack = []
1018 while tb is not None: 1032 while tb is not None:
1019 stack.append((tb.tb_frame, tb.tb_lineno)) 1033 stack.append((tb.tb_frame, tb.tb_lineno))

eric ide

mercurial