DebugClients/Python3/DebugBase.py

Tue, 19 Jul 2016 22:20:51 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Tue, 19 Jul 2016 22:20:51 +0200
branch
debugger speed
changeset 5045
50862a6a2c63
parent 5044
630b9f290a77
child 5046
d57f18f15f1a
permissions
-rw-r--r--

Check only once if a function / method has a breakpoint.

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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 def profile(self, frame, event, arg):
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
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
198 @param frame current stack frame.
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
199 @param event trace event (string)
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
200 @param arg arguments
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2927
diff changeset
201 @exception RuntimeError raised to indicate too many recursions
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
203 if event == 'return':
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.cFrame = frame.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.__recursionDepth -= 1
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
206 self.__sendCallTrace(event, frame, self.cFrame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 elif event == 'call':
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
208 self.__sendCallTrace(event, self.cFrame, frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 self.cFrame = frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.__recursionDepth += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 if self.__recursionDepth > gRecursionLimit:
3021
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2987
diff changeset
212 raise RuntimeError(
801289962f4e Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2987
diff changeset
213 'maximum recursion depth exceeded\n'
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 '(offending frame is two down the stack)')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
216 def __sendCallTrace(self, event, fromFrame, toFrame):
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
217 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
218 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
219
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
220 @param event trace event (string)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
221 @param fromFrame originating frame (frame)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
222 @param toFrame destination frame (frame)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
223 """
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
224 if self._dbgClient.callTraceEnabled:
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
225 if (not self.__skipFrame(fromFrame) and
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
226 not self.__skipFrame(toFrame)):
2170
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
227 if event in ["call", "return"]:
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
228 fr = fromFrame
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
229 fromStr = "{0}:{1}:{2}".format(
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
230 self._dbgClient.absPath(self.fix_frame_filename(fr)),
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
231 fr.f_lineno,
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
232 fr.f_code.co_name)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
233 fr = toFrame
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
234 toStr = "{0}:{1}:{2}".format(
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
235 self._dbgClient.absPath(self.fix_frame_filename(fr)),
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
236 fr.f_lineno,
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
237 fr.f_code.co_name)
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
238 self._dbgClient.write("{0}{1}@@{2}@@{3}\n".format(
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
239 CallTrace, event[0], fromStr, toStr))
f4e0f6133ace Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2166
diff changeset
240
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 def trace_dispatch(self, frame, event, arg):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
243 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
244
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 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
246 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
247 the code.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
249 @param frame The current stack frame
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
250 @type frame object
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
251 @param event The trace event
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
252 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 @param arg The arguments
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
254 @type depends on the previous event parameter
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 @return local trace function
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
256 @rtype trace function or None
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
257 @exception bdb.BdbQuit
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 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
260 return # None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 # 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
263 if self.eventPollFlag:
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
264 self._dbgClient.eventPoll()
630b9f290a77 No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
265 self.eventPollFlag = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
267 if event == 'line':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
268 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
269 self.user_line(frame)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
270 if self.quitting:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
271 raise bdb.BdbQuit
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
272 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 if event == 'call':
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
275 if self.botframe is None:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
276 # First call of dispatch since reset()
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
277 # (CT) Note that this may also be None!
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
278 self.botframe = frame.f_back
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
279 return self.trace_dispatch
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
280
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
281 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
282 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
283 Watch.watches != []):
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
284 # No need to trace this function
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
285 return
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
286 if self.quitting:
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
287 raise bdb.BdbQuit
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
288 return self.trace_dispatch
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
290 if event == 'return':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
291 if self.stop_here(frame) or frame == self.returnframe:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
292 # Ignore return events in generator except when stepping.
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
293 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
294 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
295 # 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
296 if frame == self._dbgClient.mainFrame and \
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
297 self._mainThread:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
298 atexit._run_exitfuncs()
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
299 self._dbgClient.progTerminated(arg)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
300 elif frame is not self.stepFrame:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
301 self.stepFrame = None
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
302 self.user_line(frame)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
303
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
304 if self.quitting and not self._dbgClient.passive:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
305 raise bdb.BdbQuit
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
306 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
308 if event == 'exception':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
309 if not self.__skipFrame(frame):
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
310 # 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
311 # skip the internal StopIteration exception (with no traceback)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
312 # triggered by a subiterator run with the 'yield from'
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
313 # statement.
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
314 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
315 arg[0] is StopIteration and arg[2] is None):
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
316 self.user_exception(frame, arg)
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
317 if self.quitting:
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
318 raise bdb.BdbQuit
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
319 # 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
320 # 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
321 # 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
322 # exception.
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
323 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
324 self.stopframe.f_code.co_flags & CO_GENERATOR and
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
325 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
326 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
327 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
328 raise bdb.BdbQuit
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
329 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
330
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
331 if event == 'c_call':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
332 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
333 if event == 'c_exception':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
334 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
335 if event == 'c_return':
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
336 return
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
337 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
338 return self.trace_dispatch
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
340 def set_trace(self, frame=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
342 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
343
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 @param frame frame to start debugging from
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 bdb.Bdb.set_trace(self, frame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 sys.setprofile(self.profile)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 def set_continue(self, special):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
351 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
352 exceptions.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 @param special flag indicating a special continue operation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 # Modified version of the one found in bdb.py
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 # 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
358 if not special:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 self._set_stopinfo(self.botframe, None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 self._set_stopinfo(self.stopframe, None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 def set_quit(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
365 Public method to quit.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 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
368 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 self.currentFrame = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 sys.setprofile(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 bdb.Bdb.set_quit(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 def fix_frame_filename(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 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
376
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 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
378 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
379 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
380 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
381 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
382 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
383 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
384 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
385 on the original machine. Another case might be sharing
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 code over a network... This logic deals with that.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 @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
389 @type frame object
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
390 @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
391 @rtype str
0
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 # 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
394 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
395 try:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
396 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
397 except KeyError:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
398 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
399 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
400 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
401 fixedName = absFilename[:-1]
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
402 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
403 fixedName = absFilename
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
404 else:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
405 fixedName = absFilename
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
406 else:
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
407 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
408 # update cache
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
409 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
410 return fixedName
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411
5045
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
412 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
413 """
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
414 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
415 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
416 @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
417 @type frame object
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
418 @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
419 @rtype bool
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
420 """
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
421 try:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
422 return Breakpoint.breakInFrameCache[
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
423 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
424 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
425 except KeyError:
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
426 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
427 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
428 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
429 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
430 return False
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
431 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
432 lineNumbers = [lineNo]
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
433 # 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
434 # (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
435 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
436 lineNo += co_lno
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
437 lineNumbers.append(lineNo)
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
438
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
439 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
440 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
441 Breakpoint.breakInFrameCache[
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
442 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
443 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
444 return True
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
445 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
446 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
447 return False
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5044
diff changeset
448
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 def break_here(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
451 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
452 frame.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 See fix_frame_filename for more info.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 @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
457 @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
458 @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
459 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 """
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
461 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
462 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
463 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
464 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
465 if bp:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 # 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
467 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
468 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
469 return True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
471 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
472 bp, flag = Watch.effectiveWatch(frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 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
474 # 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
475 if flag and bp.temporary:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 self.__do_clearWatch(bp.cond)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
481 def __do_clearBreak(self, filename, lineno):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 Private method called to clear a temporary breakpoint.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 @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
486 @type str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 @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
488 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 """
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
490 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
491 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
492 lineno))
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
493
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
494 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
495 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
496 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
497
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
498 @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
499 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
500 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5012
diff changeset
501 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
502 self._dbgClient.write('%s%s\n' % (ResponseClearWatch, cond))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 def getStack(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 Public method to get the stack.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 @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
509 and function name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 fr = self.cFrame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 while fr is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 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
515 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
516 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
517 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
518
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
519 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
520 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
521
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
522 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
523 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
524 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
525 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
526 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
527 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
528 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
529 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
530 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
531 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
532
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
533 stack.append([fname, fline, ffunc, fargs])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 if fr == self._dbgClient.mainFrame:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 fr = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 fr = fr.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 return stack
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 def user_line(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
544 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
545 particular line.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 @param frame the frame object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 line = frame.f_lineno
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 # We never stop on line 0.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 if line == 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 return
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 fn = self._dbgClient.absPath(self.fix_frame_filename(frame))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 # 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
558 if self._dbgClient.mainFrame is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 if fn != self._dbgClient.getRunning():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 return
4683
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
561 fr = frame
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
562 while (fr is not None and
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
563 fr.f_code != self._dbgClient.handleLine.__code__):
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
564 self._dbgClient.mainFrame = fr
1ba6ba86b383 Determination of frame boundaries corrected.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4642
diff changeset
565 fr = fr.f_back
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 self.currentFrame = frame
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 fr = frame
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 while fr is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 # Reset the trace function so we can be sure
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 # 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
574 # problems where an exception/breakpoint has occurred
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 # 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
576 # return from dispatch_call
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 fr.f_trace = self.trace_dispatch
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 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
579 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
580 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
581 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
582
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
583 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
584 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
585
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
586 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
587 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
588 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
589 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
590 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
591 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
592 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
593 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
594 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
595 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
596
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
597 stack.append([fname, fline, ffunc, fargs])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 if fr == self._dbgClient.mainFrame:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 fr = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 fr = fr.f_back
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 self.__isBroken = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 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
607 self._dbgClient.eventLoop()
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
608
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
609 self.__isBroken = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
611 def user_exception(self, frame, excinfo, unhandled=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
613 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
614
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 @param frame the frame object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616 @param excinfo information about the exception
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 @param unhandled flag indicating an uncaught exception
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 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
620
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
621 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
622 # 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
623 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
624
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 if exctype in [SystemExit, bdb.BdbQuit]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 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
627 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
628 excval = 0
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
629 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
630 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
631 excval = 1
7e5348c83c9d Fixed issues formatting the exit value in the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
632 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
633 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
634 excval = 1
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
635 if isinstance(excval, int):
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
636 self._dbgClient.progTerminated(excval)
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
637 else:
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
638 self._dbgClient.progTerminated(excval.code)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640
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
641 if exctype in [SyntaxError, IndentationError]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 try:
3085
4a0f54a64496 Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3032
diff changeset
643 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
644 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
645 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
646 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
647 except (AttributeError, ValueError):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 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
649 realSyntaxError = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 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
652 realSyntaxError = os.path.exists(filename)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653
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
654 if realSyntaxError:
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
655 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
656 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
657 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
658 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
659
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
660 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
661
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
662 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
663 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
664
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
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 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
673
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 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
675 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
676 frlist.reverse()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677
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
678 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
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 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
681 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
682
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
683 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
684 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
685 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
686
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 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
688 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
689
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 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
691 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
692
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 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
694 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
695 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
696 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
697 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
698 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
699 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
700 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
701 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
702 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
703
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 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
705
2987
c99695c0f13a Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
706 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
707 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
708
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 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
710 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
711
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 self._dbgClient.eventLoop()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 def __extractExceptionName(self, exctype):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 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
717 type object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 @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
720 @return exception name (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 """
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
722 return str(exctype).replace("<class '", "").replace("'>", "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 def __extract_stack(self, exctb):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 Private member to return a list of stack frames.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 @param exctb exception traceback
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 @return list of stack frames
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 tb = exctb
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 while tb is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 stack.append(tb.tb_frame)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 tb = tb.tb_next
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 tb = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 return stack
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 def stop_here(self, frame):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
741 Public method reimplemented to filter out debugger files.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 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
744 debugger that are called from the application being debugged.
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 @param frame the frame object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 @return flag indicating whether the debugger should stop here
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 """
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
749 if self.__skipFrame(frame):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 935
diff changeset
752 return bdb.Bdb.stop_here(self, frame)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
754 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
755 """
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
756 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
757
5007
e2fa12bb0f53 Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5005
diff changeset
758 @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
759 @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
760 """
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
761 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
762 # 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
763 if enable:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
764 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
765 ("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
766 else:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
767 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
768 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
769 "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
770 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
771
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
772 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
773
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
774 def __skipFrame(self, frame):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 Private method to filter out debugger files.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 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
779 debugger that are called from the application being debugged.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781 @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
782 @type frame object
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 @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
784 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 """
5005
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
786 try:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
787 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
788 except KeyError:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
789 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
790 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
791 return ret
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
792 except AttributeError:
684f5ba04f0b First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 4830
diff changeset
793 # 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
794 return True
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 def isBroken(self):
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 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
799
5012
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
800 @return flag indicating the broken state
be693f11da53 Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5007
diff changeset
801 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 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
804
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4455
diff changeset
805 #
2e6a880670e9 Fixed a few code style issues (forgotten future imports, copyrights,...).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4455
diff changeset
806 # eflag: noqa = M702

eric ide

mercurial