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 |
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 |
769 |
778 |
770 @param frame frame object to inspect |
779 @param frame frame object to inspect |
771 @type frame object or list |
780 @type frame object or list |
772 @param applyTrace flag to assign trace function to fr.f_trace |
781 @param applyTrace flag to assign trace function to fr.f_trace |
773 @type bool |
782 @type bool |
774 @return list of lists with file name (string), line number (integer) |
783 @return list of lists with file name, line number, function name |
775 and function name (string) |
784 and function arguments |
|
785 @rtype list of list of [str, int, str, str] |
776 """ |
786 """ |
777 tb_lineno = None |
787 tb_lineno = None |
778 if frame is None: |
788 if frame is None: |
779 fr = self.getFrame() |
789 fr = self.getFrame() |
780 elif isinstance(frame, list): |
790 elif isinstance(frame, list): |
839 def user_line(self, frame): |
849 def user_line(self, frame): |
840 """ |
850 """ |
841 Public method reimplemented to handle the program about to execute a |
851 Public method reimplemented to handle the program about to execute a |
842 particular line. |
852 particular line. |
843 |
853 |
844 @param frame the frame object |
854 @param frame reference to the frame object |
|
855 @type frame object |
845 """ |
856 """ |
846 # We never stop on line 0. |
857 # We never stop on line 0. |
847 if frame.f_lineno == 0: |
858 if frame.f_lineno == 0: |
848 return |
859 return |
849 |
860 |
1000 """ |
1011 """ |
1001 Private method to extract the exception name given the exception |
1012 Private method to extract the exception name given the exception |
1002 type object. |
1013 type object. |
1003 |
1014 |
1004 @param exctype type of the exception |
1015 @param exctype type of the exception |
1005 @return exception name (string) |
1016 @type type |
|
1017 @return exception name |
|
1018 @rtype str |
1006 """ |
1019 """ |
1007 return str(exctype).replace("<class '", "").replace("'>", "") |
1020 return str(exctype).replace("<class '", "").replace("'>", "") |
1008 |
1021 |
1009 def __extract_stack(self, exctb): |
1022 def __extract_stack(self, exctb): |
1010 """ |
1023 """ |
1011 Private member to return a list of stack frames. |
1024 Private member to return a list of stack frames. |
1012 |
1025 |
1013 @param exctb exception traceback |
1026 @param exctb exception traceback |
|
1027 @type traceback |
1014 @return list of stack frames |
1028 @return list of stack frames |
|
1029 @rtype list of frame |
1015 """ |
1030 """ |
1016 tb = exctb |
1031 tb = exctb |
1017 stack = [] |
1032 stack = [] |
1018 while tb is not None: |
1033 while tb is not None: |
1019 stack.append((tb.tb_frame, tb.tb_lineno)) |
1034 stack.append((tb.tb_frame, tb.tb_lineno)) |