eric6/DebugClients/Python/DebugClientBase.py

Sat, 02 Jan 2021 15:18:36 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 02 Jan 2021 15:18:36 +0100
changeset 7937
181d1160f617
parent 7932
c4c6b2784eec
child 7973
e836d196e888
permissions
-rw-r--r--

Fixed some 'lambda' related issues by converting them to 'functools.partial'.

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