eric6/DebugClients/Python/BreakpointWatch.py

Sat, 01 May 2021 14:27:20 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 01 May 2021 14:27:20 +0200
branch
maintenance
changeset 8273
698ae46f40a4
parent 8043
0acf98cd089a
parent 8243
cc717c2ae956
permissions
-rw-r--r--

Merged with default branch to prepare release 21.5.

5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7900
diff changeset
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
4 #
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
5
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
6 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
7 Module implementing the breakpoint and watch class.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
8 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
9
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
10 import os
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: 7960
diff changeset
11 import contextlib
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
12
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
13
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
14 class Breakpoint:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
15 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
16 Breakpoint class.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
17
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
18 Implements temporary breakpoints, ignore counts, disabling and
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
19 (re)-enabling, and conditionals.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
20
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
21 Breakpoints are indexed by the file,line tuple using breaks. It
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
22 points to a single Breakpoint instance. This is rather different to
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
23 the original bdb, since there may be more than one breakpoint per line.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
24
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
25 To test for a specific line in a file there is another dict breakInFile,
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
26 which is indexed only by filename and holds all line numbers where
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
27 breakpoints are.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
28 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
29 breaks = {} # indexed by (filename, lineno) tuple: Breakpoint
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
30 breakInFile = {} # indexed by filename: [lineno]
5045
50862a6a2c63 Check only once if a function / method has a breakpoint.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5041
diff changeset
31 breakInFrameCache = {}
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
32
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
33 def __init__(self, filename, lineno, temporary=False, cond=None):
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
34 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
35 Constructor
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
36
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
37 @param filename file name where a breakpoint is set
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
38 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
39 @param lineno line number of the breakpoint
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
40 @type int
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
41 @param temporary flag to indicate a temporary breakpoint
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
42 @type bool
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
43 @param cond Python expression which dynamically enables this bp
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
44 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
45 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
46 filename = os.path.abspath(filename)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
47 self.file = filename
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
48 self.line = lineno
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
49 self.temporary = temporary
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
50 self.cond = cond
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
51 self.enabled = True
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
52 self.ignore = 0
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
53 self.hits = 0
5535
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
54 Breakpoint.breaks[(filename, lineno)] = self
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
55 lines = Breakpoint.breakInFile.setdefault(filename, [])
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
56 if lineno not in lines:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
57 lines.append(lineno)
5535
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
58 Breakpoint.breakInFrameCache.clear()
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
59
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
60 def deleteMe(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
61 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
62 Public method to clear this breakpoint.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
63 """
8243
cc717c2ae956 Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8240
diff changeset
64 with contextlib.suppress(KeyError):
5535
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
65 del Breakpoint.breaks[(self.file, self.line)]
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
66 Breakpoint.breakInFile[self.file].remove(self.line)
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
67 if not Breakpoint.breakInFile[self.file]:
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
68 del Breakpoint.breakInFile[self.file]
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
69
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
70 def enable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
71 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
72 Public method to enable this breakpoint.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
73 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
74 self.enabled = True
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
75
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
76 def disable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
77 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
78 Public method to disable this breakpoint.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
79 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
80 self.enabled = False
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
81
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
82 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
83 def clear_break(filename, lineno):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
84 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
85 Static method reimplemented from bdb.py to clear a breakpoint.
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
86
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
87 @param filename file name of the bp to retrieve
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
88 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
89 @param lineno line number of the bp to retrieve
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
90 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
91 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
92 bp = Breakpoint.breaks.get((filename, lineno))
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
93 if bp:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
94 bp.deleteMe()
5061
753f720c2a48 Bugfix to react on new breakpoints in a running program.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
95 Breakpoint.breakInFrameCache.clear()
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
96
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
97 @staticmethod
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
98 def clear_all_breaks():
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
99 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
100 Static method to clear all breakpoints.
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
101 """
5535
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
102 Breakpoint.breaks.clear()
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
103 Breakpoint.breakInFile.clear()
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
104 Breakpoint.breakInFrameCache.clear()
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
105
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
106 @staticmethod
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
107 def get_break(filename, lineno):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
108 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
109 Static method to get the breakpoint of a particular line.
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
110
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
111 Because eric supports only one breakpoint per line, this
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
112 method will return only one breakpoint.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
113
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
114 @param filename file name of the bp to retrieve
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
115 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
116 @param lineno line number of the bp to retrieve
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
117 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
118 @return Breakpoint or None, if there is no bp
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
119 @rtype Breakpoint object or None
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
120 """
5170
fb9168c2e069 Fix an issue when a breakpoint should be ignored a number of times.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5081
diff changeset
121 return Breakpoint.breaks.get((filename, lineno))
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
122
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
123 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
124 def effectiveBreak(filename, lineno, frame):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
125 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
126 Static method to determine which breakpoint for this filename:lineno
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
127 is to be acted upon.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
128
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
129 Called only if we know there is a bpt at this
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
130 location. Returns breakpoint that was triggered and a flag
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
131 that indicates if it is ok to delete a temporary bp.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
132
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
133 @param filename file name of the bp to retrieve
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
134 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
135 @param lineno line number of the bp to retrieve
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
136 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
137 @param frame the current execution frame
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
138 @type frame object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
139 @return tuple of Breakpoint and a flag to indicate, that a
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
140 temporary breakpoint may be deleted
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
141 @rtype tuple of Breakpoint, bool
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
142 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
143 b = Breakpoint.breaks[filename, lineno]
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
144 if not b.enabled:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
145 return (None, False)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
146
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
147 # Count every hit when bp is enabled
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
148 b.hits += 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
149 if not b.cond:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
150 # If unconditional, and ignoring,
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
151 # go on to next, else break
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
152 if b.ignore > 0:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
153 b.ignore -= 1
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
154 return (None, False)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
155 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
156 # breakpoint and marker that's ok
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
157 # to delete if temporary
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
158 return (b, True)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
159 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
160 # Conditional bp.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
161 # Ignore count applies only to those bpt hits where the
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
162 # condition evaluates to true.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
163 try:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
164 val = eval(b.cond, frame.f_globals, frame.f_locals) # secok
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
165 if val:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
166 if b.ignore > 0:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
167 b.ignore -= 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
168 # continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
169 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
170 return (b, True)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
171 except Exception:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
172 # if eval fails, most conservative
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
173 # thing is to stop on breakpoint
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
174 # regardless of ignore count.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
175 # Don't delete temporary,
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
176 # as another hint to user.
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
177 return (b, False)
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
178 return (None, False)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
179
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
180
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
181 class Watch:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
182 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
183 Watch class.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
184
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
185 Implements temporary watches, ignore counts, disabling and
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
186 (re)-enabling, and conditionals.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
187 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
188 watches = []
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
189
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
190 def __init__(self, cond, compiledCond, flag, temporary=False):
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
191 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
192 Constructor
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
193
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
194 @param cond condition as string with flag
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
195 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
196 @param compiledCond precompiled condition
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
197 @type code object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
198 @param flag indicates type of watch (created or changed)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
199 @type str
7900
72b88fb20261 Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
200 @param temporary flag for temporary watches
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
201 @type bool
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
202 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
203 # Should not occur
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
204 if not cond:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
205 return
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
206
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
207 self.cond = cond
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
208 self.compiledCond = compiledCond
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
209 self.temporary = temporary
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
210
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
211 self.enabled = True
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
212 self.ignore = 0
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
213
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
214 self.created = False
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
215 self.changed = False
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
216 if flag == '??created??':
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
217 self.created = True
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
218 elif flag == '??changed??':
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
219 self.changed = True
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
220
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
221 self.values = {}
5535
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
222 Watch.watches.append(self)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
223
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
224 def deleteMe(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
225 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
226 Public method to clear this watch expression.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
227 """
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: 7960
diff changeset
228 with contextlib.suppress(ValueError):
5535
3296c56acdbf Access breakpoints and watches only by thier class variable (more reliable with threads).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5389
diff changeset
229 del Watch.watches[self]
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
230
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
231 def enable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
232 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
233 Public method to enable this watch.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
234 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
235 self.enabled = True
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
236
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
237 def disable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
238 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
239 Public method to disable this watch.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
240 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
241 self.enabled = False
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
242
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
243 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
244 def clear_watch(cond):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
245 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
246 Static method to clear a watch expression.
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
247
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
248 @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:
diff changeset
249 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
250 """
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: 7960
diff changeset
251 with contextlib.suppress(ValueError):
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
252 Watch.watches.remove(Watch.get_watch(cond))
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
253
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
254 @staticmethod
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
255 def clear_all_watches():
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
256 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
257 Static method to clear all watch expressions.
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
258 """
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
259 del Watch.watches[:]
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
260
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
261 @staticmethod
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
262 def get_watch(cond):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
263 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
264 Static method to get a watch expression.
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
265
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
266 @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:
diff changeset
267 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
268 @return reference to the watch point
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
269 @rtype Watch or None
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
270 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
271 for b in Watch.watches:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
272 if b.cond == cond:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
273 return b
6891
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
274
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
275 return None
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
276
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
277 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
278 def effectiveWatch(frame):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
279 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
280 Static method to determine, if a watch expression is effective.
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
281
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
282 @param frame the current execution frame
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
283 @type frame object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
284 @return tuple of watch expression and a flag to indicate, that a
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
285 temporary watch expression may be deleted
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
286 @rtype tuple of Watch, int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
287 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
288 for b in Watch.watches:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
289 if not b.enabled:
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
290 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
291 try:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
292 val = eval(b.compiledCond, frame.f_globals, frame.f_locals)
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
293 # secok
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
294 if b.created:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
295 if frame in b.values:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
296 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
297 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
298 b.values[frame] = [1, val, b.ignore]
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
299 return (b, True)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
300
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
301 elif b.changed:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
302 try:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
303 if b.values[frame][1] != val:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
304 b.values[frame][1] = val
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
305 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
306 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
307 except KeyError:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
308 b.values[frame] = [1, val, b.ignore]
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
309
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
310 if b.values[frame][2] > 0:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
311 b.values[frame][2] -= 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
312 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
313 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
314 return (b, True)
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
315
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
316 elif val:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
317 if b.ignore > 0:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
318 b.ignore -= 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
319 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
320 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
321 return (b, True)
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
322 except Exception: # secok
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
323 continue
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
324 return (None, False)

eric ide

mercurial