Sun, 24 Jul 2022 11:29:56 +0200
Merged with branch 'eric7' to prepare a new release.
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 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8501
diff
changeset
|
3 | # Copyright (c) 2002 - 2022 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 | """ |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
7 | Module implementing the debug base class which based originally on bdb. |
0
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 os |
5179
5f56410e7624
Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5178
diff
changeset
|
12 | import types |
0
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 time |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
17 | import dis |
8240
93b8a353c4bf
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8228
diff
changeset
|
18 | import contextlib |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
20 | from BreakpointWatch import Breakpoint, Watch |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
22 | import _thread |
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
23 | from DebugUtilities import getargvalues, formatargvalues |
5179
5f56410e7624
Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5178
diff
changeset
|
24 | |
0
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 | |
7904
0424ebe2d3b1
DebugBase: fixed an issue with Python < 3.7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7903
diff
changeset
|
27 | try: |
0424ebe2d3b1
DebugBase: fixed an issue with Python < 3.7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7903
diff
changeset
|
28 | GENERATOR_AND_COROUTINE_FLAGS = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
29 | inspect.CO_GENERATOR | inspect.CO_COROUTINE | inspect.CO_ASYNC_GENERATOR |
7904
0424ebe2d3b1
DebugBase: fixed an issue with Python < 3.7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7903
diff
changeset
|
30 | ) |
0424ebe2d3b1
DebugBase: fixed an issue with Python < 3.7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7903
diff
changeset
|
31 | except AttributeError: |
0424ebe2d3b1
DebugBase: fixed an issue with Python < 3.7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7903
diff
changeset
|
32 | # Python < 3.7 |
0424ebe2d3b1
DebugBase: fixed an issue with Python < 3.7.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7903
diff
changeset
|
33 | GENERATOR_AND_COROUTINE_FLAGS = inspect.CO_GENERATOR |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
34 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
35 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | def printerr(s): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | Module function used for debugging the debug client. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | @param s data to be printed |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | sys.__stderr__.write("{0!s}\n".format(s)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | sys.__stderr__.flush() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
45 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | def setRecursionLimit(limit): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | Module function to set the recursion limit. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
49 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | @param limit recursion limit (integer) |
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 | global gRecursionLimit |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | gRecursionLimit = limit |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
55 | |
8207
d359172d11be
Applied some more code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7986
diff
changeset
|
56 | class DebugBase: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | Class implementing base class of the debugger. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
60 | Provides methods for the 'owning' client to call to step etc. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
63 | lib = os.path.dirname(inspect.__file__) |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
64 | # tuple required because it's accessed a lot of times by startswith method |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
65 | pathsToSkip = ("<", os.path.dirname(__file__), inspect.__file__[:-1]) |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
66 | filesToSkip = {} |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
67 | |
5007
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
68 | # 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
|
69 | _fnCache = {} |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
70 | |
5667
86554f131048
Avoid crashes on using greenlets.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5659
diff
changeset
|
71 | # Stop all timers, when greenlets are used |
5674
a0ad2dcb27f9
Corrected some translations related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5667
diff
changeset
|
72 | pollTimerEnabled = True |
5007
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
73 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | def __init__(self, dbgClient): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | @param dbgClient the owning client |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | self._dbgClient = dbgClient |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | |
5209
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
82 | # Some informations about the thread |
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
83 | self.isMainThread = False |
5206
997064ba25d6
Some clean up and restructuring.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5205
diff
changeset
|
84 | self.quitting = False |
5208
aa8045780ce4
Make attachThread and dumpThreadList runnable again.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5207
diff
changeset
|
85 | self.id = -1 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
86 | self.name = "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
87 | |
8964
29344a31ee2a
Implemented a fix for issue422 caused by an incomplete API of DebuggerInterfaceNone.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8918
diff
changeset
|
88 | self.tracePythonLibs(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
89 | |
5050
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
90 | # Special handling of a recursion error |
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
91 | self.skipFrames = 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
92 | |
5206
997064ba25d6
Some clean up and restructuring.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5205
diff
changeset
|
93 | self.isBroken = False |
7376
21df384d6150
Added some inspirations received from Tobias.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
94 | self.isException = False |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | self.cFrame = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
96 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | # current frame we are at |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | self.currentFrame = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
99 | |
5206
997064ba25d6
Some clean up and restructuring.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5205
diff
changeset
|
100 | # frames, where we want to stop or release debugger |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
101 | self.stopframe = None |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
102 | self.returnframe = None |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
103 | self.stop_everywhere = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
104 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | self.__recursionDepth = -1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | self.setRecursionDepth(inspect.currentframe()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
107 | |
5044
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
108 | # 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
|
109 | self.eventPollFlag = False |
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
110 | self.timer = _thread.start_new_thread(self.__eventPollTimer, ()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
111 | |
5273
be55746da9d1
Wrong frames when running in sys.breakpoint fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5263
diff
changeset
|
112 | # provide a hook to perform a hard breakpoint |
be55746da9d1
Wrong frames when running in sys.breakpoint fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5263
diff
changeset
|
113 | # Use it like this: |
be55746da9d1
Wrong frames when running in sys.breakpoint fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5263
diff
changeset
|
114 | # if hasattr(sys, 'breakpoint): sys.breakpoint() |
be55746da9d1
Wrong frames when running in sys.breakpoint fixed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5263
diff
changeset
|
115 | sys.breakpoint = self.set_trace |
7894
4370a8b30648
Changed the minimum supported Python version to 3.6.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7802
diff
changeset
|
116 | if sys.version_info >= (3, 7): |
6404
1a0afc7f2837
Support of breakpoint() builtin of Python 3.7
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6048
diff
changeset
|
117 | sys.breakpointhook = self.set_trace |
5044
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
118 | |
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
119 | def __eventPollTimer(self): |
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
120 | """ |
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
121 | 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
|
122 | """ |
5667
86554f131048
Avoid crashes on using greenlets.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5659
diff
changeset
|
123 | while DebugBase.pollTimerEnabled: |
5044
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
124 | 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
|
125 | self.eventPollFlag = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
126 | |
5667
86554f131048
Avoid crashes on using greenlets.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5659
diff
changeset
|
127 | self.eventPollFlag = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
128 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | def getCurrentFrame(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | Public method to return the current frame. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
132 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @return the current frame |
5222
6548dc1bfd48
Collect all running threads, even if they were not started by the debug client.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5221
diff
changeset
|
134 | @rtype frame object |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | """ |
5222
6548dc1bfd48
Collect all running threads, even if they were not started by the debug client.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5221
diff
changeset
|
136 | # Don't show any local frames after the program was stopped |
6548dc1bfd48
Collect all running threads, even if they were not started by the debug client.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5221
diff
changeset
|
137 | if self.quitting: |
6548dc1bfd48
Collect all running threads, even if they were not started by the debug client.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5221
diff
changeset
|
138 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
139 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
140 | return self.currentFrame |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
141 | |
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
|
142 | 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
|
143 | """ |
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
|
144 | 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
|
145 | or a frame below. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
146 | |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7897
diff
changeset
|
147 | @param frmnr distance of frame to get locals dictionary of. 0 is |
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
|
148 | 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
|
149 | @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
|
150 | """ |
4642
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
151 | f = self.currentFrame |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
152 | 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
|
153 | f = f.f_back |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
154 | frmnr -= 1 |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
155 | return f.f_locals |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
156 | |
4642
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
157 | 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
|
158 | """ |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
159 | 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
|
160 | frame.f_locals returns the last data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
161 | |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7897
diff
changeset
|
162 | @param frmnr distance of frame to store locals dictionary to. 0 is |
4642
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
163 | the current frame (int) |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
164 | """ |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
165 | cf = self.currentFrame |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
166 | 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
|
167 | cf = cf.f_back |
f18d5fb9a53b
Store values entered into the shell in selected frame.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4631
diff
changeset
|
168 | frmnr -= 1 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
169 | |
8240
93b8a353c4bf
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 1).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8228
diff
changeset
|
170 | with contextlib.suppress(Exception): |
5156
5cb4740bd2a9
Little addition to the debuggers to make them more compatible with PyPy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5140
diff
changeset
|
171 | if "__pypy__" in sys.builtin_module_names: |
5cb4740bd2a9
Little addition to the debuggers to make them more compatible with PyPy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5140
diff
changeset
|
172 | import __pypy__ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
173 | |
5156
5cb4740bd2a9
Little addition to the debuggers to make them more compatible with PyPy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5140
diff
changeset
|
174 | __pypy__.locals_to_fast(cf) |
5cb4740bd2a9
Little addition to the debuggers to make them more compatible with PyPy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5140
diff
changeset
|
175 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
176 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
177 | ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(cf), ctypes.c_int(0)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
178 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | def step(self, traceMode): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | Public method to perform a step operation in this thread. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
182 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | @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
|
184 | otherwise it is a step over. |
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 | if traceMode: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | self.set_step() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | self.set_next(self.currentFrame) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | def stepOut(self): |
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 | 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
|
194 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | self.set_return(self.currentFrame) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
196 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | def go(self, special): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | Public method to resume the thread. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | It resumes the thread stopping only at breakpoints or exceptions. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
202 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | @param special flag indicating a special continue operation |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | self.set_continue(special) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
206 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | def setRecursionDepth(self, frame): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | Public method to determine the current recursion depth. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
210 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | @param frame The current stack frame. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | self.__recursionDepth = 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | while frame is not None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | self.__recursionDepth += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | frame = frame.f_back |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
217 | |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
218 | def profileWithRecursion(self, frame, event, arg): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | """ |
2166
15b4e58d61d7
Fixed some typos in source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
220 | 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
|
221 | trace function. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
222 | |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
223 | @param frame current stack frame |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
224 | @type frame object |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
225 | @param event trace event |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
226 | @type str |
2953
703452a2876f
Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2927
diff
changeset
|
227 | @param arg arguments |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
228 | @type depends on the previous event parameter |
2953
703452a2876f
Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2927
diff
changeset
|
229 | @exception RuntimeError raised to indicate too many recursions |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
231 | if event == "return": |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | self.cFrame = frame.f_back |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | self.__recursionDepth -= 1 |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
234 | if self._dbgClient.callTraceEnabled: |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
235 | self.__sendCallTrace(event, frame, self.cFrame) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
236 | elif event == "call": |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
237 | if self._dbgClient.callTraceEnabled: |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
238 | self.__sendCallTrace(event, self.cFrame, frame) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | self.cFrame = frame |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | self.__recursionDepth += 1 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | if self.__recursionDepth > gRecursionLimit: |
3021
801289962f4e
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2987
diff
changeset
|
242 | raise RuntimeError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
243 | "maximum recursion depth exceeded\n" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
244 | "(offending frame is two down the stack)" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
245 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
246 | |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
247 | def profile(self, frame, event, arg): |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
248 | """ |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
249 | Public method used to trace some stuff independent of the debugger |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
250 | trace function. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
251 | |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
252 | @param frame current stack frame |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
253 | @type frame object |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
254 | @param event trace event |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
255 | @type str |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
256 | @param arg arguments |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
257 | @type depends on the previous event parameter |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
258 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
259 | if event == "return": |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
260 | self.__sendCallTrace(event, frame, frame.f_back) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
261 | elif event == "call": |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
262 | self.__sendCallTrace(event, frame.f_back, frame) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
263 | |
2170
f4e0f6133ace
Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2166
diff
changeset
|
264 | def __sendCallTrace(self, event, fromFrame, toFrame): |
f4e0f6133ace
Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2166
diff
changeset
|
265 | """ |
f4e0f6133ace
Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2166
diff
changeset
|
266 | Private method to send a call/return trace. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
267 | |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
268 | @param event trace event |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
269 | @type str |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
270 | @param fromFrame originating frame |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
271 | @type frame object |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
272 | @param toFrame destination frame |
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
273 | @type frame object |
2170
f4e0f6133ace
Started implementing the call trace functionality.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2166
diff
changeset
|
274 | """ |
5046
d57f18f15f1a
Don't track the recursion limit by hand.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5045
diff
changeset
|
275 | if not self.__skipFrame(fromFrame) and not self.__skipFrame(toFrame): |
5174 | 276 | fromInfo = { |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
277 | "filename": self._dbgClient.absPath(self.fix_frame_filename(fromFrame)), |
5174 | 278 | "linenumber": fromFrame.f_lineno, |
279 | "codename": fromFrame.f_code.co_name, | |
280 | } | |
281 | toInfo = { | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
282 | "filename": self._dbgClient.absPath(self.fix_frame_filename(toFrame)), |
5174 | 283 | "linenumber": toFrame.f_lineno, |
284 | "codename": toFrame.f_code.co_name, | |
285 | } | |
286 | self._dbgClient.sendCallTrace(event, fromInfo, toInfo) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
287 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | def trace_dispatch(self, frame, event, arg): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
290 | Public method reimplemented from bdb.py to do some special things. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
291 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | 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
|
293 | 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
|
294 | the code. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
296 | @param frame The current stack frame |
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
297 | @type frame object |
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
298 | @param event The trace event |
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
299 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | @param arg The arguments |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
301 | @type depends on the previous event parameter |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | @return local trace function |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
303 | @rtype trace function or None |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
304 | @exception SystemExit |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
305 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
306 | # 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
|
307 | if self.eventPollFlag: |
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
308 | self._dbgClient.eventPoll() |
630b9f290a77
No polling of incoming messages. Just wait for a flag.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5041
diff
changeset
|
309 | self.eventPollFlag = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
310 | |
5083
4affedf129c5
Don't check the quitting flag after each operation.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5064
diff
changeset
|
311 | if self.quitting: |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
312 | raise SystemExit |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
313 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
314 | if event == "line": |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
315 | if self.stop_here(frame) or self.break_here(frame): |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
316 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
317 | self.stop_everywhere |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
318 | and frame.f_back |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
319 | and frame.f_back.f_code.co_name == "prepareJsonCommand" |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
320 | ): |
5573
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
321 | # Just stepped into print statement, so skip these frames |
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
322 | self._set_stopinfo(None, frame.f_back) |
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
323 | else: |
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
324 | self.user_line(frame) |
5263
50a03ff54b15
Make PyPy stop at breakpoints again.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5239
diff
changeset
|
325 | return self.trace_dispatch |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
326 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
327 | if event == "call": |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
328 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
329 | self.stop_here(frame) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
330 | or self.__checkBreakInFrame(frame) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
331 | or Watch.watches != [] |
8228
772103b14c18
Applied some more code simplifications suggested by the new Simplify checker (Y114: use logical or for multiple if).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8207
diff
changeset
|
332 | ) or ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
333 | self.stopframe and frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
334 | ): |
5543
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
335 | return self.trace_dispatch |
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
336 | else: |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
337 | # No need to trace this function |
6891
93f82da09f22
Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6687
diff
changeset
|
338 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
339 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
340 | if event == "return": |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
341 | if self.stop_here(frame) or frame == self.returnframe: |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
342 | # Ignore return events in generator except when stepping. |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
343 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
344 | self.stopframe |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
345 | and frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
346 | ): |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
347 | return self.trace_dispatch |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
348 | # Only true if we didn't stop in this frame, because it's |
5573
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
349 | # belonging to the eric debugger. |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
350 | if self.stopframe is frame and self.stoplineno != -1: |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
351 | self._set_stopinfo(None, frame.f_back) |
6891
93f82da09f22
Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6687
diff
changeset
|
352 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
353 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
354 | if event == "exception": |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
355 | if not self.__skipFrame(frame): |
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
356 | # 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
|
357 | # skip the internal StopIteration exception (with no traceback) |
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
358 | # triggered by a subiterator run with the 'yield from' |
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
359 | # statement. |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
360 | if not ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
361 | frame.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
362 | and arg[0] is StopIteration |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
363 | and arg[2] is None |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
364 | ): |
5536
d28e800f2810
Remove obsolete parameter 'frame' at user_exception function.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5417
diff
changeset
|
365 | self.user_exception(arg) |
5048
9899fb545b1f
Fixed some code style issues and removed the obsolete method shouldSkip.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5046
diff
changeset
|
366 | # Stop at the StopIteration or GeneratorExit exception when the |
9899fb545b1f
Fixed some code style issues and removed the obsolete method shouldSkip.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5046
diff
changeset
|
367 | # user has set stopframe in a generator by issuing a return |
9899fb545b1f
Fixed some code style issues and removed the obsolete method shouldSkip.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5046
diff
changeset
|
368 | # command, or a next/until command at the last statement in the |
9899fb545b1f
Fixed some code style issues and removed the obsolete method shouldSkip.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5046
diff
changeset
|
369 | # generator before the exception. |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
370 | elif ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
371 | self.stopframe |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
372 | and frame is not self.stopframe |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
373 | and (self.stopframe.f_code.co_flags & GENERATOR_AND_COROUTINE_FLAGS) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
374 | and arg[0] in (StopIteration, GeneratorExit) |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
375 | ): |
5536
d28e800f2810
Remove obsolete parameter 'frame' at user_exception function.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5417
diff
changeset
|
376 | self.user_exception(arg) |
6891
93f82da09f22
Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6687
diff
changeset
|
377 | return None |
5012
be693f11da53
Avoid unnecessary function calls.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5007
diff
changeset
|
378 | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
379 | if event == "c_call": |
6891
93f82da09f22
Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6687
diff
changeset
|
380 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
381 | if event == "c_exception": |
6891
93f82da09f22
Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6687
diff
changeset
|
382 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
383 | if event == "c_return": |
6891
93f82da09f22
Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6687
diff
changeset
|
384 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
385 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
386 | print( # __IGNORE_WARNING_M801__ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
387 | "DebugBase.trace_dispatch:" " unknown debugging event: ", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
388 | repr(event), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
389 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
390 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
391 | return self.trace_dispatch |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
392 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
393 | def set_trace(self, frame=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
394 | """ |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
395 | Public method to start debugging from 'frame'. |
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
396 | |
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
397 | If frame is not specified, debugging starts from caller's frame. |
5086
6cb8be573090
New set_trace for sys.breakpoint to reflect the changes in previous commit.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5085
diff
changeset
|
398 | Because of jump optimizations it's not possible to use sys.breakpoint() |
6cb8be573090
New set_trace for sys.breakpoint to reflect the changes in previous commit.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5085
diff
changeset
|
399 | as last instruction in a function or method. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
400 | |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7897
diff
changeset
|
401 | @param frame frame to start debugging from |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
402 | @type frame object |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
403 | """ |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
404 | if frame is None: |
5086
6cb8be573090
New set_trace for sys.breakpoint to reflect the changes in previous commit.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5085
diff
changeset
|
405 | frame = sys._getframe().f_back # Skip set_trace method |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
406 | |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
407 | stopOnHandleCommand = self._dbgClient.handleJsonCommand.__code__ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
408 | |
5086
6cb8be573090
New set_trace for sys.breakpoint to reflect the changes in previous commit.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5085
diff
changeset
|
409 | frame.f_trace = self.trace_dispatch |
5274
a19743a4a8fa
Easier and fail save way to get the correct botframe at sys.breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5273
diff
changeset
|
410 | while frame.f_back is not None: |
5966
3325ecd87c7c
Fixed an issue in the debugger backend related to debugging threads.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5761
diff
changeset
|
411 | # stop at eric's debugger frame or a threading bootstrap |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
412 | if frame.f_back.f_code == stopOnHandleCommand: |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
413 | frame.f_trace = self.trace_dispatch |
5086
6cb8be573090
New set_trace for sys.breakpoint to reflect the changes in previous commit.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5085
diff
changeset
|
414 | break |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
415 | |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
416 | frame = frame.f_back |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
417 | |
5086
6cb8be573090
New set_trace for sys.breakpoint to reflect the changes in previous commit.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5085
diff
changeset
|
418 | self.stop_everywhere = True |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
419 | sys.settrace(self.trace_dispatch) |
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
420 | sys.setprofile(self._dbgClient.callTraceEnabled) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
421 | |
5209
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
422 | def bootstrap(self, target, args, kwargs): |
5207
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
423 | """ |
5209
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
424 | Public method to bootstrap a thread. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
425 | |
5207
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
426 | It wraps the call to the user function to enable tracing |
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
427 | before hand. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
428 | |
5209
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
429 | @param target function which is called in the new created thread |
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
430 | @type function pointer |
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
431 | @param args arguments to pass to target |
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
432 | @type tuple |
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
433 | @param kwargs keyword arguments to pass to target |
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
434 | @type dict |
5207
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
435 | """ |
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
436 | try: |
5543
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
437 | # Because in the initial run method the "base debug" function is |
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
438 | # set up, it's also valid for the threads afterwards. |
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
439 | sys.settrace(self.trace_dispatch) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
440 | |
5209
cd058aa6af37
Insert import hook to modify thread module to use our bootstrap.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5208
diff
changeset
|
441 | target(*args, **kwargs) |
5538
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
442 | except Exception: |
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
443 | excinfo = sys.exc_info() |
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
444 | self.user_exception(excinfo, True) |
5207
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
445 | finally: |
5538
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
446 | sys.settrace(None) |
5207
7283629b02c0
Relocated some methods from Debug*Thread and the remaining modules into a new one.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5206
diff
changeset
|
447 | sys.setprofile(None) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
448 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
449 | def run( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
450 | self, cmd, globalsDict=None, localsDict=None, debug=True, closeSession=True |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
451 | ): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
452 | """ |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
453 | Public method to start a given command under debugger control. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
454 | |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
455 | @param cmd command / code to execute under debugger control |
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
456 | @type str or CodeType |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
457 | @param globalsDict dictionary of global variables for cmd |
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
458 | @type dict |
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
459 | @param localsDict dictionary of local variables for cmd |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
460 | @type dict |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
461 | @param debug flag if command should run under debugger control |
5550
b36f631e4138
Only code style issues.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5543
diff
changeset
|
462 | @type bool |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
463 | @return exit code of the program |
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
464 | @rtype int |
7903
827d89937c30
Fixed a few issues with the new multi process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7900
diff
changeset
|
465 | @param closeSession flag indicating to close the debugger session |
827d89937c30
Fixed a few issues with the new multi process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7900
diff
changeset
|
466 | at exit |
827d89937c30
Fixed a few issues with the new multi process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7900
diff
changeset
|
467 | @type bool |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
468 | """ |
5587
ea526b78ee6c
Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5582
diff
changeset
|
469 | if globalsDict is None: |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
470 | import __main__ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
471 | |
5587
ea526b78ee6c
Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5582
diff
changeset
|
472 | globalsDict = __main__.__dict__ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
473 | |
5587
ea526b78ee6c
Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5582
diff
changeset
|
474 | if localsDict is None: |
ea526b78ee6c
Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5582
diff
changeset
|
475 | localsDict = globalsDict |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
476 | |
5179
5f56410e7624
Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5178
diff
changeset
|
477 | if not isinstance(cmd, types.CodeType): |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
478 | cmd = compile(cmd, "<string>", "exec") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
479 | |
5540
40992b7a60a9
Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5539
diff
changeset
|
480 | if debug: |
5543
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
481 | # First time the trace_dispatch function is called, a "base debug" |
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
482 | # function has to be returned, which is called at every user code |
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
483 | # function call. This is ensured by setting stop_everywhere. |
4e2ab5215bcf
Get rid of botframe, because we didn't check against it anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5540
diff
changeset
|
484 | self.stop_everywhere = True |
5540
40992b7a60a9
Improved atexit handling.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5539
diff
changeset
|
485 | sys.settrace(self.trace_dispatch) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
486 | |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
487 | try: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
488 | exec(cmd, globalsDict, localsDict) # secok |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
489 | atexit._run_exitfuncs() |
7903
827d89937c30
Fixed a few issues with the new multi process debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7900
diff
changeset
|
490 | self._dbgClient.progTerminated(0, closeSession=closeSession) |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
491 | exitcode = 0 |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
492 | except SystemExit: |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
493 | atexit._run_exitfuncs() |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
494 | excinfo = sys.exc_info() |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
495 | exitcode, message = self.__extractSystemExitMessage(excinfo) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
496 | self._dbgClient.progTerminated( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
497 | exitcode, message=message, closeSession=closeSession |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
498 | ) |
5538
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
499 | except Exception: |
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
500 | excinfo = sys.exc_info() |
d6de2206af1e
Handling of unhandled exceptions restored.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5537
diff
changeset
|
501 | self.user_exception(excinfo, True) |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
502 | exitcode = 242 |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
503 | finally: |
5206
997064ba25d6
Some clean up and restructuring.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5205
diff
changeset
|
504 | self.quitting = True |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
505 | sys.settrace(None) |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
506 | return exitcode |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
507 | |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
508 | def _set_stopinfo(self, stopframe, returnframe, stoplineno=0): |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
509 | """ |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
510 | Protected method to update the frame pointers. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
511 | |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
512 | @param stopframe the frame object where to stop |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
513 | @type frame object |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
514 | @param returnframe the frame object where to stop on a function return |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
515 | @type frame object |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
516 | @param stoplineno line number to stop at. If stoplineno is greater than |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
517 | or equal to 0, then stop at line greater than or equal to the |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
518 | stopline. If stoplineno is -1, then don't stop at all. |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
519 | @type int |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
520 | """ |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
521 | self.stopframe = stopframe |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
522 | self.returnframe = returnframe |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
523 | # stoplineno >= 0 means: stop at line >= the stoplineno |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
524 | # stoplineno -1 means: don't stop at all |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
525 | self.stoplineno = stoplineno |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
526 | |
5573
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
527 | if returnframe is not None: |
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
528 | # Ensure to be able to stop on the return frame |
4f85c1de060d
Don't step into print statements.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5560
diff
changeset
|
529 | returnframe.f_trace = self.trace_dispatch |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
530 | self.stop_everywhere = False |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
531 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
532 | def set_continue(self, special): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
533 | """ |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
534 | Public method to stop only on next breakpoint. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
535 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
536 | @param special flag indicating a special continue operation |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
537 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
538 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
539 | # 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
|
540 | if not special: |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
541 | self._set_stopinfo(None, None, -1) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
542 | |
5064
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
543 | # Disable tracing if not started in debug mode |
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
544 | if not self._dbgClient.debugging: |
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
545 | sys.settrace(None) |
9f4e3914e50c
Improvements on eric's set_trace and set_continue if not in debugging mode.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5063
diff
changeset
|
546 | sys.setprofile(None) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
547 | |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
548 | def set_until(self, frame=None, lineno=None): |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
549 | """ |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
550 | Public method to stop when the line with the lineno greater than the |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
551 | current one is reached or when returning from current frame. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
552 | |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
553 | @param frame reference to the frame object |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
554 | @type frame object |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
555 | @param lineno line number to continue to |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
556 | @type int |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
557 | """ |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
558 | # the name "until" is borrowed from gdb |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
559 | if frame is None: |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
560 | frame = self.currentFrame |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
561 | if lineno is None: |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
562 | lineno = frame.f_lineno + 1 |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
563 | self._set_stopinfo(frame, frame, lineno) |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
564 | |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
565 | def set_step(self): |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
566 | """ |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
567 | Public method to stop after one line of code. |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
568 | """ |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
569 | self._set_stopinfo(None, None) |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
570 | self.stop_everywhere = True |
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
571 | |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
572 | def set_next(self, frame): |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
573 | """ |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
574 | Public method to stop on the next line in or below the given frame. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
575 | |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
576 | @param frame the frame object |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
577 | @type frame object |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
578 | """ |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
579 | self._set_stopinfo(frame, frame.f_back) |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
580 | frame.f_trace = self.trace_dispatch |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
581 | |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
582 | def set_return(self, frame): |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
583 | """ |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
584 | Public method to stop when returning from the given frame. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
585 | |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
586 | @param frame the frame object |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
587 | @type frame object |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
588 | """ |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
589 | self._set_stopinfo(None, frame.f_back) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
590 | |
5658
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
591 | def move_instruction_pointer(self, lineno): |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
592 | """ |
8444
88b242eba71b
Corrected some typos.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
593 | Public method to move the instruction pointer to another line. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
594 | |
5658
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
595 | @param lineno new line number |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
596 | @type int |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
597 | """ |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
598 | try: |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
599 | self.currentFrame.f_lineno = lineno |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
600 | stack = self.getStack(self.currentFrame) |
7986
2971d5d19951
Fixed a few thread related issues in the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
601 | self._dbgClient.sendResponseLine(stack, self.name) |
5658
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
602 | except Exception as e: |
e5f6fe5855fd
move the instruction pointer within the current function (Hotkey: F12)
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5644
diff
changeset
|
603 | printerr(e) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
604 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
605 | def set_quit(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
606 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
607 | Public method to quit. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
608 | |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
609 | Disables the trace functions and resets all frame pointer. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
610 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
611 | sys.setprofile(None) |
5087
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
612 | self.stopframe = None |
59316f14216b
Not much left of bdb, so removed it entirely.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5086
diff
changeset
|
613 | self.returnframe = None |
5287
971f24c89e6b
Restore normal stop functionality (F10).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5274
diff
changeset
|
614 | for debugThread in self._dbgClient.threads.values(): |
971f24c89e6b
Restore normal stop functionality (F10).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5274
diff
changeset
|
615 | debugThread.quitting = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
616 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
617 | def fix_frame_filename(self, frame): |
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 | Public method used to fixup the filename for a given frame. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
620 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
621 | 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
|
622 | 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
|
623 | 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
|
624 | 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
|
625 | 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
|
626 | 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
|
627 | 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
|
628 | 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
|
629 | on the original machine. Another case might be sharing |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
630 | code over a network... This logic deals with that. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
631 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
632 | @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
|
633 | @type frame object |
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
634 | @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
|
635 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
636 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
637 | # get module name from __file__ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
638 | fn = frame.f_globals.get("__file__") |
5700
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
639 | try: |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
640 | return self._fnCache[fn] |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
641 | except KeyError: |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
642 | if fn is None: |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
643 | return frame.f_code.co_filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
644 | |
5700
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
645 | absFilename = os.path.abspath(fn) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
646 | if absFilename.endswith((".pyc", ".pyo", ".pyd")): |
5700
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
647 | fixedName = absFilename[:-1] |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
648 | if not os.path.exists(fixedName): |
5007
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
649 | fixedName = absFilename |
5700
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
650 | else: |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
651 | fixedName = absFilename |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
652 | # update cache |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
653 | self._fnCache[fn] = fixedName |
3bcd20e99b52
Patch from Detlev revised to avoid an additional check on every call.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5684
diff
changeset
|
654 | return fixedName |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
655 | |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
656 | def __checkBreakInFrame(self, frame): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
657 | """ |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
658 | 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
|
659 | which is a breakpoint. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
660 | |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
661 | @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
|
662 | @type frame object |
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
663 | @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
|
664 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
665 | """ |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
935
diff
changeset
|
666 | try: |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
667 | return Breakpoint.breakInFrameCache[ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
668 | frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
669 | ] |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
670 | except KeyError: |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
671 | 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
|
672 | if filename not in Breakpoint.breakInFile: |
5048
9899fb545b1f
Fixed some code style issues and removed the obsolete method shouldSkip.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5046
diff
changeset
|
673 | Breakpoint.breakInFrameCache[ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
674 | frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
675 | ] = False |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
676 | return False |
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
677 | 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
|
678 | lineNumbers = [lineNo] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
679 | |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
680 | co_lnotab = frame.f_code.co_lnotab[1::2] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
681 | |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
682 | # 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
|
683 | # (e.g. closure), because the additional lines won't cause a bp |
5203
6f876aca1c34
Changed calculation of line numbers in a function to work properly on Python 3.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5183
diff
changeset
|
684 | for co_lno in co_lnotab: |
7442
ebcb3a228c3d
DebugBase: fixed an issue causing some breakpoints not being recognized, which was caused by incorrectly determining the line numbers of a frame.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
685 | if co_lno >= 0x80: |
ebcb3a228c3d
DebugBase: fixed an issue causing some breakpoints not being recognized, which was caused by incorrectly determining the line numbers of a frame.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
686 | lineNo -= 0x100 |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
687 | lineNo += co_lno |
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
688 | lineNumbers.append(lineNo) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
689 | |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
690 | 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
|
691 | 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
|
692 | Breakpoint.breakInFrameCache[ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
693 | frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
694 | ] = True |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
695 | return True |
5048
9899fb545b1f
Fixed some code style issues and removed the obsolete method shouldSkip.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5046
diff
changeset
|
696 | Breakpoint.breakInFrameCache[ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
697 | frame.f_globals.get("__file__"), frame.f_code.co_firstlineno |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
698 | ] = False |
5045
50862a6a2c63
Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5044
diff
changeset
|
699 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
700 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
701 | def break_here(self, frame): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
702 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
703 | 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
|
704 | frame. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
705 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
706 | See fix_frame_filename for more info. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
707 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
708 | @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
|
709 | @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
|
710 | @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
|
711 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
712 | """ |
5007
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
713 | 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
|
714 | if (filename, frame.f_lineno) in Breakpoint.breaks: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
715 | bp, flag = Breakpoint.effectiveBreak(filename, frame.f_lineno, frame) |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
716 | if bp: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
717 | # 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
|
718 | 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
|
719 | 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
|
720 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
721 | |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
722 | 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
|
723 | bp, flag = Watch.effectiveWatch(frame) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
724 | 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
|
725 | # 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
|
726 | if flag and bp.temporary: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
727 | self.__do_clearWatch(bp.cond) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
728 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
729 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
730 | return False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
731 | |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
732 | def __do_clearBreak(self, filename, lineno): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
733 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
734 | Private method called to clear a temporary breakpoint. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
735 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
736 | @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
|
737 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
738 | @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
|
739 | @type int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
740 | """ |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
741 | Breakpoint.clear_break(filename, lineno) |
5124
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
742 | self._dbgClient.sendClearTemporaryBreakpoint(filename, lineno) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
743 | |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
744 | 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
|
745 | """ |
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
746 | Private method called to clear a temporary watch expression. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
747 | |
5041
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
748 | @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
|
749 | @type str |
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
750 | """ |
f00a4c8bcbbd
Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5012
diff
changeset
|
751 | Watch.clear_watch(cond) |
5174 | 752 | self._dbgClient.sendClearTemporaryWatch(cond) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
753 | |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
754 | def getStack(self, frame=None, applyTrace=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
755 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
756 | Public method to get the stack. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
757 | |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7897
diff
changeset
|
758 | @param frame frame object to inspect |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
759 | @type frame object or list |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7897
diff
changeset
|
760 | @param applyTrace flag to assign trace function to fr.f_trace |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
761 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
762 | @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
|
763 | and function name (string) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
764 | """ |
6687
352a7abb5582
Show correct line number on specific exceptions.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6645
diff
changeset
|
765 | tb_lineno = None |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
766 | if frame is None: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
767 | fr = self.getCurrentFrame() |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
768 | elif type(frame) == list: |
6687
352a7abb5582
Show correct line number on specific exceptions.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6645
diff
changeset
|
769 | fr, tb_lineno = frame.pop(0) |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
770 | else: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
771 | fr = frame |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
772 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
773 | stack = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
774 | while fr is not None: |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
775 | if applyTrace: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
776 | # Reset the trace function so we can be sure |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
777 | # to trace all functions up the stack... This gets around |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
778 | # problems where an exception/breakpoint has occurred |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
779 | # but we had disabled tracing along the way via a None |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
780 | # return from dispatch_call |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
781 | fr.f_trace = self.trace_dispatch |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
782 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
783 | fname = self._dbgClient.absPath(self.fix_frame_filename(fr)) |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
784 | # Always show at least one stack frame, even if it's from eric. |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
785 | if stack and os.path.basename(fname).startswith( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
786 | ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
787 | "DebugBase.py", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
788 | "DebugClientBase.py", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
789 | "ThreadExtension.py", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
790 | "threading.py", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
791 | ) |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
792 | ): |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
793 | break |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
794 | |
6687
352a7abb5582
Show correct line number on specific exceptions.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6645
diff
changeset
|
795 | fline = tb_lineno or fr.f_lineno |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
796 | ffunc = fr.f_code.co_name |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
797 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
798 | if ffunc == "?": |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
799 | ffunc = "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
800 | |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
801 | if ffunc and not ffunc.startswith("<"): |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
802 | argInfo = getargvalues(fr) |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
803 | try: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
804 | fargs = formatargvalues( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
805 | argInfo.args, argInfo.varargs, argInfo.keywords, argInfo.locals |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
806 | ) |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
807 | except Exception: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
808 | fargs = "" |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
809 | else: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
810 | fargs = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
811 | |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
812 | stack.append([fname, fline, ffunc, fargs]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
813 | |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
814 | # is it a stack frame or exception list? |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
815 | if type(frame) == list: |
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
816 | if frame != []: |
6687
352a7abb5582
Show correct line number on specific exceptions.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6645
diff
changeset
|
817 | fr, tb_lineno = frame.pop(0) |
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
|
818 | else: |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
819 | fr = None |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
820 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
821 | fr = fr.f_back |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
822 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
823 | return stack |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
824 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
825 | def user_line(self, frame): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
826 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
827 | 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
|
828 | particular line. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
829 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
830 | @param frame the frame object |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
831 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
832 | # We never stop on line 0. |
5063
0b5dccc8aacb
Hide frames belonging to the debugger at a regular breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5062
diff
changeset
|
833 | if frame.f_lineno == 0: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
834 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
835 | |
5582
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
836 | self.isBroken = True |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
837 | self.currentFrame = frame |
5204
7376ae3e6668
Unify the three different variants of getStack (user_line and user_exception).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5203
diff
changeset
|
838 | stack = self.getStack(frame, applyTrace=True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
839 | |
5221
960afd19c1b6
Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5209
diff
changeset
|
840 | self._dbgClient.lockClient() |
960afd19c1b6
Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5209
diff
changeset
|
841 | self._dbgClient.currentThread = self |
960afd19c1b6
Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5209
diff
changeset
|
842 | self._dbgClient.currentThreadExec = self |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
843 | |
7986
2971d5d19951
Fixed a few thread related issues in the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
844 | self._dbgClient.sendResponseLine(stack, self.name) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
845 | self._dbgClient.eventLoop() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
846 | |
5206
997064ba25d6
Some clean up and restructuring.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5205
diff
changeset
|
847 | self.isBroken = False |
5221
960afd19c1b6
Give the next debugger command to the thread where we are stopped at the moment.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5209
diff
changeset
|
848 | self._dbgClient.unlockClient() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
849 | |
7397
f8d2f6dd6636
Fixed an issue causing multi threaded debugging sessions to hang.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7376
diff
changeset
|
850 | self._dbgClient.dumpThreadList() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
851 | |
5536
d28e800f2810
Remove obsolete parameter 'frame' at user_exception function.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5417
diff
changeset
|
852 | def user_exception(self, excinfo, unhandled=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
853 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
854 | Public method reimplemented to report an exception to the debug server. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
855 | |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
856 | @param excinfo details about the exception |
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
857 | @type tuple(Exception, excval object, traceback frame object) |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7897
diff
changeset
|
858 | @param unhandled flag indicating an uncaught exception |
5084
25115adf9758
Don't use bdb.BdbQuit anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5083
diff
changeset
|
859 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
860 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
861 | exctype, excval, exctb = excinfo |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
862 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
863 | if ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
864 | exctype in [GeneratorExit, StopIteration] and unhandled is False |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
865 | ) or exctype == SystemExit: |
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
|
866 | # 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
|
867 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
868 | |
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
|
869 | if exctype in [SyntaxError, IndentationError]: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
870 | try: |
5183
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
871 | if type(excval) == tuple: |
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
872 | message, details = excval |
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
873 | filename, lineno, charno, text = details |
5179
5f56410e7624
Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5178
diff
changeset
|
874 | else: |
5183
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
875 | message = excval.msg |
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
876 | filename = excval.filename |
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
877 | lineno = excval.lineno |
f7037c006edf
Invalid __future__ import didn't show a valid error message on Python 2.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5179
diff
changeset
|
878 | charno = excval.offset |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
879 | |
5659
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
880 | if filename is None: |
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
881 | realSyntaxError = False |
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
882 | else: |
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
883 | if charno is None: |
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
884 | charno = 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
885 | |
5659
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
886 | filename = os.path.abspath(filename) |
cf3ecfec6321
report syntax and indentation errors raised by an application or module in the correct manner
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5658
diff
changeset
|
887 | realSyntaxError = os.path.exists(filename) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
888 | |
3085
4a0f54a64496
Fixed an issue in the Python3 debugger backend handling syntax errors.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3032
diff
changeset
|
889 | except (AttributeError, ValueError): |
5124
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
890 | message = "" |
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
891 | filename = "" |
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
892 | lineno = 0 |
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
893 | charno = 0 |
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
|
894 | realSyntaxError = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
895 | |
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
|
896 | if realSyntaxError: |
5124
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
897 | self._dbgClient.sendSyntaxError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
898 | message, filename, lineno, charno, self.name |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
899 | ) |
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
|
900 | 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
|
901 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
902 | |
5050
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
903 | self.skipFrames = 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
904 | if ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
905 | exctype == RuntimeError |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
906 | and str(excval).startswith("maximum recursion depth exceeded") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
907 | or exctype == RecursionError |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
908 | ): # __IGNORE_WARNING__ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
909 | excval = "maximum recursion depth exceeded" |
5050
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
910 | depth = 0 |
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
911 | tb = exctb |
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
912 | while tb: |
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
913 | tb = tb.tb_next |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
914 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
915 | if ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
916 | tb |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
917 | and tb.tb_frame.f_code.co_name == "trace_dispatch" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
918 | and __file__.startswith(tb.tb_frame.f_code.co_filename) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
919 | ): |
5050
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
920 | depth = 1 |
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
921 | self.skipFrames += depth |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
922 | |
5050
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
923 | # always 1 if running without debugger |
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
924 | self.skipFrames = max(1, self.skipFrames) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
925 | |
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
|
926 | exctype = self.__extractExceptionName(exctype) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
927 | |
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
|
928 | if excval is None: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
929 | excval = "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
930 | |
8257
28146736bbfc
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8240
diff
changeset
|
931 | exctypetxt = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
932 | "unhandled {0!s}".format(str(exctype)) if unhandled else str(exctype) |
8257
28146736bbfc
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8240
diff
changeset
|
933 | ) |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
934 | excvaltxt = str(excval) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
935 | |
5582
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
936 | # Don't step into libraries, which are used by our debugger methods |
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
937 | if exctb is not None: |
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
938 | self.stop_everywhere = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
939 | |
5582
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
940 | self.isBroken = True |
7376
21df384d6150
Added some inspirations received from Tobias.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
941 | self.isException = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
942 | |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
943 | disassembly = None |
5124
1ba8ee313b57
Continued modernizing the debugger interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4830
diff
changeset
|
944 | stack = [] |
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
|
945 | 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
|
946 | 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
|
947 | frlist.reverse() |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
948 | disassembly = self.__disassemble(frlist[0][0]) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
949 | |
6687
352a7abb5582
Show correct line number on specific exceptions.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6645
diff
changeset
|
950 | self.currentFrame = frlist[0][0] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
951 | stack = self.getStack(frlist[self.skipFrames :]) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
952 | |
5560
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
953 | self._dbgClient.lockClient() |
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
954 | self._dbgClient.currentThread = self |
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
955 | self._dbgClient.currentThreadExec = self |
7986
2971d5d19951
Fixed a few thread related issues in the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
956 | self._dbgClient.sendException(exctypetxt, excvaltxt, stack, self.name) |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
957 | self._dbgClient.setDisassembly(disassembly) |
5560
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
958 | self._dbgClient.dumpThreadList() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
959 | |
5560
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
960 | if exctb is not None: |
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
961 | # When polling kept enabled, it isn't possible to resume after an |
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
962 | # unhandled exception without further user interaction. |
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
963 | self._dbgClient.eventLoop(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
964 | |
5050
a6335e924d08
Hide frames belonging to the debugger at a recursion exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5048
diff
changeset
|
965 | self.skipFrames = 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
966 | |
5560
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
967 | self.isBroken = False |
7376
21df384d6150
Added some inspirations received from Tobias.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
968 | self.isException = False |
5582
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
969 | stop_everywhere = self.stop_everywhere |
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
970 | self.stop_everywhere = False |
5560
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
971 | self.eventPollFlag = False |
597164ed39b7
Prevent ordinary breakpoints to steal the focus from an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5550
diff
changeset
|
972 | self._dbgClient.unlockClient() |
5582
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
973 | self.stop_everywhere = stop_everywhere |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
974 | |
7397
f8d2f6dd6636
Fixed an issue causing multi threaded debugging sessions to hang.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7376
diff
changeset
|
975 | self._dbgClient.dumpThreadList() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
976 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
977 | def __extractExceptionName(self, exctype): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
978 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
979 | 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
|
980 | type object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
981 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
982 | @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
|
983 | @return exception name (string) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
984 | """ |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
985 | return str(exctype).replace("<class '", "").replace("'>", "") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
986 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
987 | def __extract_stack(self, exctb): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
988 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
989 | Private member to return a list of stack frames. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
990 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
991 | @param exctb exception traceback |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
992 | @return list of stack frames |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
993 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
994 | tb = exctb |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
995 | stack = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
996 | while tb is not None: |
6687
352a7abb5582
Show correct line number on specific exceptions.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
6645
diff
changeset
|
997 | stack.append((tb.tb_frame, tb.tb_lineno)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
998 | tb = tb.tb_next |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
999 | tb = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1000 | return stack |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1001 | |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1002 | def __disassemble(self, frame): |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1003 | """ |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1004 | Private method to generate a disassembly of the given code object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1005 | |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1006 | @param frame frame object to be disassembled |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1007 | @type code |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1008 | @return dictionary containing the disassembly information |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1009 | @rtype dict |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1010 | """ |
7711
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1011 | co = frame.f_code |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1012 | disDict = { |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1013 | "lasti": frame.f_lasti, |
7711
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1014 | "firstlineno": co.co_firstlineno, |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1015 | "instructions": [], |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1016 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1017 | |
7711
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1018 | # 1. disassembly info |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1019 | for instr in dis.get_instructions(co): |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1020 | instrDict = { |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1021 | "lineno": 0 if instr.starts_line is None else instr.starts_line, |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1022 | "isJumpTarget": instr.is_jump_target, |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1023 | "offset": instr.offset, |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1024 | "opname": instr.opname, |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1025 | "arg": instr.arg, |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1026 | "argrepr": instr.argrepr, |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1027 | } |
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1028 | disDict["instructions"].append(instrDict) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1029 | |
7711
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1030 | # 2. code info |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1031 | # Note: keep in sync with PythonDisViewer.__createCodeInfo() |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1032 | disDict["codeinfo"] = { |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1033 | "name": co.co_name, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1034 | "filename": co.co_filename, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1035 | "firstlineno": co.co_firstlineno, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1036 | "argcount": co.co_argcount, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1037 | "kwonlyargcount": co.co_kwonlyargcount, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1038 | "nlocals": co.co_nlocals, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1039 | "stacksize": co.co_stacksize, |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1040 | "flags": dis.pretty_flags(co.co_flags), |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1041 | "consts": [str(const) for const in co.co_consts], |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1042 | "names": [str(name) for name in co.co_names], |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1043 | "varnames": [str(name) for name in co.co_varnames], |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1044 | "freevars": [str(var) for var in co.co_freevars], |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1045 | "cellvars": [str(var) for var in co.co_cellvars], |
5e6792b85a8a
Added capability to show information about a code object.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7707
diff
changeset
|
1046 | } |
7714
79bde78e3e16
PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7711
diff
changeset
|
1047 | try: |
79bde78e3e16
PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7711
diff
changeset
|
1048 | disDict["codeinfo"]["posonlyargcount"] = co.co_posonlyargcount |
79bde78e3e16
PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7711
diff
changeset
|
1049 | except AttributeError: |
79bde78e3e16
PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7711
diff
changeset
|
1050 | # does not exist prior to 3.8.0 |
79bde78e3e16
PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7711
diff
changeset
|
1051 | disDict["codeinfo"]["posonlyargcount"] = 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1052 | |
7707
6abcf4275d0e
Added a viewer to visualize Python byte code generated from a Python traceback of an exception as an additional tab of the debug viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7639
diff
changeset
|
1053 | return disDict |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1054 | |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1055 | def __extractSystemExitMessage(self, excinfo): |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1056 | """ |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1057 | Private method to get the SystemExit code and message. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1058 | |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1059 | @param excinfo details about the SystemExit exception |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1060 | @type tuple(Exception, excval object, traceback frame object) |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1061 | @return SystemExit code and message |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1062 | @rtype int, str |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1063 | """ |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1064 | exctype, excval, exctb = excinfo |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1065 | if excval is None: |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1066 | exitcode = 0 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1067 | message = "" |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
1068 | elif isinstance(excval, str): |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1069 | exitcode = 1 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1070 | message = excval |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1071 | elif isinstance(excval, bytes): |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1072 | exitcode = 1 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1073 | message = excval.decode() |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1074 | elif isinstance(excval, int): |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1075 | exitcode = excval |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1076 | message = "" |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1077 | elif isinstance(excval, SystemExit): |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1078 | code = excval.code |
7637
c878e8255972
Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7628
diff
changeset
|
1079 | if isinstance(code, str): |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1080 | exitcode = 1 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1081 | message = code |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1082 | elif isinstance(code, bytes): |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1083 | exitcode = 1 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1084 | message = code.decode() |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1085 | elif isinstance(code, int): |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1086 | exitcode = code |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1087 | message = "" |
7421
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
1088 | elif code is None: |
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
1089 | exitcode = 0 |
4a9900aef04e
Continued with the multiprocess debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7405
diff
changeset
|
1090 | message = "" |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1091 | else: |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1092 | exitcode = 1 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1093 | message = str(code) |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1094 | else: |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1095 | exitcode = 1 |
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1096 | message = str(excval) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1097 | |
5537
706ac32a4538
Improved handling of program termination. atexit is only run once as specified anymore.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5536
diff
changeset
|
1098 | return exitcode, message |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1099 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1100 | def stop_here(self, frame): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1101 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
1102 | Public method reimplemented to filter out debugger files. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1103 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1104 | 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
|
1105 | debugger that are called from the application being debugged. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1106 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1107 | @param frame the frame object |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
1108 | @type frame object |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1109 | @return flag indicating whether the debugger should stop here |
5085
85dfb7886fb9
Determination where to stop in stop_here heavily reworked.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5084
diff
changeset
|
1110 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1111 | """ |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1112 | if self.__skipFrame(frame): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1113 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1114 | |
7897
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
1115 | if frame is self.stopframe: |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
1116 | if self.stoplineno == -1: |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
1117 | return False |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
1118 | return frame.f_lineno >= self.stoplineno |
9acc015ea443
Debugger: added support for the "Continue Until" debug action.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7894
diff
changeset
|
1119 | return self.stop_everywhere or frame is self.returnframe |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1120 | |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1121 | 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
|
1122 | """ |
5007
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
1123 | Public method to update the settings to trace into Python libraries. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1124 | |
5007
e2fa12bb0f53
Don't canonic the filename any more and cache it.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5005
diff
changeset
|
1125 | @param enable flag to debug into Python libraries |
5174 | 1126 | @type bool |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1127 | """ |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1128 | 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
|
1129 | # 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
|
1130 | if enable: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1131 | pathsToSkip = [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1132 | x |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1133 | for x in pathsToSkip |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1134 | if not x.endswith(("site-packages", "dist-packages", self.lib)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1135 | ] |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1136 | else: |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1137 | pathsToSkip.append(self.lib) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1138 | localLib = [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1139 | x |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1140 | for x in sys.path |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1141 | if x.endswith(("site-packages", "dist-packages")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1142 | and not x.startswith(self.lib) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1143 | ] |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1144 | pathsToSkip.extend(localLib) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1145 | |
5582
d829281d439f
Little improvements and avoid stepping into libs after an exception.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
5573
diff
changeset
|
1146 | self.pathsToSkip = tuple(set(pathsToSkip)) |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1147 | |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1148 | def __skipFrame(self, frame): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1149 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1150 | Private method to filter out debugger files. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1151 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1152 | 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
|
1153 | debugger that are called from the application being debugged. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1154 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1155 | @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
|
1156 | @type frame object |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1157 | @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
|
1158 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1159 | """ |
5005
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1160 | try: |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1161 | 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
|
1162 | except KeyError: |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1163 | 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
|
1164 | 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
|
1165 | return ret |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1166 | except AttributeError: |
684f5ba04f0b
First improvements on debugger speed: Cheaper detection of unwanted files and
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4830
diff
changeset
|
1167 | # 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
|
1168 | return True |