DebugClients/Python/DebugClientBase.py

Tue, 26 Mar 2019 19:29:30 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 26 Mar 2019 19:29:30 +0100
changeset 6901
f2c774c8db7e
parent 6899
8c4cf9c405c7
child 6904
3f35037a08d4
permissions
-rw-r--r--

UnittestDialog: implemented the remote part fo 'discover only'.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6588
diff changeset
3 # Copyright (c) 2002 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a debug client base class.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import socket
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import select
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import codeop
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
14 import codecs
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import traceback
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import os
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
17 import json
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import imp
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 import re
2371
72e2f353f34b Fixed severe bugs in the coverage integration.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
20 import atexit
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
21 import signal
6847
5150e076014b DebugClientBase: changed the name reslver of the debug client to overcome slow name resolution issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6735
diff changeset
22 import time
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 import DebugClientCapabilities
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
26 import DebugVariables
723
49ef401db2ce Changed syntax check to allow to ignore a syntax warning by ending the source line with "__IGNORE_WARNING__" and modified a few files accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 692
diff changeset
27 from DebugBase import setRecursionLimit, printerr # __IGNORE_WARNING__
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1029
diff changeset
28 from AsyncFile import AsyncFile, AsyncPendingWrite
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 from DebugConfig import ConfigVarTypeStrings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 from FlexCompleter import Completer
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
31 from DebugUtilities import prepareJsonCommand
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
32 from BreakpointWatch import Breakpoint, Watch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
34 if sys.version_info[0] == 2:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
35 from inspect import getargvalues, formatargvalues
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
36 else:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
37 unichr = chr
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
38 from DebugUtilities import getargvalues, formatargvalues
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 DebugClientInstance = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
42 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
44
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
45 def DebugClientRawInput(prompt="", echo=True):
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
46 """
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
47 Replacement for the standard raw_input builtin.
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
48
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
49 This function works with the split debugger.
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
50
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
51 @param prompt prompt to be shown. (string)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
52 @param echo flag indicating echoing of the input (boolean)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
53 @return result of the raw_input() call
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
54 """
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
55 if DebugClientInstance is None or not DebugClientInstance.redirect:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
56 return DebugClientOrigRawInput(prompt)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
57
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
58 return DebugClientInstance.raw_input(prompt, echo)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
59
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
60
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
61 def DebugClientInput(prompt="", echo=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Replacement for the standard input builtin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 This function works with the split debugger.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
67 @param prompt prompt to be shown (string)
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
68 @param echo flag indicating to echo the output (boolean)
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
69 @return result of the input() call
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 if DebugClientInstance is None or not DebugClientInstance.redirect:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 return DebugClientOrigInput(prompt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 72
diff changeset
74 return DebugClientInstance.input(prompt, echo)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
76 # Use our own input() and on Python 2 raw_input().
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
77 if sys.version_info[0] == 2:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
78 try:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
79 DebugClientOrigRawInput = __builtins__.__dict__['raw_input']
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
80 __builtins__.__dict__['raw_input'] = DebugClientRawInput
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
81 except (AttributeError, KeyError):
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
82 import __main__
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
83 DebugClientOrigRawInput = __main__.__builtins__.__dict__['raw_input']
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
84 __main__.__builtins__.__dict__['raw_input'] = DebugClientRawInput
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
85
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
86 try:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
87 DebugClientOrigInput = __builtins__.__dict__['input']
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
88 __builtins__.__dict__['input'] = DebugClientInput
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
89 except (AttributeError, KeyError):
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
90 import __main__
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
91 DebugClientOrigInput = __main__.__builtins__.__dict__['input']
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
92 __main__.__builtins__.__dict__['input'] = DebugClientInput
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
93 else:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
94 try:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
95 DebugClientOrigInput = __builtins__.__dict__['input']
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
96 __builtins__.__dict__['input'] = DebugClientRawInput
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
97 except (AttributeError, KeyError):
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
98 import __main__
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
99 DebugClientOrigInput = __main__.__builtins__.__dict__['input']
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
100 __main__.__builtins__.__dict__['input'] = DebugClientRawInput
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
102 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
104
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 def DebugClientFork():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 Replacement for the standard os.fork().
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
108
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
109 @return result of the fork() call
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 if DebugClientInstance is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 return DebugClientOrigFork()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 return DebugClientInstance.fork()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 # use our own fork().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 if 'fork' in dir(os):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 DebugClientOrigFork = os.fork
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 os.fork = DebugClientFork
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
121 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
123
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 def DebugClientClose(fd):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 Replacement for the standard os.close(fd).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 @param fd open file descriptor to be closed (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 if DebugClientInstance is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 DebugClientOrigClose(fd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 DebugClientInstance.close(fd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 # use our own close().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if 'close' in dir(os):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 DebugClientOrigClose = os.close
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 os.close = DebugClientClose
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
140 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
142
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 def DebugClientSetRecursionLimit(limit):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 Replacement for the standard sys.setrecursionlimit(limit).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 @param limit recursion limit (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 rl = max(limit, 64)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 setRecursionLimit(rl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 DebugClientOrigSetRecursionLimit(rl + 64)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 # use our own setrecursionlimit().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 if 'setrecursionlimit' in dir(sys):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 DebugClientOrigSetRecursionLimit = sys.setrecursionlimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 sys.setrecursionlimit = DebugClientSetRecursionLimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 DebugClientSetRecursionLimit(sys.getrecursionlimit())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
159 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
161
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 class DebugClientBase(object):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 Class implementing the client side of the debugger.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
166 It provides access to the Python interpeter from a debugger running in
5135
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
167 another process.
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
168
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
169 The protocol between the debugger and the client is based on JSONRPC 2.0
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
170 PDUs. Each one is sent on a single line, i.e. commands or responses are
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
171 separated by a linefeed character.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 If the debugger closes the session there is no response from the client.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 The client may close the session at any time as a result of the script
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 being debugged closing or crashing.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
177 <b>Note</b>: This class is meant to be subclassed by individual
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
178 DebugClient classes. Do not instantiate it directly.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 clientCapabilities = DebugClientCapabilities.HasAll
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
182 # keep these in sync with VariablesViewer.VariableItem.Indicators
5616
adcffadf4962 Reworked some __IGNORE_WARNING__ comments to be more specific.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5595
diff changeset
183 Indicators = ("()", "[]", "{:}", "{}") # __IGNORE_WARNING_M613__
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
184
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.breakpoints = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.redirect = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 # special objects representing the main scripts thread and frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.mainThread = self
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 self.framenr = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 # The context to run the debugged program in.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.debugMod = imp.new_module('__main__')
3729
b6eda7d63e4c Debug viewer always active.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3640
diff changeset
198 self.debugMod.__dict__['__builtins__'] = __builtins__
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 # The list of complete lines to execute.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self.buffer = ''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 # The list of regexp objects to filter variables against
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.globalsFilterObjects = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.localsFilterObjects = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206
1706
d0871e278075 Fixed an issue uncovered by the recent change to the DebugClientBase classes (only on Windows).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1607
diff changeset
207 self._fncache = {}
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.dircache = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 self.passive = False # used to indicate the passive mode
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.running = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.test = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 self.debugging = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.fork_auto = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.fork_child = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.readstream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 self.writestream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 self.errorstream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.pollingDisabled = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
222 self.callTraceEnabled = None
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2157
diff changeset
223
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 self.variant = 'You should not see this'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 self.compile_command = codeop.CommandCompiler()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
43
2fdc635b106a Reverted the last change to the Python3 debugger backend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
228 self.coding_re = re.compile(r"coding[:=]\s*([-\w_.]+)")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.defaultCoding = 'utf-8'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.__coding = self.defaultCoding
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 self.noencoding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 def getCoding(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 Public method to return the current coding.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 @return codec name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 return self.__coding
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 def __setCoding(self, filename):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 Private method to set the coding used by a python file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 @param filename name of the file to inspect (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 if self.noencoding:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.__coding = sys.getdefaultencoding()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 default = 'utf-8'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 f = open(filename, 'rb')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 # read the first and second line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 text = f.readline()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 text = "{0}{1}".format(text, f.readline())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 f.close()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 except IOError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 self.__coding = default
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
261 for line in text.splitlines():
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
262 m = self.coding_re.search(line)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 if m:
43
2fdc635b106a Reverted the last change to the Python3 debugger backend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
264 self.__coding = m.group(1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 self.__coding = default
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
268 def raw_input(self, prompt, echo):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 """
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
270 Public method to implement raw_input() / input() using the event loop.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @param prompt the prompt to be shown (string)
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 72
diff changeset
273 @param echo Flag indicating echoing of the input (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 @return the entered string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
276 self.sendJsonCommand("RequestRaw", {
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
277 "prompt": prompt,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
278 "echo": echo,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
279 })
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 self.eventLoop(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 return self.rawLine
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
283 def input(self, prompt):
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
284 """
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
285 Public method to implement input() (Python 2) using the event loop.
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
286
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
287 @param prompt the prompt to be shown (string)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
288 @return the entered string evaluated as a Python expresion
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
289 """
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
290 return eval(self.raw_input(prompt, True))
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
291
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5551
diff changeset
292 def sessionClose(self, terminate=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 """
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
294 Public method to close the session with the debugger and optionally
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
295 terminate.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5551
diff changeset
297 @param terminate flag indicating to terminate (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.set_quit()
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
301 except Exception:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.debugging = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 # make sure we close down our end of the socket
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 # might be overkill as normally stdin, stdout and stderr
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 # SHOULD be closed on exit, but it does not hurt to do it here
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 self.readstream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 self.writestream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 self.errorstream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5551
diff changeset
313 if terminate:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 # Ok, go away.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 sys.exit()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
317 def __compileFileSource(self, filename, mode='exec'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 Private method to compile source code read from a file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 @param filename name of the source file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 @param mode kind of code to be generated (string, exec or eval)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 @return compiled code object (None in case of errors)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 """
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
325 with codecs.open(filename, encoding=self.__coding) as fp:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 statement = fp.read()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
328 if sys.version_info[0] == 2:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
329 lines = statement.splitlines(True)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
330 for lineno, line in enumerate(lines[:2]):
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
331 lines[lineno] = self.coding_re.sub('', line)
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
332
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
333 statement = unicode('').join(lines) # __IGNORE_WARNING__
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
334
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 code = compile(statement + '\n', filename, mode)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 except SyntaxError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 exctype, excval, exctb = sys.exc_info()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 try:
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
340 message = str(excval)
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
341 filename = excval.filename
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
342 lineno = excval.lineno
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
343 charno = excval.offset
5184
79b3922094ba Fixed an interesting issue showing up when the code contains an invalid future statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5175
diff changeset
344 if charno is None:
79b3922094ba Fixed an interesting issue showing up when the code contains an invalid future statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5175
diff changeset
345 charno = 0
5239
27f56dc07b5b Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5190 5221
diff changeset
346
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
347 except (AttributeError, ValueError):
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
348 message = ""
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
349 filename = ""
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
350 lineno = 0
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
351 charno = 0
5239
27f56dc07b5b Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5190 5221
diff changeset
352
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
353 self.sendSyntaxError(message, filename, lineno, charno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 return code
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
358 def handleJsonCommand(self, jsonStr):
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
359 """
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
360 Public method to handle a command serialized as a JSON string.
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
361
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
362 @param jsonStr string containing the command received from the IDE
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
363 @type str
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
364 """
5966
3325ecd87c7c Fixed an issue in the debugger backend related to debugging threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5964
diff changeset
365 ## printerr(jsonStr) ##debug
3325ecd87c7c Fixed an issue in the debugger backend related to debugging threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5964
diff changeset
366
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
367 try:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
368 commandDict = json.loads(jsonStr.strip())
5162
bbf2bb2d533c Fixed an issue in the new debugger protocol because JSONDecodeError is defined for Python 3.5 and newer only.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5161
diff changeset
369 except (TypeError, ValueError) as err:
5966
3325ecd87c7c Fixed an issue in the debugger backend related to debugging threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5964
diff changeset
370 printerr("Error handling command: " + jsonStr)
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
371 printerr(str(err))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
372 return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
373
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
374 method = commandDict["method"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
375 params = commandDict["params"]
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
376 if "filename" in params and sys.version_info[0] == 2:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
377 params["filename"] = params["filename"].encode(
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
378 sys.getfilesystemencoding())
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
379
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
380 if method == "RequestVariables":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
381 self.__dumpVariables(
5964
066e6c78a367 Introduced a configuration option for the debugger variables viewers to limit the variables shown by the variables viewers depending on their size (in order to avoid overload situations on low power or low memory machines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5957
diff changeset
382 params["frameNumber"], params["scope"], params["filters"],
066e6c78a367 Introduced a configuration option for the debugger variables viewers to limit the variables shown by the variables viewers depending on their size (in order to avoid overload situations on low power or low memory machines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5957
diff changeset
383 params["maxSize"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
384
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
385 elif method == "RequestVariable":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
386 self.__dumpVariable(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
387 params["variable"], params["frameNumber"],
5964
066e6c78a367 Introduced a configuration option for the debugger variables viewers to limit the variables shown by the variables viewers depending on their size (in order to avoid overload situations on low power or low memory machines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5957
diff changeset
388 params["scope"], params["filters"],
066e6c78a367 Introduced a configuration option for the debugger variables viewers to limit the variables shown by the variables viewers depending on their size (in order to avoid overload situations on low power or low memory machines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5957
diff changeset
389 params["maxSize"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
390
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
391 elif method == "RequestThreadList":
5207
7283629b02c0 Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5206
diff changeset
392 self.dumpThreadList()
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
393
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
394 elif method == "RequestThreadSet":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
395 if params["threadID"] in self.threads:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
396 self.setCurrentThread(params["threadID"])
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
397 self.sendJsonCommand("ResponseThreadSet", {})
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
398 stack = self.currentThread.getStack()
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
399 self.sendJsonCommand("ResponseStack", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
400 "stack": stack,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
401 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
402
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
403 elif method == "RequestCapabilities":
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
404 clientType = "Python2" if sys.version_info[0] == 2 else "Python3"
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
405 self.sendJsonCommand("ResponseCapabilities", {
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
406 "capabilities": self.__clientCapabilities(),
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
407 "clientType": clientType
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
408 })
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
409
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
410 elif method == "RequestBanner":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
411 self.sendJsonCommand("ResponseBanner", {
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
412 "version": "Python {0}".format(sys.version),
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
413 "platform": socket.gethostname(),
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
414 "dbgclient": self.variant,
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
415 })
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
416
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
417 elif method == "RequestSetFilter":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
418 self.__generateFilterObjects(params["scope"], params["filter"])
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
419
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
420 elif method == "RequestCallTrace":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
421 if params["enable"]:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
422 callTraceEnabled = self.profile
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
423 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
424 callTraceEnabled = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
426 if self.debugging:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
427 sys.setprofile(callTraceEnabled)
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
428 else:
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
429 # remember for later
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
430 self.callTraceEnabled = callTraceEnabled
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
431
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
432 elif method == "RequestEnvironment":
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
433 for key, value in params["environment"].items():
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
434 if key.endswith("+"):
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
435 if key[:-1] in os.environ:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
436 os.environ[key[:-1]] += value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
437 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
438 os.environ[key[:-1]] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
439 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
440 os.environ[key] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
441
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
442 elif method == "RequestLoad":
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
443 self._fncache = {}
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
444 self.dircache = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
445 sys.argv = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
446 self.__setCoding(params["filename"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
447 sys.argv.append(params["filename"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
448 sys.argv.extend(params["argv"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
449 sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
450 if params["workdir"] == '':
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
451 os.chdir(sys.path[1])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
452 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
453 os.chdir(params["workdir"])
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
454
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
455 self.running = sys.argv[0]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
456 self.debugging = True
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
457
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
458 self.fork_auto = params["autofork"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
459 self.fork_child = params["forkChild"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
460
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
461 self.threads.clear()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
462 self.attachThread(mainThread=True)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
463
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
464 # set the system exception handling function to ensure, that
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
465 # we report on all unhandled exceptions
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
466 sys.excepthook = self.__unhandled_exception
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
467 self.__interceptSignals()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
468
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
469 # clear all old breakpoints, they'll get set after we have
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
470 # started
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
471 Breakpoint.clear_all_breaks()
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
472 Watch.clear_all_watches()
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
473
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
474 self.mainThread.tracePythonLibs(params["traceInterpreter"])
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
475
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
476 # This will eventually enter a local event loop.
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
477 self.debugMod.__dict__['__file__'] = self.running
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
478 sys.modules['__main__'] = self.debugMod
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
479 code = self.__compileFileSource(self.running)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
480 if code:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
481 sys.setprofile(self.callTraceEnabled)
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
482 self.mainThread.run(code, self.debugMod.__dict__, debug=True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
484 elif method == "RequestRun":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
485 sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
486 self.__setCoding(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
487 sys.argv.append(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
488 sys.argv.extend(params["argv"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
489 sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
490 if params["workdir"] == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
491 os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
492 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
493 os.chdir(params["workdir"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
494
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
495 self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
496 self.botframe = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
497
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
498 self.fork_auto = params["autofork"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
499 self.fork_child = params["forkChild"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
500
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
501 self.threads.clear()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
502 self.attachThread(mainThread=True)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
503
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
504 # set the system exception handling function to ensure, that
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
505 # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
506 sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
507 self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
508
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
509 self.mainThread.tracePythonLibs(False)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
510
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
511 self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
512 sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
513 res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
514 code = self.__compileFileSource(self.running)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
515 if code:
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
516 self.mainThread.run(code, self.debugMod.__dict__, debug=False)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
517
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
518 elif method == "RequestCoverage":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
519 from coverage import coverage
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
520 sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
521 self.__setCoding(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
522 sys.argv.append(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
523 sys.argv.extend(params["argv"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
524 sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
525 if params["workdir"] == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
526 os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
527 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
528 os.chdir(params["workdir"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
529
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
530 # set the system exception handling function to ensure, that
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
531 # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
532 sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
533 self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
534
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
535 # generate a coverage object
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
536 self.cover = coverage(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
537 auto_data=True,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
538 data_file="{0}.coverage".format(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
539 os.path.splitext(sys.argv[0])[0]))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
540
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
541 if params["erase"]:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
542 self.cover.erase()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
543 sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
544 self.debugMod.__dict__['__file__'] = sys.argv[0]
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
545 code = self.__compileFileSource(sys.argv[0])
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
546 if code:
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
547 self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
548 self.cover.start()
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
549 self.mainThread.run(code, self.debugMod.__dict__, debug=False)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
550 self.cover.stop()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
551 self.cover.save()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
552
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
553 elif method == "RequestProfile":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
554 sys.setprofile(None)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
555 import PyProfile
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
556 sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
557 self.__setCoding(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
558 sys.argv.append(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
559 sys.argv.extend(params["argv"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
560 sys.path = self.__getSysPath(os.path.dirname(sys.argv[0]))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
561 if params["workdir"] == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
562 os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
563 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
564 os.chdir(params["workdir"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
565
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
566 # set the system exception handling function to ensure, that
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
567 # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
568 sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
569 self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
570
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
571 # generate a profile object
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
572 self.prof = PyProfile.PyProfile(sys.argv[0])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
573
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
574 if params["erase"]:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
575 self.prof.erase()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
576 self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
577 sys.modules['__main__'] = self.debugMod
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
578 script = ''
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
579 if sys.version_info[0] == 2:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
580 script = 'execfile({0!r})'.format(sys.argv[0])
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
581 else:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
582 with codecs.open(sys.argv[0], encoding=self.__coding) as fp:
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
583 script = fp.read()
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
584 if script and not script.endswith('\n'):
6735
31e263d49c04 Fixed some code style issues detected by the updated style checker (over-indented lines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
585 script += '\n'
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
586
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
587 if script:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
588 self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
589 res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
590 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
591 self.prof.run(script)
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
592 atexit._run_exitfuncs()
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
593 except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
594 res = exc.code
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
595 atexit._run_exitfuncs()
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
596 except Exception:
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
597 excinfo = sys.exc_info()
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
598 self.__unhandled_exception(*excinfo)
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
599
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
600 self.prof.save()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
601 self.progTerminated(res)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
602
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
603 elif method == "ExecuteStatement":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
604 if self.buffer:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
605 self.buffer = self.buffer + '\n' + params["statement"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
606 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
607 self.buffer = params["statement"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
608
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
609 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
610 code = self.compile_command(self.buffer, self.readstream.name)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
611 except (OverflowError, SyntaxError, ValueError):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
612 # Report the exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
613 sys.last_type, sys.last_value, sys.last_traceback = \
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
614 sys.exc_info()
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
615 self.sendJsonCommand("ClientOutput", {
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
616 "text": "".join(traceback.format_exception_only(
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
617 sys.last_type, sys.last_value))
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
618 })
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
619 self.buffer = ''
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
620 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
621 if code is None:
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
622 self.sendJsonCommand("ResponseContinue", {})
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
623 return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
624 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
625 self.buffer = ''
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
626
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
627 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
628 if self.running is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
629 exec(code, self.debugMod.__dict__)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
630 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
631 if self.currentThread is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
632 # program has terminated
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
633 self.running = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
634 _globals = self.debugMod.__dict__
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
635 _locals = _globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
636 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
637 cf = self.currentThread.getCurrentFrame()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
638 # program has terminated
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
639 if cf is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
640 self.running = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
641 _globals = self.debugMod.__dict__
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
642 _locals = _globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
643 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
644 frmnr = self.framenr
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
645 while cf is not None and frmnr > 0:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
646 cf = cf.f_back
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
647 frmnr -= 1
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
648 _globals = cf.f_globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
649 _locals = \
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
650 self.currentThread.getFrameLocals(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
651 self.framenr)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
652 # reset sys.stdout to our redirector
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
653 # (unconditionally)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
654 if "sys" in _globals:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
655 __stdout = _globals["sys"].stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
656 _globals["sys"].stdout = self.writestream
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
657 exec(code, _globals, _locals)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
658 _globals["sys"].stdout = __stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
659 elif "sys" in _locals:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
660 __stdout = _locals["sys"].stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
661 _locals["sys"].stdout = self.writestream
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
662 exec(code, _globals, _locals)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
663 _locals["sys"].stdout = __stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
664 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
665 exec(code, _globals, _locals)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
666
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
667 self.currentThread.storeFrameLocals(self.framenr)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
668 except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
669 self.progTerminated(exc.code)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
670 except Exception:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
671 # Report the exception and the traceback
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
672 tlist = []
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
673 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
674 exc_type, exc_value, exc_tb = sys.exc_info()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
675 sys.last_type = exc_type
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
676 sys.last_value = exc_value
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
677 sys.last_traceback = exc_tb
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
678 tblist = traceback.extract_tb(exc_tb)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
679 del tblist[:1]
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
680 tlist = traceback.format_list(tblist)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
681 if tlist:
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
682 tlist.insert(
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
683 0, "Traceback (innermost last):\n")
5131
889ed5ff7a68 Fixed a few issues in the modernized Python 3 debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5129
diff changeset
684 tlist.extend(traceback.format_exception_only(
889ed5ff7a68 Fixed a few issues in the modernized Python 3 debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5129
diff changeset
685 exc_type, exc_value))
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
686 finally:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
687 tblist = exc_tb = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
688
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
689 self.sendJsonCommand("ClientOutput", {
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
690 "text": "".join(tlist)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
691 })
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
692
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
693 self.sendJsonCommand("ResponseOK", {})
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
694
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
695 elif method == "RequestStep":
5221
960afd19c1b6 Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5207
diff changeset
696 self.currentThreadExec.step(True)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
697 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
698
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
699 elif method == "RequestStepOver":
5221
960afd19c1b6 Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5207
diff changeset
700 self.currentThreadExec.step(False)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
701 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
702
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
703 elif method == "RequestStepOut":
5221
960afd19c1b6 Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5207
diff changeset
704 self.currentThreadExec.stepOut()
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
705 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
706
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
707 elif method == "RequestStepQuit":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
708 if self.passive:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
709 self.progTerminated(42)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
710 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
711 self.set_quit()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
712 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
713
5658
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
714 elif method == "RequestMoveIP":
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
715 newLine = params["newLine"]
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
716 self.currentThreadExec.move_instruction_pointer(newLine)
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
717
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
718 elif method == "RequestContinue":
5551
16f9a0bccda1 In rare cases the wrong thread could issued to continue.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5540
diff changeset
719 self.currentThreadExec.go(params["special"])
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
720 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
721
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
722 elif method == "RawInput":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
723 # If we are handling raw mode input then break out of the current
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
724 # event loop.
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
725 self.rawLine = params["input"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
726 self.eventExit = True
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
727
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
728 elif method == "RequestBreakpoint":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
729 if params["setBreakpoint"]:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
730 if params["condition"] in ['None', '']:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
731 cond = None
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
732 elif params["condition"] is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
733 try:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
734 cond = compile(params["condition"], '<string>', 'eval')
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
735 except SyntaxError:
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
736 self.sendJsonCommand("ResponseBPConditionError", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
737 "filename": params["filename"],
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
738 "line": params["line"],
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
739 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
740 return
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
741 else:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
742 cond = None
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
743
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
744 Breakpoint(
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
745 params["filename"], params["line"], params["temporary"],
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
746 cond)
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
747 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
748 Breakpoint.clear_break(params["filename"], params["line"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
749
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
750 elif method == "RequestBreakpointEnable":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
751 bp = Breakpoint.get_break(params["filename"], params["line"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
752 if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
753 if params["enable"]:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
754 bp.enable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
755 else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
756 bp.disable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
757
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
758 elif method == "RequestBreakpointIgnore":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
759 bp = Breakpoint.get_break(params["filename"], params["line"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
760 if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
761 bp.ignore = params["count"]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
762
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
763 elif method == "RequestWatch":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
764 if params["setWatch"]:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
765 if params["condition"].endswith(
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
766 ('??created??', '??changed??')):
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
767 compiledCond, flag = params["condition"].split()
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
768 else:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
769 compiledCond = params["condition"]
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
770 flag = ''
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
771
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
772 try:
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
773 compiledCond = compile(compiledCond, '<string>', 'eval')
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
774 except SyntaxError:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
775 self.sendJsonCommand("ResponseWatchConditionError", {
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
776 "condition": params["condition"],
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
777 })
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
778 return
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
779 Watch(
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
780 params["condition"], compiledCond, flag,
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
781 params["temporary"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
782 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
783 Watch.clear_watch(params["condition"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
784
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
785 elif method == "RequestWatchEnable":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
786 wp = Watch.get_watch(params["condition"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
787 if wp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
788 if params["enable"]:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
789 wp.enable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
790 else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
791 wp.disable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
792
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
793 elif method == "RequestWatchIgnore":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
794 wp = Watch.get_watch(params["condition"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
795 if wp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
796 wp.ignore = params["count"]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
797
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
798 elif method == "RequestShutdown":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
799 self.sessionClose()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
800
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
801 elif method == "RequestCompletion":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
802 self.__completionList(params["text"])
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
803
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
804 elif method == "RequestUTDiscover":
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
805 if params["syspath"]:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
806 sys.path = params["syspath"] + sys.path
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
807
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
808 discoveryStart = params["discoverystart"]
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
809 if not discoveryStart:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
810 discoveryStart = params["workdir"]
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
811
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
812 os.chdir(params["discoverystart"])
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
813
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
814 # set the system exception handling function to ensure, that
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
815 # we report on all unhandled exceptions
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
816 sys.excepthook = self.__unhandled_exception
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
817 self.__interceptSignals()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
818
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
819 try:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
820 import unittest
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
821 testLoader = unittest.TestLoader()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
822 test = testLoader.discover(discoveryStart)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
823 if hasattr(testLoader, "errors") and \
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
824 bool(testLoader.errors):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
825 self.sendJsonCommand("ResponseUTDiscover", {
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
826 "testCasesList": [],
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
827 "exception": "DiscoveryError",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
828 "message": "\n\n".join(testLoader.errors),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
829 })
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
830 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
831 testsList = self.__assembleTestCasesList(test)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
832 self.sendJsonCommand("ResponseUTDiscover", {
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
833 "testCasesList": testsList,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
834 "exception": "",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
835 "message": "",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
836 })
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
837 except Exception:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
838 exc_type, exc_value, exc_tb = sys.exc_info()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
839 self.sendJsonCommand("ResponseUTDiscover", {
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
840 "testCasesList": [],
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
841 "exception": exc_type.__name__,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
842 "message": str(exc_value),
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
843 })
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
844
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
845 elif method == "RequestUTPrepare":
6892
c147620313c5 UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6849
diff changeset
846 if params["syspath"]:
c147620313c5 UnittestDialog: fixed an issue running tests for a project and removed the (obsolete) 'local' option.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6849
diff changeset
847 sys.path = params["syspath"] + sys.path
5131
889ed5ff7a68 Fixed a few issues in the modernized Python 3 debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5129
diff changeset
848 sys.path.insert(
889ed5ff7a68 Fixed a few issues in the modernized Python 3 debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5129
diff changeset
849 0, os.path.dirname(os.path.abspath(params["filename"])))
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
850 if params["workdir"]:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
851 os.chdir(params["workdir"])
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
852 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
853 os.chdir(sys.path[0])
5131
889ed5ff7a68 Fixed a few issues in the modernized Python 3 debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5129
diff changeset
854
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
855 # set the system exception handling function to ensure, that
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
856 # we report on all unhandled exceptions
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
857 sys.excepthook = self.__unhandled_exception
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
858 self.__interceptSignals()
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
859
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
860 try:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
861 import unittest
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
862 testLoader = unittest.TestLoader()
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
863 if params["discover"]:
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
864 discoveryStart = params["discoverystart"]
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
865 if not discoveryStart:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
866 discoveryStart = params["workdir"]
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
867 if params["testcases"]:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
868 self.test = testLoader.loadTestsFromNames(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
869 params["testcases"])
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
870 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
871 self.test = testLoader.discover(discoveryStart)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
872 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
873 if params["filename"]:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
874 utModule = imp.load_source(
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
875 params["testname"], params["filename"])
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
876 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
877 utModule = None
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
878 if params["failed"]:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
879 if utModule:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
880 failed = [t.split(".", 1)[1]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
881 for t in params["failed"]]
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
882 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
883 failed = params["failed"][:]
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
884 self.test = testLoader.loadTestsFromNames(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
885 failed, utModule)
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
886 else:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
887 self.test = testLoader.loadTestsFromName(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
888 params["testfunctionname"], utModule)
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
889 except Exception:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
890 exc_type, exc_value, exc_tb = sys.exc_info()
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
891 self.sendJsonCommand("ResponseUTPrepared", {
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
892 "count": 0,
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
893 "exception": exc_type.__name__,
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
894 "message": str(exc_value),
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
895 })
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
896 return
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
897
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
898 # generate a coverage object
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
899 if params["coverage"]:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
900 from coverage import coverage
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
901 self.cover = coverage(
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
902 auto_data=True,
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
903 data_file="{0}.coverage".format(
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
904 os.path.splitext(params["coveragefile"])[0]))
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
905 if params["coverageerase"]:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
906 self.cover.erase()
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
907 else:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
908 self.cover = None
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
909
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
910 self.sendJsonCommand("ResponseUTPrepared", {
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
911 "count": self.test.countTestCases(),
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
912 "exception": "",
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
913 "message": "",
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
914 })
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
915
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
916 elif method == "RequestUTRun":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
917 from DCTestResult import DCTestResult
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
918 self.testResult = DCTestResult(self)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
919 if self.cover:
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
920 self.cover.start()
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
921 self.test.run(self.testResult)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
922 if self.cover:
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
923 self.cover.stop()
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
924 self.cover.save()
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
925 self.sendJsonCommand("ResponseUTFinished", {})
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
926
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
927 elif method == "RequestUTStop":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
928 self.testResult.stop()
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
929
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
930 elif method == "ResponseForkTo":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
931 # this results from a separate event loop
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
932 self.fork_child = (params["target"] == 'child')
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
933 self.eventExit = True
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
934
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
935 def __assembleTestCasesList(self, suite):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
936 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
937 Private method to assemble a list of test cases included in a test
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
938 suite.
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
939
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
940 @param suite test suite to be inspected
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
941 @type unittest.TestSuite
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
942 @return list of tuples containing the test case ID and short
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
943 description
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
944 @rtype list of tuples of (str, str)
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
945 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
946 import unittest
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
947 testCases = []
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
948 for test in suite:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
949 if isinstance(test, unittest.TestSuite):
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
950 testCases.extend(self.__assembleTestCasesList(test))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
951 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
952 testId = test.id()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
953 if "ModuleImportFailure" not in testId and \
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
954 "LoadTestsFailure" not in testId and \
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
955 "_FailedTest" not in testId:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
956 testCases.append((test.id(), test.shortDescription()))
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
957 return testCases
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
958
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
959 def sendJsonCommand(self, method, params):
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
960 """
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
961 Public method to send a single command or response to the IDE.
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
962
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
963 @param method command or response command name to be sent
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
964 @type str
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
965 @param params dictionary of named parameters for the command or
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
966 response
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
967 @type dict
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
968 """
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
969 cmd = prepareJsonCommand(method, params)
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
970
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
971 self.writestream.write_p(cmd)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
972 self.writestream.flush()
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
973
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
974 def sendClearTemporaryBreakpoint(self, filename, lineno):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
975 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
976 Public method to signal the deletion of a temporary breakpoint.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
977
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
978 @param filename name of the file the bp belongs to
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
979 @type str
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
980 @param lineno linenumber of the bp
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
981 @type int
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
982 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
983 self.sendJsonCommand("ResponseClearBreakpoint", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
984 "filename": filename,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
985 "line": lineno
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
986 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
987
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
988 def sendClearTemporaryWatch(self, condition):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
989 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
990 Public method to signal the deletion of a temporary watch expression.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
991
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
992 @param condition condition of the watch expression to be cleared
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
993 @type str
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
994 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
995 self.sendJsonCommand("ResponseClearWatch", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
996 "condition": condition,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
997 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
998
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
999 def sendResponseLine(self, stack):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1000 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1001 Public method to send the current call stack.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1002
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1003 @param stack call stack
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1004 @type list
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1005 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
1006 self.sendJsonCommand("ResponseLine", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1007 "stack": stack,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1008 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1009
5140
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1010 def sendCallTrace(self, event, fromInfo, toInfo):
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1011 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1012 Public method to send a call trace entry.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1013
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1014 @param event trace event (call or return)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1015 @type str
5140
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1016 @param fromInfo dictionary containing the origin info
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1017 @type dict with 'filename', 'linenumber' and 'codename'
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1018 as keys
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1019 @param toInfo dictionary containing the target info
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1020 @type dict with 'filename', 'linenumber' and 'codename'
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1021 as keys
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1022 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
1023 self.sendJsonCommand("CallTrace", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1024 "event": event[0],
5140
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1025 "from": fromInfo,
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1026 "to": toInfo,
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1027 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1028
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1029 def sendException(self, exceptionType, exceptionMessage, stack):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1030 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1031 Public method to send information for an exception.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1032
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1033 @param exceptionType type of exception raised
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1034 @type str
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1035 @param exceptionMessage message of the exception
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1036 @type str
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1037 @param stack stack trace information
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
1038 @type list
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1039 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
1040 self.sendJsonCommand("ResponseException", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1041 "type": exceptionType,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1042 "message": exceptionMessage,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1043 "stack": stack,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1044 })
1ba8ee313b57 Continued modernizing the d