DebugClients/Python3/DebugBase.py

Wed, 20 Jul 2016 22:14:24 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 20 Jul 2016 22:14:24 +0200
branch
debugger speed
changeset 5046
d57f18f15f1a
parent 5045
50862a6a2c63
child 5048
9899fb545b1f
permissions
-rw-r--r--

Don't track the recursion limit by hand.

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: 4566
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 the debug 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 bdb
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import atexit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import inspect
4642
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
15 import ctypes
5044
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
16 import _thread
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
17 import time
4365
d97f2e05ae1b Enhanced the Python3 debugger a little bit in accordance with bdb.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
18 from inspect import CO_GENERATOR
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
20 from DebugProtocol import ResponseClearWatch, ResponseClearBreak, \
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
21 ResponseLine, ResponseSyntax, ResponseException, CallTrace
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
22 from DebugUtilities import getargvalues, formatargvalues
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
23 from BreakpointWatch import Breakpoint, Watch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 gRecursionLimit = 64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
27
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def printerr(s):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Module function used for debugging the debug client.
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 @param s data to be printed
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 sys.__stderr__.write('{0!s}\n'.format(s))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 sys.__stderr__.flush()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
37
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 def setRecursionLimit(limit):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Module function to set the recursion limit.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param limit recursion limit (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 global gRecursionLimit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 gRecursionLimit = limit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
47
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 class DebugBase(bdb.Bdb):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Class implementing base class of the debugger.
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 Provides simple wrapper methods around bdb for the 'owning' client to
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 call to step etc.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
55 # Don't thrust distutils.sysconfig.get_python_lib: possible case mismatch
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
56 # on Windows
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
57 lib = os.path.dirname(bdb.__file__)
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
58 # tuple required because it's accessed a lot of times by startswith method
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
59 pathsToSkip = ('<', os.path.dirname(__file__), bdb.__file__[:-1])
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
60 filesToSkip = {}
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
61
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
62 # cache for fixed file names
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
63 _fnCache = {}
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
64
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def __init__(self, dbgClient):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 @param dbgClient the owning client
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 bdb.Bdb.__init__(self)
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 self._dbgClient = dbgClient
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self._mainThread = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
76 self.tracePythonLibs(0)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
78 self.__isBroken = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.cFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 # current frame we are at
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.currentFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 # frame that we are stepping in, can be different than currentFrame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.stepFrame = None
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 # provide a hook to perform a hard breakpoint
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 # Use it like this:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 # if hasattr(sys, 'breakpoint): sys.breakpoint()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 sys.breakpoint = self.set_trace
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 # initialize parent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 bdb.Bdb.reset(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__recursionDepth = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.setRecursionDepth(inspect.currentframe())
5044
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
97
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
98 # background task to periodicaly check for client interactions
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
99 self.eventPollFlag = False
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
100 self.timer = _thread.start_new_thread(self.__eventPollTimer, ())
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
101
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
102 def __eventPollTimer(self):
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
103 """
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
104 Private method to set a flag every 0.5 s to check for new messages.
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
105 """
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
106 while True:
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
107 time.sleep(0.5)
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
108 self.eventPollFlag = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 def getCurrentFrame(self):
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 Public method to return the current frame.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @return the current frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
116 return self.currentFrame
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
4309
cc9c62f55413 Changed the Python debugger backends to evaluate statements entered into the shell in the frame selected in the local variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4293
diff changeset
118 def getFrameLocals(self, frmnr=0):
935
bf9ee1e00bc5 Fixed an issue in the Python debuggers related to the usage of the locals dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
119 """
4309
cc9c62f55413 Changed the Python debugger backends to evaluate statements entered into the shell in the frame selected in the local variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4293
diff changeset
120 Public method to return the locals dictionary of the current frame
cc9c62f55413 Changed the Python debugger backends to evaluate statements entered into the shell in the frame selected in the local variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4293
diff changeset
121 or a frame below.
935
bf9ee1e00bc5 Fixed an issue in the Python debuggers related to the usage of the locals dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
122
4309
cc9c62f55413 Changed the Python debugger backends to evaluate statements entered into the shell in the frame selected in the local variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4293
diff changeset
123 @keyparam frmnr distance of frame to get locals dictionary of. 0 is
cc9c62f55413 Changed the Python debugger backends to evaluate statements entered into the shell in the frame selected in the local variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4293
diff changeset
124 the current frame (int)
cc9c62f55413 Changed the Python debugger backends to evaluate statements entered into the shell in the frame selected in the local variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4293
diff changeset
125 @return locals dictionary of the frame
935
bf9ee1e00bc5 Fixed an issue in the Python debuggers related to the usage of the locals dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
126 """
4642
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
127 f = self.currentFrame
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
128 while f is not None and frmnr > 0:
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
129 f = f.f_back
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
130 frmnr -= 1
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
131 return f.f_locals
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
132
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
133 def storeFrameLocals(self, frmnr=0):
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
134 """
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
135 Public method to store the locals into the frame, so an access to
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
136 frame.f_locals returns the last data.
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
137
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
138 @keyparam frmnr distance of frame to store locals dictionary to. 0 is
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
139 the current frame (int)
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
140 """
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
141 cf = self.currentFrame
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
142 while cf is not None and frmnr > 0:
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
143 cf = cf.f_back
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
144 frmnr -= 1
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
145 ctypes.pythonapi.PyFrame_LocalsToFast(
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
146 ctypes.py_object(cf),
f18d5fb9a53b Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4631
diff changeset
147 ctypes.c_int(0))
935
bf9ee1e00bc5 Fixed an issue in the Python debuggers related to the usage of the locals dictionary.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
148
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 def step(self, traceMode):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 Public method to perform a step operation in this thread.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 @param traceMode If it is True, then the step is a step into,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 otherwise it is a step over.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 self.stepFrame = self.currentFrame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 if traceMode:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.currentFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.set_step()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 self.set_next(self.currentFrame)
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 def stepOut(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 Public method to perform a step out of the current call.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 self.stepFrame = self.currentFrame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.set_return(self.currentFrame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 def go(self, special):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 Public method to resume the thread.
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 It resumes the thread stopping only at breakpoints or exceptions.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 @param special flag indicating a special continue operation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.currentFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.set_continue(special)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 def setRecursionDepth(self, frame):
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 Public method to determine the current recursion depth.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 @param frame The current stack frame.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 self.__recursionDepth = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 while frame is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 self.__recursionDepth += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 frame = frame.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
193 def profileWithRecursion(self, frame, event, arg):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
2166
15b4e58d61d7 Fixed some typos in source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
195 Public method used to trace some stuff independent of the debugger
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 trace function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
198 @param frame current stack frame
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
199 @type frame object
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
200 @param event trace event
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
201 @type str
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
202 @param arg arguments
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
203 @type depends on the previous event parameter
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
204 @exception RuntimeError raised to indicate too many recursions
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
206 if event == 'return':
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.cFrame = frame.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.__recursionDepth -= 1
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
209 if self._dbgClient.callTraceEnabled:
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
210 self.__sendCallTrace(event, frame, self.cFrame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 elif event == 'call':
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
212 if self._dbgClient.callTraceEnabled:
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
213 self.__sendCallTrace(event, self.cFrame, frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 self.cFrame = frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.__recursionDepth += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 if self.__recursionDepth > gRecursionLimit:
3021
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2987
diff changeset
217 raise RuntimeError(
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2987
diff changeset
218 'maximum recursion depth exceeded\n'
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 '(offending frame is two down the stack)')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
221 def profile(self, frame, event, arg):
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
222 """
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
223 Public method used to trace some stuff independent of the debugger
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
224 trace function.
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
225
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
226 @param frame current stack frame
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
227 @type frame object
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
228 @param event trace event
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
229 @type str
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
230 @param arg arguments
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
231 @type depends on the previous event parameter
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
232 """
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
233 if event == 'return':
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
234 self.__sendCallTrace(event, frame, frame.f_back)
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
235 elif event == 'call':
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
236 self.__sendCallTrace(event, frame.f_back, frame)
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
237
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
238 def __sendCallTrace(self, event, fromFrame, toFrame):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
239 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
240 Private method to send a call/return trace.
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
241
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
242 @param event trace event
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
243 @type str
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
244 @param fromFrame originating frame
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
245 @type frame object
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
246 @param toFrame destination frame
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
247 @type frame object
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
248 """
5046
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
249 if not self.__skipFrame(fromFrame) and not self.__skipFrame(toFrame):
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
250 fromStr = "{0}:{1}:{2}".format(
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
251 self._dbgClient.absPath(self.fix_frame_filename(fromFrame)),
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
252 fromFrame.f_lineno,
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
253 fromFrame.f_code.co_name)
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
254 toStr = "{0}:{1}:{2}".format(
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
255 self._dbgClient.absPath(self.fix_frame_filename(toFrame)),
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
256 toFrame.f_lineno,
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
257 toFrame.f_code.co_name)
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
258 self._dbgClient.write("{0}{1}@@{2}@@{3}\n".format(
d57f18f15f1a Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
259 CallTrace, event[0], fromStr, toStr))
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
260
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 def trace_dispatch(self, frame, event, arg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
263 Public method reimplemented from bdb.py to do some special things.
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 This specialty is to check the connection to the debug server
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 for new events (i.e. new breakpoints) while we are going through
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 the code.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
269 @param frame The current stack frame
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
270 @type frame object
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
271 @param event The trace event
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
272 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 @param arg The arguments
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
274 @type depends on the previous event parameter
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 @return local trace function
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
276 @rtype trace function or None
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
277 @exception bdb.BdbQuit
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 if self.quitting:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
280 return # None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 # give the client a chance to push through new break points.
5044
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
283 if self.eventPollFlag:
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
284 self._dbgClient.eventPoll()
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
285 self.eventPollFlag = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
287 if event == 'line':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
288 if self.stop_here(frame) or self.break_here(frame):
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
289 self.user_line(frame)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
290 if self.quitting:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
291 raise bdb.BdbQuit
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
292 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 if event == 'call':
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
295 if self.botframe is None:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
296 # First call of dispatch since reset()
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
297 # (CT) Note that this may also be None!
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
298 self.botframe = frame.f_back
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
299 return self.trace_dispatch
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
300
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
301 if not (self.stop_here(frame) or
5045
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
302 self.__checkBreakInFrame(frame) or
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
303 Watch.watches != []):
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
304 # No need to trace this function
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
305 return
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
306 if self.quitting:
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
307 raise bdb.BdbQuit
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
308 return self.trace_dispatch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
310 if event == 'return':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
311 if self.stop_here(frame) or frame == self.returnframe:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
312 # Ignore return events in generator except when stepping.
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
313 if self.stopframe and frame.f_code.co_flags & CO_GENERATOR:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
314 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
315 # The program has finished if we have just left the first frame
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
316 if frame == self._dbgClient.mainFrame and \
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
317 self._mainThread:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
318 atexit._run_exitfuncs()
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
319 self._dbgClient.progTerminated(arg)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
320 elif frame is not self.stepFrame:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
321 self.stepFrame = None
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
322 self.user_line(frame)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
323
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
324 if self.quitting and not self._dbgClient.passive:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
325 raise bdb.BdbQuit
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
326 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
328 if event == 'exception':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
329 if not self.__skipFrame(frame):
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
330 # When stepping with next/until/return in a generator frame,
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
331 # skip the internal StopIteration exception (with no traceback)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
332 # triggered by a subiterator run with the 'yield from'
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
333 # statement.
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
334 if not (frame.f_code.co_flags & CO_GENERATOR and
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
335 arg[0] is StopIteration and arg[2] is None):
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
336 self.user_exception(frame, arg)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
337 if self.quitting:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
338 raise bdb.BdbQuit
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
339 # Stop at the StopIteration or GeneratorExit exception when the user
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
340 # has set stopframe in a generator by issuing a return command, or a
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
341 # next/until command at the last statement in the generator before the
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
342 # exception.
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
343 elif (self.stopframe and frame is not self.stopframe and
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
344 self.stopframe.f_code.co_flags & CO_GENERATOR and
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
345 arg[0] in (StopIteration, GeneratorExit)):
4365
d97f2e05ae1b Enhanced the Python3 debugger a little bit in accordance with bdb.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
346 self.user_exception(frame, arg)
d97f2e05ae1b Enhanced the Python3 debugger a little bit in accordance with bdb.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
347 if self.quitting:
d97f2e05ae1b Enhanced the Python3 debugger a little bit in accordance with bdb.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4309
diff changeset
348 raise bdb.BdbQuit
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
349 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
350
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
351 if event == 'c_call':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
352 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
353 if event == 'c_exception':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
354 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
355 if event == 'c_return':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
356 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
357 print('bdb.Bdb.dispatch: unknown debugging event: ', repr(event)) # __IGNORE_WARNING__
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 return self.trace_dispatch
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
360 def set_trace(self, frame=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
362 Public method reimplemented from bdb.py to do some special setup.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 @param frame frame to start debugging from
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 bdb.Bdb.set_trace(self, frame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 sys.setprofile(self.profile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 def set_continue(self, special):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
371 Public method reimplemented from bdb.py to always get informed of
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
372 exceptions.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 @param special flag indicating a special continue operation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 # Modified version of the one found in bdb.py
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 # Here we only set a new stop frame if it is a normal continue.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 if not special:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 self._set_stopinfo(self.botframe, None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 self._set_stopinfo(self.stopframe, None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 def set_quit(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
385 Public method to quit.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 It wraps call to bdb to clear the current frame properly.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.currentFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 sys.setprofile(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 bdb.Bdb.set_quit(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 def fix_frame_filename(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 Public method used to fixup the filename for a given frame.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 The logic employed here is that if a module was loaded
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 from a .pyc file, then the correct .py to operate with
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 should be in the same path as the .pyc. The reason this
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 logic is needed is that when a .pyc file is generated, the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 filename embedded and thus what is readable in the code object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 of the frame object is the fully qualified filepath when the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 pyc is generated. If files are moved from machine to machine
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 this can break debugging as the .pyc will refer to the .py
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 on the original machine. Another case might be sharing
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 code over a network... This logic deals with that.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 @param frame the frame object
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
409 @type frame object
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
410 @return fixed up file name
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
411 @rtype str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 # get module name from __file__
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
414 fn = frame.f_globals.get('__file__')
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
415 try:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
416 return self._fnCache[fn]
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
417 except KeyError:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
418 if fn and fn != frame.f_code.co_filename:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
419 absFilename = os.path.abspath(fn)
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
420 if absFilename.endswith(('.pyc', '.pyo')):
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
421 fixedName = absFilename[:-1]
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
422 if not os.path.exists(fixedName):
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
423 fixedName = absFilename
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
424 else:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
425 fixedName = absFilename
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
426 else:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
427 fixedName = frame.f_code.co_filename
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
428 # update cache
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
429 self._fnCache[fn] = fixedName
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
430 return fixedName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431
5045
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
432 def __checkBreakInFrame(self, frame):
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
433 """
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
434 Private method to check if the function / method has a line number
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
435 which is a breakpoint.
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
436 @param frame the frame object
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
437 @type frame object
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
438 @return Flag indicating a function / method with breakpoint
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
439 @rtype bool
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
440 """
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
441 try:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
442 return Breakpoint.breakInFrameCache[
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
443 frame.f_globals.get('__file__'),
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
444 frame.f_code.co_firstlineno]
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
445 except KeyError:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
446 filename = self.fix_frame_filename(frame)
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
447 if filename not in Breakpoint.breakInFile:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
448 Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'),
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
449 frame.f_code.co_firstlineno] = False
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
450 return False
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
451 lineNo = frame.f_code.co_firstlineno
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
452 lineNumbers = [lineNo]
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
453 # No need to handle special case if a lot of lines between
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
454 # (e.g. closure), because the additional lines won't cause a bp
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
455 for co_lno in frame.f_code.co_lnotab[1::2]:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
456 lineNo += co_lno
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
457 lineNumbers.append(lineNo)
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
458
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
459 for bp in Breakpoint.breakInFile[filename]:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
460 if bp in lineNumbers:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
461 Breakpoint.breakInFrameCache[
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
462 frame.f_globals.get('__file__'),
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
463 frame.f_code.co_firstlineno] = True
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
464 return True
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
465 Breakpoint.breakInFrameCache[frame.f_globals.get('__file__'),
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
466 frame.f_code.co_firstlineno] = False
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
467 return False
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
468
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 def break_here(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
471 Public method reimplemented from bdb.py to fix the filename from the
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
472 frame.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 See fix_frame_filename for more info.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 @param frame the frame object
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
477 @type frame object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
478 @return flag indicating the break status
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
479 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 """
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
481 filename = self.fix_frame_filename(frame)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
482 if (filename, frame.f_lineno) in Breakpoint.breaks:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
483 bp, flag = Breakpoint.effectiveBreak(
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
484 filename, frame.f_lineno, frame)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
485 if bp:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 # flag says ok to delete temp. bp
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
487 if flag and bp.temporary:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
488 self.__do_clearBreak(filename, frame.f_lineno)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
489 return True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
491 if Watch.watches != []:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
492 bp, flag = Watch.effectiveWatch(frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 if bp:
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
494 # flag says ok to delete temp. watch
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
495 if flag and bp.temporary:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 self.__do_clearWatch(bp.cond)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
501 def __do_clearBreak(self, filename, lineno):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 Private method called to clear a temporary breakpoint.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 @param filename name of the file the bp belongs to
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
506 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 @param lineno linenumber of the bp
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
508 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 """
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
510 Breakpoint.clear_break(filename, lineno)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
511 self._dbgClient.write('%s%s,%d\n' % (ResponseClearBreak, filename,
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
512 lineno))
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
513
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
514 def __do_clearWatch(self, cond):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
515 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
516 Private method called to clear a temporary watch expression.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
517
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
518 @param cond expression of the watch expression to be cleared
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
519 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
520 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
521 Watch.clear_watch(cond)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
522 self._dbgClient.write('%s%s\n' % (ResponseClearWatch, cond))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 def getStack(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 Public method to get the stack.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 @return list of lists with file name (string), line number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 and function name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 fr = self.cFrame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 while fr is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 fname = self._dbgClient.absPath(self.fix_frame_filename(fr))
2620
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
535 if not fname.startswith("<"):
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
536 fline = fr.f_lineno
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
537 ffunc = fr.f_code.co_name
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
538
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
539 if ffunc == '?':
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
540 ffunc = ''
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
541
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
542 if ffunc and not ffunc.startswith("<"):
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
543 argInfo = getargvalues(fr)
4293
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
544 try:
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
545 fargs = formatargvalues(
4293
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
546 argInfo.args, argInfo.varargs,
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
547 argInfo.keywords, argInfo.locals)
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
548 except Exception:
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
549 fargs = ""
2620
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
550 else:
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
551 fargs = ""
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
552
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
553 stack.append([fname, fline, ffunc, fargs])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 if fr == self._dbgClient.mainFrame:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 fr = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 fr = fr.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 return stack
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 def user_line(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
564 Public method reimplemented to handle the program about to execute a
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
565 particular line.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 @param frame the frame object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 line = frame.f_lineno
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 # We never stop on line 0.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 if line == 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 fn = self._dbgClient.absPath(self.fix_frame_filename(frame))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 # See if we are skipping at the start of a newly loaded program.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 if self._dbgClient.mainFrame is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 if fn != self._dbgClient.getRunning():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 return
4683
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
581 fr = frame
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
582 while (fr is not None and
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
583 fr.f_code != self._dbgClient.handleLine.__code__):
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
584 self._dbgClient.mainFrame = fr
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
585 fr = fr.f_back
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 self.currentFrame = frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 fr = frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 while fr is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 # Reset the trace function so we can be sure
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 # to trace all functions up the stack... This gets around
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 # problems where an exception/breakpoint has occurred
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 # but we had disabled tracing along the way via a None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 # return from dispatch_call
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 fr.f_trace = self.trace_dispatch
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 fname = self._dbgClient.absPath(self.fix_frame_filename(fr))
2620
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
599 if not fname.startswith("<"):
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
600 fline = fr.f_lineno
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
601 ffunc = fr.f_code.co_name
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
602
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
603 if ffunc == '?':
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
604 ffunc = ''
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
605
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
606 if ffunc and not ffunc.startswith("<"):
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
607 argInfo = getargvalues(fr)
4293
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
608 try:
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
609 fargs = formatargvalues(
4293
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
610 argInfo.args, argInfo.varargs,
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
611 argInfo.keywords, argInfo.locals)
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
612 except Exception:
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
613 fargs = ""
2620
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
614 else:
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
615 fargs = ""
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
616
a3be952f2ae4 Extended the Python debugger backends to report the call arguments and values of the frames.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2486
diff changeset
617 stack.append([fname, fline, ffunc, fargs])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 if fr == self._dbgClient.mainFrame:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 fr = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 fr = fr.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 self.__isBroken = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 self._dbgClient.write('{0}{1}\n'.format(ResponseLine, str(stack)))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 self._dbgClient.eventLoop()
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
628
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
629 self.__isBroken = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
631 def user_exception(self, frame, excinfo, unhandled=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
633 Public method reimplemented to report an exception to the debug server.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 @param frame the frame object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 @param excinfo information about the exception
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 @param unhandled flag indicating an uncaught exception
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 exctype, excval, exctb = excinfo
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
640
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
641 if exctype in [GeneratorExit, StopIteration]:
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
642 # ignore these
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
643 return
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
644
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 if exctype in [SystemExit, bdb.BdbQuit]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 atexit._run_exitfuncs()
1475
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
647 if excval is None:
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
648 excval = 0
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
649 elif isinstance(excval, str):
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
650 self._dbgClient.write(excval)
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
651 excval = 1
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
652 elif isinstance(excval, bytes):
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
653 self._dbgClient.write(excval.decode())
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
654 excval = 1
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
655 if isinstance(excval, int):
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
656 self._dbgClient.progTerminated(excval)
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
657 else:
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
658 self._dbgClient.progTerminated(excval.code)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
661 if exctype in [SyntaxError, IndentationError]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 try:
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
663 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
664 filename = excval.filename
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
665 linenr = excval.lineno
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
666 charnr = excval.offset
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
667 except (AttributeError, ValueError):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 exclist = []
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
669 realSyntaxError = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 exclist = [message, [filename, linenr, charnr]]
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
672 realSyntaxError = os.path.exists(filename)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
674 if realSyntaxError:
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
675 self._dbgClient.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
676 ResponseSyntax, str(exclist)))
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
677 self._dbgClient.eventLoop()
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
678 return
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
679
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
680 exctype = self.__extractExceptionName(exctype)
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
681
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
682 if excval is None:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
683 excval = ''
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
684
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
685 if unhandled:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
686 exctypetxt = "unhandled {0!s}".format(str(exctype))
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
687 else:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
688 exctypetxt = str(exctype)
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
689 try:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
690 exclist = [exctypetxt, str(excval)]
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
691 except TypeError:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
692 exclist = [exctypetxt, str(excval)]
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
693
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
694 if exctb:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
695 frlist = self.__extract_stack(exctb)
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
696 frlist.reverse()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
698 self.currentFrame = frlist[0]
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
699
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
700 for fr in frlist:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
701 filename = self._dbgClient.absPath(self.fix_frame_filename(fr))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
703 if os.path.basename(filename).startswith("DebugClient") or \
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
704 os.path.basename(filename) == "bdb.py":
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
705 break
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
706
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
707 linenr = fr.f_lineno
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
708 ffunc = fr.f_code.co_name
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
709
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
710 if ffunc == '?':
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
711 ffunc = ''
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
712
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
713 if ffunc and not ffunc.startswith("<"):
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
714 argInfo = getargvalues(fr)
4293
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
715 try:
4455
ca13a6f6c452 Prepared the Python3 debug client for some obsolescences of the inspect.py module.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4365
diff changeset
716 fargs = formatargvalues(
4293
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
717 argInfo.args, argInfo.varargs,
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
718 argInfo.keywords, argInfo.locals)
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
719 except Exception:
125a75cfd249 Fixed an issue in the debugger backend causing a crash if a class reimplements __repr__ and a breakpoint is set in the __init__() method of such class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4063
diff changeset
720 fargs = ""
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
721 else:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
722 fargs = ""
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
723
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
724 exclist.append([filename, linenr, ffunc, fargs])
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
725
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
726 self._dbgClient.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
727 ResponseException, str(exclist)))
2927
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
728
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
729 if exctb is None:
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
730 return
f36b757378f1 Fixed an issue in the Python debugger backends when a syntax error was raised for an invalid source file. That will be treated now like any other exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2648
diff changeset
731
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 self._dbgClient.eventLoop()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 def __extractExceptionName(self, exctype):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 Private method to extract the exception name given the exception
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 type object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 @param exctype type of the exception
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
740 @return exception name (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 """
2486
e16c9ced6ae5 Fixed an issue that could cause the debugger backends to crash, if a class redefined __repr__.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
742 return str(exctype).replace("<class '", "").replace("'>", "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
744 def __extract_stack(self, exctb):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 Private member to return a list of stack frames.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 @param exctb exception traceback
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 @return list of stack frames
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 tb = exctb
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 while tb is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 stack.append(tb.tb_frame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 tb = tb.tb_next
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 tb = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 return stack
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 def stop_here(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
761 Public method reimplemented to filter out debugger files.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 Tracing is turned off for files that are part of the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 debugger that are called from the application being debugged.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 @param frame the frame object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 @return flag indicating whether the debugger should stop here
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 """
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
769 if self.__skipFrame(frame):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
772 return bdb.Bdb.stop_here(self, frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
774 def tracePythonLibs(self, enable):
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
775 """
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
776 Public method to update the settings to trace into Python libraries.
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
777
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
778 @param enable flag to debug into Python libraries
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
779 @type int
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
780 """
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
781 pathsToSkip = list(self.pathsToSkip)
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
782 # don't trace into Python library?
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
783 if enable:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
784 pathsToSkip = [x for x in pathsToSkip if not x.endswith(
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
785 ("site-packages", "dist-packages", self.lib))]
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
786 else:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
787 pathsToSkip.append(self.lib)
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
788 localLib = [x for x in sys.path if x.endswith(("site-packages",
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
789 "dist-packages")) and not x.startswith(self.lib)]
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
790 pathsToSkip.extend(localLib)
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
791
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
792 self.pathsToSkip = tuple(pathsToSkip)
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
793
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
794 def __skipFrame(self, frame):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 Private method to filter out debugger files.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 Tracing is turned off for files that are part of the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 debugger that are called from the application being debugged.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 @param frame the frame object
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
802 @type frame object
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 @return flag indicating whether the debugger should skip this frame
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
804 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 """
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
806 try:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
807 return self.filesToSkip[frame.f_code.co_filename]
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
808 except KeyError:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
809 ret = frame.f_code.co_filename.startswith(self.pathsToSkip)
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
810 self.filesToSkip[frame.f_code.co_filename] = ret
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
811 return ret
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
812 except AttributeError:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
813 # if frame is None
3640
2bf828881e86 Fixed stop at sys.breakpoint() in run mode under Python3 and on first run (Py2 and 3).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3591
diff changeset
814 return True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 def isBroken(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 Public method to return the broken state of the debugger.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
820 @return flag indicating the broken state
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
821 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 return self.__isBroken
4543
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4455
diff changeset
824
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4455
diff changeset
825 #
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4455
diff changeset
826 # eflag: noqa = M702

eric ide

mercurial