DebugClients/Python3/DebugClientBase.py

Thu, 01 Sep 2016 19:00:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 01 Sep 2016 19:00:46 +0200
branch
jsonrpc
changeset 5124
1ba8ee313b57
parent 5120
c5189d404cc7
child 5125
eb1b3e0577e4
permissions
-rw-r--r--

Continued modernizing the debugger interface.

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
4631
5c1a96925da4 Updated copyright for 2016.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4604
diff changeset
3 # Copyright (c) 2009 - 2016 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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import traceback
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import time
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import imp
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
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
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
23 import DebugProtocol
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import DebugClientCapabilities
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
25 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
26 from AsyncFile import AsyncFile, AsyncPendingWrite
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 from DebugConfig import ConfigVarTypeStrings
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 from FlexCompleter import Completer
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4370
diff changeset
29 from DebugUtilities import getargvalues, formatargvalues
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 DebugClientInstance = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
34 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
36
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
37 def DebugClientInput(prompt="", echo=True):
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 Replacement for the standard input builtin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 This function works with the split debugger.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
43 @param prompt prompt to be shown (string)
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
44 @param echo flag indicating to echo the output (boolean)
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
45 @return result of the input() call
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 if DebugClientInstance is None or not DebugClientInstance.redirect:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 return DebugClientOrigInput(prompt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 72
diff changeset
50 return DebugClientInstance.input(prompt, echo)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 # Use our own input().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 DebugClientOrigInput = __builtins__.__dict__['input']
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 __builtins__.__dict__['input'] = DebugClientInput
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 except (AttributeError, KeyError):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 import __main__
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 DebugClientOrigInput = __main__.__builtins__.__dict__['input']
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 __main__.__builtins__.__dict__['input'] = DebugClientInput
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
61 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
63
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 def DebugClientFork():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 Replacement for the standard os.fork().
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
67
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
68 @return result of the fork() call
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 if DebugClientInstance is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 return DebugClientOrigFork()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 return DebugClientInstance.fork()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 # use our own fork().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if 'fork' in dir(os):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 DebugClientOrigFork = os.fork
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 os.fork = DebugClientFork
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
80 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
82
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 def DebugClientClose(fd):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 Replacement for the standard os.close(fd).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 @param fd open file descriptor to be closed (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 if DebugClientInstance is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 DebugClientOrigClose(fd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 DebugClientInstance.close(fd)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 # use our own close().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 if 'close' in dir(os):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 DebugClientOrigClose = os.close
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 os.close = DebugClientClose
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
99 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
101
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 def DebugClientSetRecursionLimit(limit):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 Replacement for the standard sys.setrecursionlimit(limit).
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @param limit recursion limit (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 rl = max(limit, 64)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 setRecursionLimit(rl)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 DebugClientOrigSetRecursionLimit(rl + 64)
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 # use our own setrecursionlimit().
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 if 'setrecursionlimit' in dir(sys):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 DebugClientOrigSetRecursionLimit = sys.setrecursionlimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 sys.setrecursionlimit = DebugClientSetRecursionLimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 DebugClientSetRecursionLimit(sys.getrecursionlimit())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
118 ###############################################################################
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
120
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 class DebugClientBase(object):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 Class implementing the client side of the debugger.
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 It provides access to the Python interpeter from a debugger running in
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
126 another process whether or not the Qt event loop is running.
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 The protocol between the debugger and the client assumes that there will be
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 a single source of debugger commands and a single source of Python
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 statements. Commands and statement are always exactly one line and may be
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 interspersed.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 The protocol is as follows. First the client opens a connection to the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 debugger and then sends a series of one line commands. A command is either
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
135 &gt;Load&lt;, &gt;Step&lt;, &gt;StepInto&lt;, ... or a Python statement.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 See DebugProtocol.py for a listing of valid protocol tokens.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 A Python statement consists of the statement to execute, followed (in a
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
139 separate line) by &gt;OK?&lt;. If the statement was incomplete then the
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
140 response is &gt;Continue&lt;. If there was an exception then the response
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
141 is &gt;Exception&lt;. Otherwise the response is &gt;OK&lt;. The reason
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
142 for the &gt;OK?&lt; part is to provide a sentinal (ie. the responding
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
143 &gt;OK&lt;) after any possible output as a result of executing the command.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 The client may send any other lines at any other time which should be
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 interpreted as program output.
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 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
149 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
150 being debugged closing or crashing.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
152 <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
153 DebugClient classes. Do not instantiate it directly.
0
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 clientCapabilities = DebugClientCapabilities.HasAll
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 self.breakpoints = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.redirect = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 # The next couple of members are needed for the threaded version.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 # For this base class they contain static values for the non threaded
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 # debugger
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 # dictionary of all threads running
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.threads = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
171 # the "current" thread, basically the thread we are at a breakpoint
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
172 # for.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 self.currentThread = self
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 # special objects representing the main scripts thread and frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.mainThread = self
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.mainFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 self.framenr = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 # The context to run the debugged program in.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 self.debugMod = imp.new_module('__main__')
3729
b6eda7d63e4c Debug viewer always active.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3640
diff changeset
182 self.debugMod.__dict__['__builtins__'] = __builtins__
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 # The list of complete lines to execute.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 self.buffer = ''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 # The list of regexp objects to filter variables against
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.globalsFilterObjects = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 self.localsFilterObjects = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
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
191 self.pendingResponse = DebugProtocol.ResponseOK
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
192 self._fncache = {}
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 self.dircache = []
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
194 ## self.inRawMode = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.mainProcStr = None # used for the passive mode
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self.passive = False # used to indicate the passive mode
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.running = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.test = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.tracePython = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 self.debugging = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.fork_auto = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.fork_child = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.readstream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 self.writestream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.errorstream = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.pollingDisabled = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2157
diff changeset
210 self.callTraceEnabled = False
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2157
diff changeset
211 self.__newCallTraceEnabled = False
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2157
diff changeset
212
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 self.skipdirs = sys.path[:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.variant = 'You should not see this'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 # commandline completion stuff
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 self.complete = Completer(self.debugMod.__dict__).complete
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.compile_command = codeop.CommandCompiler()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
43
2fdc635b106a Reverted the last change to the Python3 debugger backend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
222 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
223 self.defaultCoding = 'utf-8'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 self.__coding = self.defaultCoding
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.noencoding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 def getCoding(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 Public method to return the current coding.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @return codec name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 return self.__coding
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 def __setCoding(self, filename):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 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
238
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 @param filename name of the file to inspect (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 if self.noencoding:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 self.__coding = sys.getdefaultencoding()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 default = 'utf-8'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 f = open(filename, 'rb')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 # read the first and second line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 text = f.readline()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 text = "{0}{1}".format(text, f.readline())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 f.close()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 except IOError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.__coding = default
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 for l in text.splitlines():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 m = self.coding_re.search(l)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 if m:
43
2fdc635b106a Reverted the last change to the Python3 debugger backend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
258 self.__coding = m.group(1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 self.__coding = default
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
262 def attachThread(self, target=None, args=None, kwargs=None,
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
263 mainThread=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 Public method to setup a thread for DebugClient to debug.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
267 If mainThread is non-zero, then we are attaching to the already
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 started mainthread of the app and the rest of the args are ignored.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
270 @param target the start function of the target thread (i.e. the
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
271 user code)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @param args arguments to pass to target
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 @param kwargs keyword arguments to pass to target
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
274 @param mainThread True, if we are attaching to the already
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 started mainthread of the app
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 if self.debugging:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 sys.setprofile(self.profile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 def __dumpThreadList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
282 Private method to send the list of threads.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 threadList = []
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
285 if self.threads and self.currentThread:
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
286 # indication for the threaded debugger
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 currentId = self.currentThread.get_ident()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 for t in self.threads.values():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 d = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 d["id"] = t.get_ident()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 d["name"] = t.get_name()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 d["broken"] = t.isBroken()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 threadList.append(d)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 currentId = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 d = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 d["id"] = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 d["name"] = "MainThread"
4063
b7269498aa95 Fixed a serious issue handling 'non-error' exceptions in the debugger. This bug was about 10 years old.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
299 if hasattr(self, "isBroken"):
b7269498aa95 Fixed a serious issue handling 'non-error' exceptions in the debugger. This bug was about 10 years old.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
300 d["broken"] = self.isBroken()
b7269498aa95 Fixed a serious issue handling 'non-error' exceptions in the debugger. This bug was about 10 years old.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
301 else:
b7269498aa95 Fixed a serious issue handling 'non-error' exceptions in the debugger. This bug was about 10 years old.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
302 d["broken"] = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 threadList.append(d)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
305 ## self.write("{0}{1!r}\n".format(DebugProtocol.ResponseThreadList,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
306 ## (currentId, threadList)))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
307 self.__sendJsonCommand("ResponseThreadList", {
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
308 "currentID": currentId,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
309 "threadList": threadList,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
310 })
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
312 def input(self, prompt, echo=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 Public method to implement input() using the event loop.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 @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
317 @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
318 @return the entered string
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 """
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
320 ## self.write("{0}{1!r}\n".format(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
321 ## DebugProtocol.ResponseRaw, (prompt, echo)))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
322 self.__sendJsonCommand("RequestRaw", {
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
323 "prompt": prompt,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
324 "echo": echo,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
325 })
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
326 ## self.inRawMode = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.eventLoop(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 return self.rawLine
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 def __exceptionRaised(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 """
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2761
diff changeset
332 Private method called in the case of an exception.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 It ensures that the debug server is informed of the raised exception.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 """
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
336 ## self.pendingResponse = DebugProtocol.ResponseException
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
337 self.__sendJsonCommand("ResponseException", {})
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
339 def sessionClose(self, exit=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 """
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
341 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
342 terminate.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 @param exit flag indicating to terminate (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 self.set_quit()
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
348 except Exception:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 # clean up asyncio.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 self.disconnect()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.debugging = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 # 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
356 # might be overkill as normally stdin, stdout and stderr
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 # 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
358 self.readstream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 self.writestream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 self.errorstream.close(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 if exit:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 # Ok, go away.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 sys.exit()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
366 def __compileFileSource(self, filename, mode='exec'):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 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
369
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 @param filename name of the source file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 @param mode kind of code to be generated (string, exec or eval)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 @return compiled code object (None in case of errors)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
374 with open(filename, encoding=self.__coding) as fp:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 statement = fp.read()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 code = compile(statement + '\n', filename, mode)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 except SyntaxError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 exctype, excval, exctb = sys.exc_info()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 try:
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
382 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
383 filename = excval.filename
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
384 lineno = excval.lineno
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
385 charno = excval.offset
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
386 except (AttributeError, ValueError):
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
387 message = ""
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
388 filename = ""
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
389 lineno = 0
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
390 charno = 0
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
391 self.sendSyntaxError(message, filename, lineno, charno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 return code
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
396 def handleLine(self, line):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 Public method to handle the receipt of a complete line.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
400 It first looks for a valid protocol token at the start of the line.
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
401 Thereafter it trys to execute the lines accumulated so far.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 @param line the received line
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 # Remove any newline.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 if line[-1] == '\n':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 line = line[:-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 ## printerr(line) ##debug
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
410
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
411 if "jsonrpc" in line:
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
412 return self.handleJsonCommand(line)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 eoc = line.find('<')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 if eoc >= 0 and line[0] == '>':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 # Get the command part and any argument.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 cmd = line[:eoc + 1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 arg = line[eoc + 1:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
421 ## if cmd == DebugProtocol.RequestVariables:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
422 ## frmnr, scope, filter = eval(arg.replace("u'", "'"))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
423 ## self.__dumpVariables(int(frmnr), int(scope), filter)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
424 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
425 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
426 ## if cmd == DebugProtocol.RequestVariable:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
427 ## var, frmnr, scope, filter = eval(arg.replace("u'", "'"))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
428 ## self.__dumpVariable(var, int(frmnr), int(scope), filter)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
429 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
430 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
431 ## if cmd == DebugProtocol.RequestThreadList:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
432 ## self.__dumpThreadList()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
433 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
434 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
435 ## if cmd == DebugProtocol.RequestThreadSet:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
436 ## tid = eval(arg)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
437 ## if tid in self.threads:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
438 ## self.setCurrentThread(tid)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
439 ## self.write(DebugProtocol.ResponseThreadSet + '\n')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
440 ## stack = self.currentThread.getStack()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
441 ## self.write('{0}{1!r}\n'.format(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
442 ## DebugProtocol.ResponseStack, stack))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
443 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
444 ##
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
445 ## if cmd == DebugProtocol.RequestStep:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
446 ## self.currentThread.step(True)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
447 ## self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
448 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
449 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
450 ## if cmd == DebugProtocol.RequestStepOver:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
451 ## self.currentThread.step(False)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
452 ## self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
453 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
454 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
455 ## if cmd == DebugProtocol.RequestStepOut:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
456 ## self.currentThread.stepOut()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
457 ## self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
458 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
459 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
460 ## if cmd == DebugProtocol.RequestStepQuit:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
461 ## if self.passive:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
462 ## self.progTerminated(42)
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 ## self.set_quit()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
465 ## self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
466 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
467 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
468 ## if cmd == DebugProtocol.RequestContinue:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
469 ## special = int(arg)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
470 ## self.currentThread.go(special)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
471 ## self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
472 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
473 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
474 ## if cmd == DebugProtocol.RequestOK:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
475 ## self.write(self.pendingResponse + '\n')
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
476 ## self.pendingResponse = DebugProtocol.ResponseOK
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
477 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
478 ##
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
479 ## if cmd == DebugProtocol.RequestCallTrace:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
480 ## if arg.strip().lower() == "on":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
481 ## callTraceEnabled = True
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
482 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
483 ## callTraceEnabled = False
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
484 ## if self.debugging:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
485 ## self.callTraceEnabled = callTraceEnabled
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
486 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
487 ## self.__newCallTraceEnabled = callTraceEnabled
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
488 ## # remember for later
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
489 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
490 ##
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
491 ## if cmd == DebugProtocol.RequestEnv:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
492 ## env = eval(arg.replace("u'", "'"))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
493 ## for key, value in env.items():
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
494 ## if key.endswith("+"):
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
495 ## 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
496 ## os.environ[key[:-1]] += value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
497 ## else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
498 ## os.environ[key[:-1]] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
499 ## else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
500 ## os.environ[key] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
501 ## return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
502 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
503 ## if cmd == DebugProtocol.RequestLoad:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
504 ## self._fncache = {}
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
505 ## self.dircache = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
506 ## sys.argv = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
507 ## wd, fn, args, tracePython = arg.split('|')
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
508 ## self.__setCoding(fn)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
509 ## sys.argv.append(fn)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
510 ## sys.argv.extend(eval(args))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
511 ## 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
512 ## if wd == '':
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
513 ## os.chdir(sys.path[1])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
514 ## else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
515 ## os.chdir(wd)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
516 ## tracePython = int(tracePython)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
517 ## self.running = sys.argv[0]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
518 ## self.mainFrame = None
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
519 ## self.inRawMode = False
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
520 ## self.debugging = True
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
521 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
522 ## self.threads.clear()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
523 ## self.attachThread(mainThread=True)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
524 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
525 ## # 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
526 ## # 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
527 ## sys.excepthook = self.__unhandled_exception
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
528 ## self.__interceptSignals()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
529 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
530 ## # 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
531 ## # started
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
532 ## self.mainThread.clear_all_breaks()
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
533 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
534 ## self.mainThread.tracePython = tracePython
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
535 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
536 ## # 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
537 ## 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
538 ## sys.modules['__main__'] = self.debugMod
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
539 ## code = self.__compileFileSource(self.running)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
540 ## if code:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
541 ## self.callTraceEnabled = self.__newCallTraceEnabled
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
542 ## res = self.mainThread.run(code, self.debugMod.__dict__)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
543 ## self.progTerminated(res)
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
544 ## return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
545 ##
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
546 ## if cmd == DebugProtocol.RequestRun:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
547 ## sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
548 ## wd, fn, args = arg.split('|')
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
549 ## self.__setCoding(fn)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
550 ## sys.argv.append(fn)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
551 ## sys.argv.extend(eval(args))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
552 ## 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
553 ## if wd == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
554 ## os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
555 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
556 ## os.chdir(wd)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
557 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
558 ## self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
559 ## self.mainFrame = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
560 ## self.botframe = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
561 ## self.inRawMode = False
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
562 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
563 ## self.threads.clear()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
564 ## self.attachThread(mainThread=True)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
565 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
566 ## # set the system exception handling function to ensure, that
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
567 ## # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
568 ## sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
569 ## self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
570 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
571 ## self.mainThread.tracePython = False
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
572 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
573 ## self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
574 ## sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
575 ## res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
576 ## code = self.__compileFileSource(self.running)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
577 ## if code:
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 ## exec(code, self.debugMod.__dict__)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
580 ## except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
581 ## res = exc.code
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
582 ## atexit._run_exitfuncs()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
583 ## self.writestream.flush()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
584 ## self.progTerminated(res)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
585 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
586 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
587 ## if cmd == DebugProtocol.RequestProfile:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
588 ## sys.setprofile(None)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
589 ## import PyProfile
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
590 ## sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
591 ## wd, fn, args, erase = arg.split('|')
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
592 ## self.__setCoding(fn)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
593 ## sys.argv.append(fn)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
594 ## sys.argv.extend(eval(args))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
595 ## 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
596 ## if wd == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
597 ## os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
598 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
599 ## os.chdir(wd)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
600 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
601 ## # 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
602 ## # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
603 ## sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
604 ## self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
605 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
606 ## # generate a profile object
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
607 ## self.prof = PyProfile.PyProfile(sys.argv[0])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
608 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
609 ## if int(erase):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
610 ## self.prof.erase()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
611 ## self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
612 ## sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
613 ## fp = open(sys.argv[0], encoding=self.__coding)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
614 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
615 ## script = fp.read()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
616 ## finally:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
617 ## fp.close()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
618 ## if script:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
619 ## if not script.endswith('\n'):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
620 ## script += '\n'
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
621 ## self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
622 ## res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
623 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
624 ## self.prof.run(script)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
625 ## except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
626 ## res = exc.code
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
627 ## atexit._run_exitfuncs()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
628 ## self.prof.save()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
629 ## self.writestream.flush()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
630 ## self.progTerminated(res)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
631 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
632 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
633 ## if cmd == DebugProtocol.RequestCoverage:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
634 ## from coverage import coverage
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
635 ## sys.argv = []
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
636 ## wd, fn, args, erase = arg.split('@@')
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
637 ## self.__setCoding(fn)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
638 ## sys.argv.append(fn)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
639 ## sys.argv.extend(eval(args))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
640 ## 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
641 ## if wd == '':
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
642 ## os.chdir(sys.path[1])
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
643 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
644 ## os.chdir(wd)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
645 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
646 ## # 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
647 ## # we report on all unhandled exceptions
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
648 ## sys.excepthook = self.__unhandled_exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
649 ## self.__interceptSignals()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
650 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
651 ## # generate a coverage object
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
652 ## self.cover = coverage(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
653 ## auto_data=True,
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
654 ## data_file="{0}.coverage".format(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
655 ## os.path.splitext(sys.argv[0])[0]))
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
656 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
657 ## if int(erase):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
658 ## self.cover.erase()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
659 ## sys.modules['__main__'] = self.debugMod
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
660 ## self.debugMod.__dict__['__file__'] = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
661 ## fp = open(sys.argv[0], encoding=self.__coding)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
662 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
663 ## script = fp.read()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
664 ## finally:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
665 ## fp.close()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
666 ## if script:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
667 ## if not script.endswith('\n'):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
668 ## script += '\n'
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
669 ## code = compile(script, sys.argv[0], 'exec')
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
670 ## self.running = sys.argv[0]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
671 ## res = 0
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
672 ## self.cover.start()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
673 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
674 ## exec(code, self.debugMod.__dict__)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
675 ## except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
676 ## res = exc.code
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
677 ## atexit._run_exitfuncs()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
678 ## self.cover.stop()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
679 ## self.cover.save()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
680 ## self.writestream.flush()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
681 ## self.progTerminated(res)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
682 ## return
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
683 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
684 ## if cmd == DebugProtocol.RequestShutdown:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
685 ## self.sessionClose()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
686 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
687 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
688 ## if cmd == DebugProtocol.RequestBreak:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
689 ## fn, line, temporary, set, cond = arg.split('@@')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
690 ## line = int(line)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
691 ## set = int(set)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
692 ## temporary = int(temporary)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
693 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
694 ## if set:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
695 ## if cond == 'None' or cond == '':
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
696 ## cond = None
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
697 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
698 ## try:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
699 ## compile(cond, '<string>', 'eval')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
700 ## except SyntaxError:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
701 ## self.write('{0}{1},{2:d}\n'.format(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
702 ## DebugProtocol.ResponseBPConditionError,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
703 ## fn, line))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
704 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
705 ## self.mainThread.set_break(fn, line, temporary, cond)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
706 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
707 ## self.mainThread.clear_break(fn, line)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
708 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
709 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
710 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
711 ## if cmd == DebugProtocol.RequestBreakEnable:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
712 ## fn, line, enable = arg.split(',')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
713 ## line = int(line)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
714 ## enable = int(enable)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
715 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
716 ## bp = self.mainThread.get_break(fn, line)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
717 ## if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
718 ## if enable:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
719 ## bp.enable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
720 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
721 ## bp.disable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
722 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
723 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
724 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
725 ## if cmd == DebugProtocol.RequestBreakIgnore:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
726 ## fn, line, count = arg.split(',')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
727 ## line = int(line)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
728 ## count = int(count)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
729 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
730 ## bp = self.mainThread.get_break(fn, line)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
731 ## if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
732 ## bp.ignore = count
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
733 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
734 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
735 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
736 ## if cmd == DebugProtocol.RequestWatch:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
737 ## cond, temporary, set = arg.split('@@')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
738 ## set = int(set)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
739 ## temporary = int(temporary)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
740 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
741 ## if set:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
742 ## if not cond.endswith('??created??') and \
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
743 ## not cond.endswith('??changed??'):
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
744 ## try:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
745 ## compile(cond, '<string>', 'eval')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
746 ## except SyntaxError:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
747 ## self.write('{0}{1}\n'.format(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
748 ## DebugProtocol.ResponseWPConditionError, cond))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
749 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
750 ## self.mainThread.set_watch(cond, temporary)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
751 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
752 ## self.mainThread.clear_watch(cond)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
753 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
754 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
755 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
756 ## if cmd == DebugProtocol.RequestWatchEnable:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
757 ## cond, enable = arg.split(',')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
758 ## enable = int(enable)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
759 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
760 ## bp = self.mainThread.get_watch(cond)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
761 ## if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
762 ## if enable:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
763 ## bp.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 ## bp.disable()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
766 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
767 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
768 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
769 ## if cmd == DebugProtocol.RequestWatchIgnore:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
770 ## cond, count = arg.split(',')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
771 ## count = int(count)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
772 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
773 ## bp = self.mainThread.get_watch(cond)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
774 ## if bp is not None:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
775 ## bp.ignore = count
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
776 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
777 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
778 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
779 ## if cmd == DebugProtocol.RequestEval:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
780 ## try:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
781 ## value = eval(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
782 ## arg,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
783 ## self.currentThread.getCurrentFrame().f_globals,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
784 ## self.currentThread.getFrameLocals(self.framenr))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
785 ## self.currentThread.storeFrameLocals(self.framenr)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
786 ## except Exception:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
787 ## # Report the exception and the traceback
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
788 ## try:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
789 ## type, value, tb = sys.exc_info()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
790 ## sys.last_type = type
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
791 ## sys.last_value = value
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
792 ## sys.last_traceback = tb
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
793 ## tblist = traceback.extract_tb(tb)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
794 ## del tblist[:1]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
795 ## list = traceback.format_list(tblist)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
796 ## if list:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
797 ## list.insert(0, "Traceback (innermost last):\n")
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
798 ## list[len(list):] = \
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
799 ## traceback.format_exception_only(type, value)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
800 ## finally:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
801 ## tblist = tb = None
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
802 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
803 ## for l in list:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
804 ## self.write(l)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
805 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
806 ## self.write(DebugProtocol.ResponseException + '\n')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
807 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
808 ## else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
809 ## self.write(str(value) + '\n')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
810 ## self.write(DebugProtocol.ResponseOK + '\n')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
811 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
812 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
813 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
814 ## if cmd == DebugProtocol.RequestExec:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
815 ## _globals = self.currentThread.getCurrentFrame().f_globals
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
816 ## _locals = self.currentThread.getFrameLocals(self.framenr)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
817 ## try:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
818 ## code = compile(arg + '\n', '<stdin>', 'single')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
819 ## exec(code, _globals, _locals)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
820 ## self.currentThread.storeFrameLocals(self.framenr)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
821 ## except Exception:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
822 ## # Report the exception and the traceback
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
823 ## try:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
824 ## type, value, tb = sys.exc_info()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
825 ## sys.last_type = type
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
826 ## sys.last_value = value
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
827 ## sys.last_traceback = tb
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
828 ## tblist = traceback.extract_tb(tb)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
829 ## del tblist[:1]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
830 ## list = traceback.format_list(tblist)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
831 ## if list:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
832 ## list.insert(0, "Traceback (innermost last):\n")
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
833 ## list[len(list):] = \
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
834 ## traceback.format_exception_only(type, value)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
835 ## finally:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
836 ## tblist = tb = None
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
837 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
838 ## for l in list:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
839 ## self.write(l)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
840 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
841 ## self.write(DebugProtocol.ResponseException + '\n')
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
842 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
843 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
844 ##
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
845 ## if cmd == DebugProtocol.RequestBanner:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
846 ## self.write('{0}{1}\n'.format(DebugProtocol.ResponseBanner,
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
847 ## str(("Python {0}".format(sys.version),
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
848 ## socket.gethostname(), self.variant))))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
849 ## return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
850 ##
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
851 ## if cmd == DebugProtocol.RequestCapabilities:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
852 ## self.write('{0}{1:d}, "Python3"\n'.format(
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
853 ## DebugProtocol.ResponseCapabilities,
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
854 ## self.__clientCapabilities()))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
855 ## return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
856 ##
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
857 ## if cmd == DebugProtocol.RequestCompletion:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
858 ## self.__completionList(arg.replace("u'", "'"))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
859 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
860 ##
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
861 ## if cmd == DebugProtocol.RequestSetFilter:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
862 ## scope, filterString = eval(arg.replace("u'", "'"))
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
863 ## self.__generateFilterObjects(int(scope), filterString)
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
864 ## return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
865 ##
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
866 if cmd == DebugProtocol.RequestUTPrepare:
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
867 fn, tn, tfn, failed, cov, covname, erase = arg.split('|')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 sys.path.insert(0, os.path.dirname(os.path.abspath(fn)))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 os.chdir(sys.path[0])
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
870 failed = eval(failed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 # set the system exception handling function to ensure, that
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 # we report on all unhandled exceptions
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 sys.excepthook = self.__unhandled_exception
4366
9445c7cb991f Implemented a signal handler for the Python debug clients.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
875 self.__interceptSignals()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 import unittest
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 utModule = imp.load_source(tn, fn)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 try:
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
881 if failed:
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
882 self.test = unittest.defaultTestLoader\
3032
927a2f8b3669 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3021
diff changeset
883 .loadTestsFromNames(failed, utModule)
1499
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
884 else:
b4d0457afb15 Extended the unit test module to allow to rerun only failed tests of the last.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
885 self.test = unittest.defaultTestLoader\
3032
927a2f8b3669 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3021
diff changeset
886 .loadTestsFromName(tfn, utModule)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 self.test = unittest.defaultTestLoader\
3032
927a2f8b3669 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3021
diff changeset
889 .loadTestsFromModule(utModule)
4563
881340f4bd0c Fixed a few coding style issue related to 'blind except:' statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4543
diff changeset
890 except Exception:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 exc_type, exc_value, exc_tb = sys.exc_info()
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
892 self.write('{0}{1}\n'.format(
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
893 DebugProtocol.ResponseUTPrepared,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 str((0, str(exc_type), str(exc_value)))))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 self.__exceptionRaised()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 # generate a coverage object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 if int(cov):
33
597036b70646 Added a forgotten import statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 26
diff changeset
900 from coverage import coverage
3021
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2991
diff changeset
901 self.cover = coverage(
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2991
diff changeset
902 auto_data=True,
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
903 data_file="{0}.coverage".format(
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
904 os.path.splitext(covname)[0]))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 if int(erase):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906 self.cover.erase()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 self.cover = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909
3021
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2991
diff changeset
910 self.write('{0}{1}\n'.format(
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2991
diff changeset
911 DebugProtocol.ResponseUTPrepared,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 str((self.test.countTestCases(), "", ""))))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914
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
915 if cmd == DebugProtocol.RequestUTRun:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 from DCTestResult import DCTestResult
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 self.testResult = DCTestResult(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918 if self.cover:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 self.cover.start()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 self.test.run(self.testResult)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 if self.cover:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 self.cover.stop()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 self.cover.save()
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
924 self.write('{0}\n'.format(DebugProtocol.ResponseUTFinished))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926
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
927 if cmd == DebugProtocol.RequestUTStop:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 self.testResult.stop()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930
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
931 if cmd == DebugProtocol.ResponseForkTo:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 # this results from a separate event loop
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 self.fork_child = (arg == 'child')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 self.eventExit = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936
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
937 if cmd == DebugProtocol.RequestForkMode:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 self.fork_auto, self.fork_child = eval(arg)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940
5120
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
941 ## # If we are handling raw mode input then reset the mode and break out
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
942 ## # of the current event loop.
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
943 ## if self.inRawMode:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
944 ## self.inRawMode = False
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
945 ## self.rawLine = line
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
946 ## self.eventExit = True
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
947 ## return
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
948 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
949 ## if self.buffer:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
950 ## self.buffer = self.buffer + '\n' + line
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
951 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
952 ## self.buffer = line
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
953 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
954 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
955 ## 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
956 ## except (OverflowError, SyntaxError, ValueError):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
957 ## # Report the exception
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
958 ## sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
959 ## for l in traceback.format_exception_only(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
960 ## sys.last_type, sys.last_value):
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
961 ## self.write(l)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
962 ## self.buffer = ''
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
963 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
964 ## if code is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
965 ## self.pendingResponse = DebugProtocol.ResponseContinue
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
966 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
967 ## self.buffer = ''
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
968 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
969 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
970 ## if self.running is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
971 ## exec(code, self.debugMod.__dict__)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
972 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
973 ## if self.currentThread is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
974 ## # program has terminated
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
975 ## self.running = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
976 ## _globals = self.debugMod.__dict__
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
977 ## _locals = _globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
978 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
979 ## cf = self.currentThread.getCurrentFrame()
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
980 ## # program has terminated
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
981 ## if cf is None:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
982 ## self.running = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
983 ## _globals = self.debugMod.__dict__
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
984 ## _locals = _globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
985 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
986 ## frmnr = self.framenr
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
987 ## while cf is not None and frmnr > 0:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
988 ## cf = cf.f_back
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
989 ## frmnr -= 1
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
990 ## _globals = cf.f_globals
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
991 ## _locals = \
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
992 ## self.currentThread.getFrameLocals(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
993 ## self.framenr)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
994 ## # reset sys.stdout to our redirector (unconditionally)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
995 ## if "sys" in _globals:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
996 ## __stdout = _globals["sys"].stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
997 ## _globals["sys"].stdout = self.writestream
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
998 ## exec(code, _globals, _locals)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
999 ## _globals["sys"].stdout = __stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1000 ## elif "sys" in _locals:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1001 ## __stdout = _locals["sys"].stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1002 ## _locals["sys"].stdout = self.writestream
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1003 ## exec(code, _globals, _locals)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1004 ## _locals["sys"].stdout = __stdout
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1005 ## else:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1006 ## exec(code, _globals, _locals)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1007 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1008 ## self.currentThread.storeFrameLocals(self.framenr)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1009 ## except SystemExit as exc:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1010 ## self.progTerminated(exc.code)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1011 ## except Exception:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1012 ## # Report the exception and the traceback
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1013 ## try:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1014 ## 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
1015 ## sys.last_type = exc_type
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1016 ## sys.last_value = exc_value
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1017 ## sys.last_traceback = exc_tb
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1018 ## tblist = traceback.extract_tb(exc_tb)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1019 ## del tblist[:1]
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1020 ## list = traceback.format_list(tblist)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1021 ## if list:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1022 ## list.insert(0, "Traceback (innermost last):\n")
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1023 ## list[len(list):] = traceback.format_exception_only(
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1024 ## exc_type, exc_value)
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1025 ## finally:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1026 ## tblist = exc_tb = None
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1027 ##
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1028 ## for l in list:
c5189d404cc7 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5119
diff changeset
1029 ## self.write(l)
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1030
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1031 def handleJsonCommand(self, jsonStr):
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1032 """
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1033 Public method to handle a command serialized as a JSON string.
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1034 """
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1035 import json
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1036
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1037 try:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1038 commandDict = json.loads(jsonStr.strip())
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1039 except json.JSONDecodeError as err:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1040 printerr(str(err))
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1041 return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1042
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1043 method = commandDict["method"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1044 params = commandDict["params"]
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1045
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1046 if method == "RequestVariables":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1047 self.__dumpVariables(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1048 params["frameNumber"], params["scope"], params["filters"])
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1049 return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1050
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1051 if method == "RequestVariable":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1052 self.__dumpVariable(
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1053 params["variable"], params["frameNumber"],
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1054 params["scope"], params["filters"])
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1055 return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1056
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1057 if method == "RequestThreadList":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1058 self.__dumpThreadList()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1059 return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1060
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1061 if method == "RequestThreadSet":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1062 if params["threadID"] in self.threads:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1063 self.setCurrentThread(params["threadID"])
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1064 self.__sendJsonCommand("ResponseThreadSet", {})
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1065 stack = self.currentThread.getStack()
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1066 self.__sendJsonCommand("ResponseStack", {
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1067 "stack": stack,
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1068 })
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1069 return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1070
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1071 if method == "RequestCapabilities":
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1072 self.__sendJsonCommand("ResponseCapabilities", {
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1073 "capabilities": self.__clientCapabilities(),
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1074 "clientType": "Python3"
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1075 })
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1076 return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1077
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1078 if method == "RequestBanner":
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1079 self.__sendJsonCommand("ResponseBanner", {
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1080 "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
1081 "platform": socket.gethostname(),
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1082 "dbgclient": self.variant,
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1083 })
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1084 return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1085
5124
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1086 if method == "RequestSetFilter":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1087 self.__generateFilterObjects(params["scope"], params["filter"])
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1088 return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1089
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1090 if method == "RequestCallTrace":
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1091 if self.debugging:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1092 self.callTraceEnabled = params["enable"]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1093 else:
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1094 self.__newCallTraceEnabled = params["enable"]
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1095 # remember for later
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1096 return
1ba8ee313b57 Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5120
diff changeset
1097
5119
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1098 if method == "RequestEnvironment":
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1099 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
1100 if key.endswith("+"):
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1101 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
1102 os.environ[key[:-1]] += value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1103 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1104 os.environ[key[:-1]] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1105 else:
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1106 os.environ[key] = value
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1107 return
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1108
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1109 if method == "RequestLoad":
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1110 self._fncache = {}
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1111 self.dircache = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1112 sys.argv = []
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1113 self.__setCoding(params["filename"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1114 sys.argv.append(params["filename"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1115 sys.argv.extend(params["argv"])
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1116 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
1117 if params["workdir"] == '':
80bd41498eef Started with the modernization of the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5115
diff changeset
1118 os.chdir(