eric6/DebugClients/Python/DebugClientBase.py

Sun, 18 Oct 2020 12:42:37 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 18 Oct 2020 12:42:37 +0200
changeset 7803
97f77d69c6f0
parent 7785
9978016560ec
child 7818
5c9271c2f662
child 7836
2f0d208b8137
permissions
-rw-r--r--

Debugger: modified the 'disassembly' interface to ease future extension.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7250
diff changeset
3 # Copyright (c) 2002 - 2020 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 re
2371
72e2f353f34b Fixed severe bugs in the coverage integration.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
19 import atexit
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
20 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
21 import time
7769
c9f64088224b DebugClientBase: changed code to get rid of the use of the deprecated imp module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
22 import types
c9f64088224b DebugClientBase: changed code to get rid of the use of the deprecated imp module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
23 import importlib
0
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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 import DebugClientCapabilities
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
27 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
28 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
29 from AsyncFile import AsyncFile, AsyncPendingWrite
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6942
diff changeset
30 from DebugConfig import ConfigQtNames, ConfigVarTypeStrings
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 from FlexCompleter import Completer
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
32 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
33 from BreakpointWatch import Breakpoint, Watch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
35 from DebugUtilities import getargvalues, formatargvalues
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 DebugClientInstance = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
39 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
41
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7637
diff changeset
42 def DebugClientInput(prompt=""):
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
43 """
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
44 Replacement for the standard input() builtin.
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
45
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
46 This function works with the split debugger.
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
47
7550
e91462fd0838 Python Debugger: fixed an issue related to redirecting the input() builtin function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7427
diff changeset
48 @param prompt prompt to be shown
e91462fd0838 Python Debugger: fixed an issue related to redirecting the input() builtin function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7427
diff changeset
49 @type str
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7637
diff changeset
50 @return result of the input() call
7550
e91462fd0838 Python Debugger: fixed an issue related to redirecting the input() builtin function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7427
diff changeset
51 @rtype str
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
52 """
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
53 if DebugClientInstance is None or not DebugClientInstance.redirect:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 return DebugClientOrigInput(prompt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
7550
e91462fd0838 Python Debugger: fixed an issue related to redirecting the input() builtin function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7427
diff changeset
56 return DebugClientInstance.input(prompt)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
58 # Use our own input().
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
59 try:
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
60 DebugClientOrigInput = __builtins__.__dict__['input']
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7637
diff changeset
61 __builtins__.__dict__['input'] = DebugClientInput
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
62 except (AttributeError, KeyError):
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
63 import __main__
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
64 DebugClientOrigInput = __main__.__builtins__.__dict__['input']
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7637
diff changeset
65 __main__.__builtins__.__dict__['input'] = DebugClientInput
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
67 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
69
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 def DebugClientFork():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 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
73
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
74 @return result of the fork() call
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if DebugClientInstance is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 return DebugClientOrigFork()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 return DebugClientInstance.fork()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 # use our own fork().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 if 'fork' in dir(os):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 DebugClientOrigFork = os.fork
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 os.fork = DebugClientFork
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
86 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
88
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 def DebugClientClose(fd):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 Replacement for the standard os.close(fd).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @param fd open file descriptor to be closed (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 if DebugClientInstance is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 DebugClientOrigClose(fd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 DebugClientInstance.close(fd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 # use our own close().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 if 'close' in dir(os):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 DebugClientOrigClose = os.close
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 os.close = DebugClientClose
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
105 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
107
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 def DebugClientSetRecursionLimit(limit):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 Replacement for the standard sys.setrecursionlimit(limit).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 @param limit recursion limit (integer)
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 rl = max(limit, 64)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 setRecursionLimit(rl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 DebugClientOrigSetRecursionLimit(rl + 64)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 # use our own setrecursionlimit().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 if 'setrecursionlimit' in dir(sys):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 DebugClientOrigSetRecursionLimit = sys.setrecursionlimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 sys.setrecursionlimit = DebugClientSetRecursionLimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 DebugClientSetRecursionLimit(sys.getrecursionlimit())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
124 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
126
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 class DebugClientBase(object):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 Class implementing the client side of the debugger.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
131 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
132 another process.
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
133
04905a8681dc Did some cleanup in the modernized debugger code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5131
diff changeset
134 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
135 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
136 separated by a linefeed character.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 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
139 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
140 being debugged closing or crashing.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
142 <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
143 DebugClient classes. Do not instantiate it directly.
0
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 clientCapabilities = DebugClientCapabilities.HasAll
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
147 # 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
148 Indicators = ("()", "[]", "{:}", "{}") # __IGNORE_WARNING_M613__
6988
87ad87ef1910 Make dictionary views expandable.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6980
diff changeset
149 arrayTypes = {
87ad87ef1910 Make dictionary views expandable.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6980
diff changeset
150 'list', 'tuple', 'dict', 'set', 'frozenset', "class 'dict_items'",
87ad87ef1910 Make dictionary views expandable.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6980
diff changeset
151 "class 'dict_keys'", "class 'dict_values'"
87ad87ef1910 Make dictionary views expandable.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6980
diff changeset
152 }
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
153
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.breakpoints = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.redirect = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 # special objects representing the main scripts thread and frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.mainThread = self
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 self.framenr = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 # The context to run the debugged program in.
7769
c9f64088224b DebugClientBase: changed code to get rid of the use of the deprecated imp module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
166 self.debugMod = types.ModuleType('__main__')
3729
b6eda7d63e4c Debug viewer always active.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3640
diff changeset
167 self.debugMod.__dict__['__builtins__'] = __builtins__
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 # The list of complete lines to execute.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 self.buffer = ''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 # The list of regexp objects to filter variables against
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.globalsFilterObjects = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 self.localsFilterObjects = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
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
176 self._fncache = {}
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.dircache = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.passive = False # used to indicate the passive mode
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.running = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.test = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 self.debugging = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.fork_auto = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.fork_child = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.readstream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 self.writestream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.errorstream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.pollingDisabled = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
191 self.callTraceEnabled = None
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2157
diff changeset
192
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
193 self.disassembly = None
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
194
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.variant = 'You should not see this'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.compile_command = codeop.CommandCompiler()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
43
2fdc635b106a Reverted the last change to the Python3 debugger backend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
199 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
200 self.defaultCoding = 'utf-8'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 self.__coding = self.defaultCoding
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.noencoding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 def getCoding(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 Public method to return the current coding.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 @return codec name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 return self.__coding
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 def __setCoding(self, filename):
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 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
215
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 @param filename name of the file to inspect (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 if self.noencoding:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 self.__coding = sys.getdefaultencoding()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 default = 'utf-8'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 try:
7785
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
223 with open(filename, 'rb') as f:
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
224 # read the first and second line
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
225 text = f.readline()
9978016560ec Changed code to use context manager 'open()' for file operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7775
diff changeset
226 text = "{0}{1}".format(text, f.readline())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 except IOError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 self.__coding = default
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
231 for line in text.splitlines():
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
232 m = self.coding_re.search(line)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 if m:
43
2fdc635b106a Reverted the last change to the Python3 debugger backend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
234 self.__coding = m.group(1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.__coding = default
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7637
diff changeset
238 def input(self, prompt, echo=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 """
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
240 Public method to implement input() using the event loop.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 @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
243 @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
244 @return the entered string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
246 self.sendJsonCommand("RequestRaw", {
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
247 "prompt": prompt,
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7637
diff changeset
248 "echo": echo,
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
249 })
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.eventLoop(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 return self.rawLine
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5551
diff changeset
253 def sessionClose(self, terminate=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
255 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
256 terminate.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5551
diff changeset
258 @param terminate flag indicating to terminate (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 self.set_quit()
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7594
diff changeset
262 except Exception: # secok
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 self.debugging = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 # 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
268 # might be overkill as normally stdin, stdout and stderr
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 # 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
270 self.readstream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 self.writestream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 self.errorstream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5551
diff changeset
274 if terminate:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 # Ok, go away.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 sys.exit()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
278 def __compileFileSource(self, filename, mode='exec'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 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
281
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 @param filename name of the source file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 @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
284 @return compiled code object (None in case of errors)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 """
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
286 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
287 statement = fp.read()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 code = compile(statement + '\n', filename, mode)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 except SyntaxError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 exctype, excval, exctb = sys.exc_info()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 try:
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
294 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
295 filename = excval.filename
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
296 lineno = excval.lineno
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
297 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
298 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
299 charno = 0
5239
27f56dc07b5b Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5190 5221
diff changeset
300
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
301 except (AttributeError, ValueError):
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
302 message = ""
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
303 filename = ""
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
304 lineno = 0
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
305 charno = 0
5239
27f56dc07b5b Merge with default branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5190 5221
diff changeset
306
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
307 self.sendSyntaxError(message, filename, lineno, charno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 return code
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
312 def handleJsonCommand(self, jsonStr):
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
313 """
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
314 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
315
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
316 @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
317 @type str
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
318 """
5966
3325ecd87c7c Fixed an issue in the debugger backend related to debugging threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5964
diff changeset
319 ## 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
320
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
321 try:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
322 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
323 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
324 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
325 printerr(str(err))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
326 return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
327
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
328 method = commandDict["method"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
329 params = commandDict["params"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
330
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
331 if method == "RequestVariables":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
332 self.__dumpVariables(
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6942
diff changeset
333 params["frameNumber"], params["scope"], params["filters"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
334
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
335 elif method == "RequestVariable":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
336 self.__dumpVariable(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
337 params["variable"], params["frameNumber"],
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6942
diff changeset
338 params["scope"], params["filters"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
339
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
340 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
341 self.dumpThreadList()
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
342
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
343 elif method == "RequestThreadSet":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
344 if params["threadID"] in self.threads:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
345 self.setCurrentThread(params["threadID"])
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
346 self.sendJsonCommand("ResponseThreadSet", {})
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
347 stack = self.currentThread.getStack()
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
348 self.sendJsonCommand("ResponseStack", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
349 "stack": stack,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
350 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
351
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
352 elif method == "RequestDisassembly":
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
353 if self.disassembly is not None:
7803
97f77d69c6f0 Debugger: modified the 'disassembly' interface to ease future extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
354 self.sendJsonCommand("ResponseDisassembly", {
97f77d69c6f0 Debugger: modified the 'disassembly' interface to ease future extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
355 "disassembly": self.disassembly
97f77d69c6f0 Debugger: modified the 'disassembly' interface to ease future extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
356 })
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
357 else:
7803
97f77d69c6f0 Debugger: modified the 'disassembly' interface to ease future extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
358 self.sendJsonCommand("ResponseDisassembly", {
97f77d69c6f0 Debugger: modified the 'disassembly' interface to ease future extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
359 "disassembly": {}
97f77d69c6f0 Debugger: modified the 'disassembly' interface to ease future extension.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7785
diff changeset
360 })
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
361
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
362 elif method == "RequestCapabilities":
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
363 clientType = "Python3"
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
364 self.sendJsonCommand("ResponseCapabilities", {
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
365 "capabilities": self.__clientCapabilities(),
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
366 "clientType": clientType
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
367 })
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
368
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
369 elif method == "RequestBanner":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
370 self.sendJsonCommand("ResponseBanner", {
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
371 "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
372 "platform": socket.gethostname(),
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
373 "dbgclient": self.variant,
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
374 })
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
375
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
376 elif method == "RequestSetFilter":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
377 self.__generateFilterObjects(params["scope"], params["filter"])
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
378
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
379 elif method == "RequestCallTrace":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
380 if params["enable"]:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
381 callTraceEnabled = self.profile
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
382 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
383 callTraceEnabled = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
385 if self.debugging:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
386 sys.setprofile(callTraceEnabled)
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
387 else:
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
388 # remember for later
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
389 self.callTraceEnabled = callTraceEnabled
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 == "RequestEnvironment":
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
392 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
393 if key.endswith("+"):
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
394 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
395 os.environ[key[:-1]] += value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
396 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
397 os.environ[key[:-1]] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
398 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
399 os.environ[key] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
400
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
401 elif method == "RequestLoad":
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
402 self._fncache = {}
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
403 self.dircache = []
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
404 self.disassembly = None
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
405 sys.argv = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
406 self.__setCoding(params["filename"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
407 sys.argv.append(params["filename"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
408 sys.argv.extend(params["argv"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
409 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
410 if params["workdir"] == '':
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
411 os.chdir(sys.path[1])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
412 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
413 os.chdir(params["workdir"])
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
414
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
415 self.running = sys.argv[0]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
416 self.debugging = True
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
417
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
418 self.fork_auto = params["autofork"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
419 self.fork_child = params["forkChild"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
420
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
421 self.threads.clear()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
422 self.attachThread(mainThread=True)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
423
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
424 # 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
425 # 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
426 sys.excepthook = self.__unhandled_exception
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
427 self.__interceptSignals()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
428
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
429 # 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
430 # started
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
431 Breakpoint.clear_all_breaks()
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
432 Watch.clear_all_watches()
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
433
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
434 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
435
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
436 # 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
437 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
438 sys.modules['__main__'] = self.debugMod
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
439 code = self.__compileFileSource(self.running)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
440 if code:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
441 sys.setprofile(self.callTraceEnabled)
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
442 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
443
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
444 elif method == "RequestRun":
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
445 self.disassembly = None
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
446 sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
447 self.__setCoding(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
448 sys.argv.append(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
449 sys.argv.extend(params["argv"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
450 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
451 if params["workdir"] == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
452 os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
453 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
454 os.chdir(params["workdir"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
455
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
456 self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
457 self.botframe = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
458
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
459 self.fork_auto = params["autofork"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
460 self.fork_child = params["forkChild"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
461
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
462 self.threads.clear()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
463 self.attachThread(mainThread=True)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
464
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
465 # 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
466 # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
467 sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
468 self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
469
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
470 self.mainThread.tracePythonLibs(False)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
471
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
472 self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
473 sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
474 res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
475 code = self.__compileFileSource(self.running)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
476 if code:
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
477 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
478
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
479 elif method == "RequestCoverage":
7427
362cd1b6f81a coverage: updated coverage.py to 5.0.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7423
diff changeset
480 from coverage import Coverage
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
481 self.disassembly = None
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
482 sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
483 self.__setCoding(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
484 sys.argv.append(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
485 sys.argv.extend(params["argv"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
486 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
487 if params["workdir"] == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
488 os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
489 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
490 os.chdir(params["workdir"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
491
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
492 # 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
493 # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
494 sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
495 self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
496
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
497 # generate a coverage object
7427
362cd1b6f81a coverage: updated coverage.py to 5.0.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7423
diff changeset
498 self.cover = Coverage(
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
499 auto_data=True,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
500 data_file="{0}.coverage".format(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
501 os.path.splitext(sys.argv[0])[0]))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
502
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
503 if params["erase"]:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
504 self.cover.erase()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
505 sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
506 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
507 code = self.__compileFileSource(sys.argv[0])
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
508 if code:
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
509 self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
510 self.cover.start()
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
511 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
512 self.cover.stop()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
513 self.cover.save()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
514
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
515 elif method == "RequestProfile":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
516 sys.setprofile(None)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
517 import PyProfile
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
518 self.disassembly = None
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
519 sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
520 self.__setCoding(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
521 sys.argv.append(params["filename"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
522 sys.argv.extend(params["argv"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
523 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
524 if params["workdir"] == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
525 os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
526 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
527 os.chdir(params["workdir"])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
528
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
529 # 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
530 # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
531 sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
532 self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
533
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
534 # generate a profile object
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
535 self.prof = PyProfile.PyProfile(sys.argv[0])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
536
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
537 if params["erase"]:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
538 self.prof.erase()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
539 self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
540 sys.modules['__main__'] = self.debugMod
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
541 script = ''
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
542 with codecs.open(sys.argv[0], encoding=self.__coding) as fp:
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
543 script = fp.read()
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
544 if script and not script.endswith('\n'):
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7635
diff changeset
545 script += '\n'
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
546
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
547 if script:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
548 self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
549 res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
550 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
551 self.prof.run(script)
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
552 atexit._run_exitfuncs()
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
553 except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
554 res = exc.code
5540
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
555 atexit._run_exitfuncs()
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
556 except Exception:
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
557 excinfo = sys.exc_info()
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
558 self.__unhandled_exception(*excinfo)
40992b7a60a9 Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5536
diff changeset
559
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
560 self.prof.save()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
561 self.progTerminated(res)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
562
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
563 elif method == "ExecuteStatement":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
564 if self.buffer:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
565 self.buffer = self.buffer + '\n' + params["statement"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
566 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
567 self.buffer = params["statement"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
568
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
569 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
570 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
571 except (OverflowError, SyntaxError, ValueError):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
572 # Report the exception
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
573 sys.last_type, sys.last_value, sys.last_traceback = (
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
574 sys.exc_info())
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
575 self.sendJsonCommand("ClientOutput", {
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
576 "text": "".join(traceback.format_exception_only(
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
577 sys.last_type, sys.last_value))
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
578 })
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
579 self.buffer = ''
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
580 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
581 if code is None:
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
582 self.sendJsonCommand("ResponseContinue", {})
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
583 return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
584 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
585 self.buffer = ''
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
586
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
587 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
588 if self.running is None:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7594
diff changeset
589 exec(code, self.debugMod.__dict__) # secok
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
590 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
591 if self.currentThread is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
592 # program has terminated
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
593 self.running = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
594 _globals = self.debugMod.__dict__
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
595 _locals = _globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
596 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
597 cf = self.currentThread.getCurrentFrame()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
598 # program has terminated
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
599 if cf is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
600 self.running = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
601 _globals = self.debugMod.__dict__
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
602 _locals = _globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
603 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
604 frmnr = self.framenr
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
605 while cf is not None and frmnr > 0:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
606 cf = cf.f_back
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
607 frmnr -= 1
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
608 _globals = cf.f_globals
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
609 _locals = (
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
610 self.currentThread.getFrameLocals(
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
611 self.framenr))
7249
0bf517e60f54 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7074
diff changeset
612 ## reset sys.stdout to our redirector
0bf517e60f54 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7074
diff changeset
613 ## (unconditionally)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
614 if "sys" in _globals:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
615 __stdout = _globals["sys"].stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
616 _globals["sys"].stdout = self.writestream
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7594
diff changeset
617 exec(code, _globals, _locals) # secok
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
618 _globals["sys"].stdout = __stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
619 elif "sys" in _locals:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
620 __stdout = _locals["sys"].stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
621 _locals["sys"].stdout = self.writestream
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7594
diff changeset
622 exec(code, _globals, _locals) # secok
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
623 _locals["sys"].stdout = __stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
624 else:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7594
diff changeset
625 exec(code, _globals, _locals) # secok
5120
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 self.currentThread.storeFrameLocals(self.framenr)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
628 except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
629 self.progTerminated(exc.code)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
630 except Exception:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
631 # Report the exception and the traceback
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
632 tlist = []
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
633 try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
634 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
635 sys.last_type = exc_type
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
636 sys.last_value = exc_value
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
637 sys.last_traceback = exc_tb
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
638 tblist = traceback.extract_tb(exc_tb)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
639 del tblist[:1]
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
640 tlist = traceback.format_list(tblist)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
641 if tlist:
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
642 tlist.insert(
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
643 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
644 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
645 exc_type, exc_value))
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
646 finally:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
647 tblist = exc_tb = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
648
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
649 self.sendJsonCommand("ClientOutput", {
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
650 "text": "".join(tlist)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
651 })
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
652
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
653 self.sendJsonCommand("ResponseOK", {})
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
654
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
655 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
656 self.currentThreadExec.step(True)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
657 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
658
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
659 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
660 self.currentThreadExec.step(False)
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
661 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
662
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
663 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
664 self.currentThreadExec.stepOut()
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
665 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
666
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
667 elif method == "RequestStepQuit":
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
668 if self.passive:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
669 self.progTerminated(42)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
670 else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
671 self.set_quit()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
672 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
673
5658
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
674 elif method == "RequestMoveIP":
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
675 newLine = params["newLine"]
e5f6fe5855fd move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5657
diff changeset
676 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
677
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
678 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
679 self.currentThreadExec.go(params["special"])
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
680 self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
681
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
682 elif method == "RawInput":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
683 # 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
684 # event loop.
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
685 self.rawLine = params["input"]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
686 self.eventExit = True
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
687
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
688 elif method == "RequestBreakpoint":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
689 if params["setBreakpoint"]:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
690 if params["condition"] in ['None', '']:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
691 cond = None
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
692 elif params["condition"] is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
693 try:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
694 cond = compile(params["condition"], '<string>', 'eval')
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
695 except SyntaxError:
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
696 self.sendJsonCommand("ResponseBPConditionError", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
697 "filename": params["filename"],
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
698 "line": params["line"],
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
699 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
700 return
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
701 else:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
702 cond = None
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
703
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
704 Breakpoint(
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
705 params["filename"], params["line"], params["temporary"],
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
706 cond)
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
707 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
708 Breakpoint.clear_break(params["filename"], params["line"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
709
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
710 elif method == "RequestBreakpointEnable":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
711 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
712 if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
713 if params["enable"]:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
714 bp.enable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
715 else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
716 bp.disable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
717
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
718 elif method == "RequestBreakpointIgnore":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
719 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
720 if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
721 bp.ignore = params["count"]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
722
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
723 elif method == "RequestWatch":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
724 if params["setWatch"]:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
725 if params["condition"].endswith(
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
726 ('??created??', '??changed??')):
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
727 compiledCond, flag = params["condition"].split()
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
728 else:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
729 compiledCond = params["condition"]
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
730 flag = ''
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
731
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
732 try:
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5178
diff changeset
733 compiledCond = compile(compiledCond, '<string>', 'eval')
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
734 except SyntaxError:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
735 self.sendJsonCommand("ResponseWatchConditionError", {
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
736 "condition": params["condition"],
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
737 })
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
738 return
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
739 Watch(
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
740 params["condition"], compiledCond, flag,
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
741 params["temporary"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
742 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
743 Watch.clear_watch(params["condition"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
744
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
745 elif method == "RequestWatchEnable":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
746 wp = Watch.get_watch(params["condition"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
747 if wp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
748 if params["enable"]:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
749 wp.enable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
750 else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
751 wp.disable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
752
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
753 elif method == "RequestWatchIgnore":
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170 5171
diff changeset
754 wp = Watch.get_watch(params["condition"])
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
755 if wp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
756 wp.ignore = params["count"]
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 == "RequestShutdown":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
759 self.sessionClose()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
760
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
761 elif method == "RequestCompletion":
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
762 self.__completionList(params["text"])
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
763
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
764 elif method == "RequestUTDiscover":
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
765 if params["syspath"]:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
766 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
767
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
768 discoveryStart = params["discoverystart"]
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
769 if not discoveryStart:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
770 discoveryStart = params["workdir"]
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
771
7071
c9ff30a1acbb Fix unittest discovery, allow discovery start in project subdirectory.
Mikhail Terekhov
parents: 7031
diff changeset
772 top_level_dir = params["workdir"]
c9ff30a1acbb Fix unittest discovery, allow discovery start in project subdirectory.
Mikhail Terekhov
parents: 7031
diff changeset
773
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
774 os.chdir(params["discoverystart"])
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
775
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
776 # 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
777 # 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
778 sys.excepthook = self.__unhandled_exception
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
779 self.__interceptSignals()
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
780
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
781 try:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
782 import unittest
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
783 testLoader = unittest.TestLoader()
7074
7da5a5a14469 Fixed a code style issue in Mikhails changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7071
diff changeset
784 test = testLoader.discover(
7da5a5a14469 Fixed a code style issue in Mikhails changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7071
diff changeset
785 discoveryStart, top_level_dir=top_level_dir)
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
786 if (hasattr(testLoader, "errors") and
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
787 bool(testLoader.errors)):
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
788 self.sendJsonCommand("ResponseUTDiscover", {
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
789 "testCasesList": [],
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
790 "exception": "DiscoveryError",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
791 "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
792 })
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
793 else:
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
794 testsList = self.__assembleTestCasesList(test,
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
795 discoveryStart)
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
796 self.sendJsonCommand("ResponseUTDiscover", {
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
797 "testCasesList": testsList,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
798 "exception": "",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
799 "message": "",
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
800 })
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
801 except Exception:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
802 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
803 self.sendJsonCommand("ResponseUTDiscover", {
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
804 "testCasesList": [],
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
805 "exception": exc_type.__name__,
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
806 "message": str(exc_value),
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
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
809 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
810 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
811 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
812 sys.path.insert(
889ed5ff7a68 Fixed a few issues in the modernized Python 3 debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5129
diff changeset
813 0, os.path.dirname(os.path.abspath(params["filename"])))
7071
c9ff30a1acbb Fix unittest discovery, allow discovery start in project subdirectory.
Mikhail Terekhov
parents: 7031
diff changeset
814 top_level_dir = None
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
815 if params["workdir"]:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
816 os.chdir(params["workdir"])
7071
c9ff30a1acbb Fix unittest discovery, allow discovery start in project subdirectory.
Mikhail Terekhov
parents: 7031
diff changeset
817 top_level_dir = params["workdir"]
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
818 else:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
819 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
820
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
821 # 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
822 # we report on all unhandled exceptions
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
823 sys.excepthook = self.__unhandled_exception
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
824 self.__interceptSignals()
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
825
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
826 try:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
827 import unittest
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
828 testLoader = unittest.TestLoader()
6897
701256697721 UnittestDialog: refined the handling of "Rerun Failed".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6896
diff changeset
829 if params["discover"]:
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
830 discoveryStart = params["discoverystart"]
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
831 if not discoveryStart:
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
832 discoveryStart = params["workdir"]
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
833 if params["testcases"]:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
834 self.test = testLoader.loadTestsFromNames(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
835 params["testcases"])
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
836 else:
7074
7da5a5a14469 Fixed a code style issue in Mikhails changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7071
diff changeset
837 self.test = testLoader.discover(
7da5a5a14469 Fixed a code style issue in Mikhails changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7071
diff changeset
838 discoveryStart, top_level_dir=top_level_dir)
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
839 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
840 if params["filename"]:
7769
c9f64088224b DebugClientBase: changed code to get rid of the use of the deprecated imp module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
841 spec = importlib.util.spec_from_file_location(
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
842 params["testname"], params["filename"])
7769
c9f64088224b DebugClientBase: changed code to get rid of the use of the deprecated imp module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7707
diff changeset
843 utModule = importlib.util.module_from_spec(spec)
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
844 else:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
845 utModule = None
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
846 if params["failed"]:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
847 if utModule:
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
848 failed = [t.split(".", 1)[1]
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
849 for t in params["failed"]]
6894
df83ac87e0db UnittestDialog: added capability to auto-discover tests.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6892
diff changeset
850 else:
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
851 failed = params["failed"][:]
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
852 self.test = testLoader.loadTestsFromNames(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
853 failed, utModule)
6896
3716c4af48bb UnittestDialog: did some refinements and error corrections.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6894
diff changeset
854 else:
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
855 self.test = testLoader.loadTestsFromName(
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
856 params["testfunctionname"], utModule)
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
857 except Exception:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
858 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
859 self.sendJsonCommand("ResponseUTPrepared", {
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
860 "count": 0,
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
861 "exception": exc_type.__name__,
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
862 "message": str(exc_value),
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
863 })
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
864 return
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
865
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
866 # generate a coverage object
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
867 if params["coverage"]:
7427
362cd1b6f81a coverage: updated coverage.py to 5.0.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7423
diff changeset
868 from coverage import Coverage
362cd1b6f81a coverage: updated coverage.py to 5.0.3.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7423
diff changeset
869 self.cover = Coverage(
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
870 auto_data=True,
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
871 data_file="{0}.coverage".format(
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
872 os.path.splitext(params["coveragefile"])[0]))
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
873 if params["coverageerase"]:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
874 self.cover.erase()
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
875 else:
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
876 self.cover = None
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
877
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
878 if params["debug"]:
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
879 Breakpoint.clear_all_breaks()
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
880 Watch.clear_all_watches()
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
881
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
882 self.sendJsonCommand("ResponseUTPrepared", {
5125
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
883 "count": self.test.countTestCases(),
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
884 "exception": "",
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
885 "message": "",
eb1b3e0577e4 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5124
diff changeset
886 })
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
887
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
888 elif method == "RequestUTRun":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
889 from DCTestResult import DCTestResult
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
890 self.disassembly = None
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
891 self.testResult = DCTestResult(self, params["failfast"])
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
892 if self.cover:
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
893 self.cover.start()
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
894 self.debugging = params["debug"]
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
895 if params["debug"]:
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
896 locals_ = locals()
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
897 self.threads.clear()
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
898 self.attachThread(mainThread=True)
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
899 sys.setprofile(None)
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
900 self.mainThread.run(
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
901 "result = self.test.run(self.testResult)\n",
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
902 localsDict=locals_)
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
903 result = locals_["result"]
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
904 else:
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
905 result = self.test.run(self.testResult)
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
906 if self.cover:
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
907 self.cover.stop()
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
908 self.cover.save()
6904
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
909 self.sendJsonCommand("ResponseUTFinished", {
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
910 "status": 0 if result.wasSuccessful() else 1,
3f35037a08d4 Unit Test: added capability to run test with debugger support and to stop the test on the first error or failure.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6901
diff changeset
911 })
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
912
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
913 elif method == "RequestUTStop":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
914 self.testResult.stop()
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 == "ResponseForkTo":
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
917 # this results from a separate event loop
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
918 self.fork_child = (params["target"] == 'child')
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
919 self.eventExit = True
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
920
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
921 def __assembleTestCasesList(self, suite, start):
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
922 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
923 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
924 suite.
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
925
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
926 @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
927 @type unittest.TestSuite
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
928 @param start name of directory discovery was started at
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
929 @type str
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
930 @return list of tuples containing the test case ID, a short description
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
931 and the path of the test file name
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
932 @rtype list of tuples of (str, str, str)
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
933 """
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
934 import unittest
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
935 testCases = []
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
936 for test in suite:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
937 if isinstance(test, unittest.TestSuite):
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
938 testCases.extend(self.__assembleTestCasesList(test, start))
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
939 else:
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
940 testId = test.id()
7250
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
941 if ("ModuleImportFailure" not in testId and
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
942 "LoadTestsFailure" not in testId and
d8bdc55aee1a Started to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
943 "_FailedTest" not in testId):
6908
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
944 filename = os.path.join(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
945 start,
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
946 test.__module__.replace(".", os.sep) + ".py")
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
947 testCases.append(
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
948 (test.id(), test.shortDescription(), filename)
a56b500d7d2d UnittestDialog: added a message for the situation, where discovery results are present but none are selected when Start is pressed and added the capability to open the source file by double clicking a discovery entry.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6904
diff changeset
949 )
6901
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
950 return testCases
f2c774c8db7e UnittestDialog: implemented the remote part fo 'discover only'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6899
diff changeset
951
7707
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
952 def setDisassembly(self, disassembly):
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
953 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
954 Public method to store a disassembly of the code object raising an
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
955 exception.
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
956
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
957 @param disassembly dictionary containing the disassembly information
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
958 @type dict
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
959 """
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
960 self.disassembly = disassembly
6abcf4275d0e Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
961
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
962 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
963 """
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
964 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
965
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
966 @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
967 @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
968 @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
969 response
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
970 @type dict
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
971 """
5129
e4ab234cf071 Cleaned up the modified code for the modernized debugger interface (Python3 variant).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5128
diff changeset
972 cmd = prepareJsonCommand(method, params)
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
973
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
974 self.writestream.write_p(cmd)
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
975 self.writestream.flush()
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
976
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
977 def sendClearTemporaryBreakpoint(self, filename, lineno):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
978 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
979 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
980
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
981 @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
982 @type str
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
983 @param lineno linenumber of the bp
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
984 @type int
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
985 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
986 self.sendJsonCommand("ResponseClearBreakpoint", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
987 "filename": filename,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
988 "line": lineno
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
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
991 def sendClearTemporaryWatch(self, condition):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
992 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
993 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
994
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
995 @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
996 @type str
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
997 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
998 self.sendJsonCommand("ResponseClearWatch", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
999 "condition": condition,
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
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1002 def sendResponseLine(self, stack):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1003 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1004 Public method to send the current call stack.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1005
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1006 @param stack call stack
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1007 @type list
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1008 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
1009 self.sendJsonCommand("ResponseLine", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1010 "stack": stack,
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
5140
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1013 def sendCallTrace(self, event, fromInfo, toInfo):
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1014 """
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1015 Public method to send a call trace entry.
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1016
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1017 @param event trace event (call or return)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1018 @type str
5140
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1019 @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
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
01484c0afbc6 Worked on the last TODOs for the modernized debugger protocol.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5135
diff changeset
1022 @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
1023 @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
1024 as keys
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1025 """
5128
b6cbdba69967 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5125
diff changeset
1026 self.sendJsonCommand("CallTrace", {
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1027 "event":