eric6/DebugClients/Python/BreakpointWatch.py

Wed, 01 Jan 2020 11:57:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:57:23 +0100
changeset 7360
9190402e4505
parent 7249
0bf517e60f54
child 7628
f904d0eef264
permissions
-rw-r--r--

Updated copyright for 2020.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
3 # Copyright (c) 2016 - 2020 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
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
11
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 class Breakpoint:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
14 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
15 Breakpoint class.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
16
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
17 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
18 (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
19
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
20 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
21 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
22 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
23
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
24 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
25 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
26 breakpoints are.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
27 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
28 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
29 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
30 breakInFrameCache = {}
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
31
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
32 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
33 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
34 Constructor
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
35
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
36 @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
37 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
38 @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
39 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
40 @keyparam temporary flag to indicate a temporary breakpoint
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
41 @type bool
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
42 @keyparam cond Python expression which dynamically enables this bp
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
43 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
44 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
45 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
46 self.file = filename
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
47 self.line = lineno
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
48 self.temporary = temporary
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
49 self.cond = cond
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
50 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
51 self.ignore = 0
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
52 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
53 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
54 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
55 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
56 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
57 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
58
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
59 def deleteMe(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
60 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
61 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
62 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
63 try:
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
64 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
65 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
66 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
67 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
68 except KeyError:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
69 pass
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
70
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
71 def enable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
72 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
73 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
74 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
75 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
76
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
77 def disable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
78 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
79 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
80 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
81 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
82
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
83 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
84 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
85 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
86 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
87
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
88 @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
89 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
90 @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
91 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
92 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
93 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
94 if bp:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
95 bp.deleteMe()
5061
753f720c2a48 Bugfix to react on new breakpoints in a running program.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5045
diff changeset
96 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
97
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
98 @staticmethod
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
99 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
100 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
101 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
102 """
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
103 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
104 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
105 Breakpoint.breakInFrameCache.clear()
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
106
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
107 @staticmethod
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
108 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
109 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
110 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
111
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
112 Because eric6 supports only one breakpoint per line, this
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
113 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
114
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
115 @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
116 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
117 @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
118 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
119 @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
120 @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
121 """
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
122 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
123
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
124 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
125 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
126 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
127 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
128 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
129
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
130 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
131 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
132 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
133
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
134 @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
135 @type str
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
136 @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
137 @type int
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
138 @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
139 @type frame object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
140 @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
141 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
142 @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
143 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
144 b = Breakpoint.breaks[filename, lineno]
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
145 if not b.enabled:
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
146 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
147
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
148 # 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
149 b.hits += 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
150 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
151 # 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
152 # 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
153 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
154 b.ignore -= 1
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
155 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
156 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
157 # 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
158 # to delete if temporary
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
159 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
160 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
161 # Conditional bp.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
162 # 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
163 # 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
164 try:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
165 val = eval(b.cond, frame.f_globals, frame.f_locals)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
166 if val:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
167 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
168 b.ignore -= 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
169 # continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
170 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
171 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
172 except Exception:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
173 # 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
174 # 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
175 # 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
176 # 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
177 # as another hint to user.
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
178 return (b, False)
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
179 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
180
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
181
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
182 class Watch:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
183 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
184 Watch class.
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
185
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
186 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
187 (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
188 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
189 watches = []
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
190
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
191 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
192 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
193 Constructor
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
194
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
195 @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
196 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
197 @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
198 @type code object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
199 @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
200 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
201 @keyparam temporary flag for temporary watches
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
202 @type bool
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
203 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
204 # Should not occur
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
205 if not cond:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
206 return
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
207
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
208 self.cond = cond
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
209 self.compiledCond = compiledCond
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
210 self.temporary = temporary
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
211
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
212 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
213 self.ignore = 0
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
214
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
215 self.created = False
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
216 self.changed = False
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
217 if flag == '??created??':
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
218 self.created = True
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
219 elif flag == '??changed??':
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
220 self.changed = True
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
221
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
222 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
223 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
224
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
225 def deleteMe(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
226 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
227 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
228 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
229 try:
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
230 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
231 except ValueError:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
232 pass
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
233
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
234 def enable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
235 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
236 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
237 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
238 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
239
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
240 def disable(self):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
241 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
242 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
243 """
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
244 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
245
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
246 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
247 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
248 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
249 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
250
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
251 @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
252 @type str
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 try:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
255 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
256 except ValueError:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
257 pass
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
258
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
259 @staticmethod
5081
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
260 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
261 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
262 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
263 """
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
264 del Watch.watches[:]
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
265
4c896f626bd6 Bdb.clear_all_breaks doesn't work anymore. BreakpointWatch improved.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5061
diff changeset
266 @staticmethod
5041
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
267 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
268 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
269 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
270
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
271 @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
272 @type str
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
273 @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
274 @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
275 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
276 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
277 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
278 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
279
93f82da09f22 Fixed some code style issues detected by the new 'return' checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
280 return None
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 @staticmethod
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
283 def effectiveWatch(frame):
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
284 """
5815
223fa32b3a32 Extended the doc style checker again and corrected some doc style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5535
diff changeset
285 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
286
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
287 @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
288 @type frame object
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
289 @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
290 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
291 @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
292 """
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
293 for b in Watch.watches:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
294 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
295 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
296 try:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
297 val = eval(b.compiledCond, frame.f_globals, frame.f_locals)
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
298 if b.created:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
299 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
300 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
301 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
302 b.values[frame] = [1, val, b.ignore]
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
303 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
304
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
305 elif b.changed:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
306 try:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
307 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
308 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
309 else:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
310 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
311 except KeyError:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
312 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
313
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
314 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
315 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
316 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
317 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
318 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
319
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
320 elif val:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
321 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
322 b.ignore -= 1
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
323 continue
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
324 else:
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
325 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
326 except Exception:
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
327 continue
5174
8c48f5e0cd92 Get changes from current branch.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5170
diff changeset
328 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
329
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
330
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
331 #
f00a4c8bcbbd Breakpoint and Watch and thier basic methods in new classes extracted.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
diff changeset
332 # eflag: noqa = M702

eric ide

mercurial