2 # Copyright (C) 2008-2019 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 class CallerIs(gdb
.Function
):
21 """Check the calling function's name.
23 Usage: $_caller_is (NAME [, NUMBER-OF-FRAMES])
27 NAME: The name of the function to search for.
29 NUMBER-OF-FRAMES: How many stack frames to traverse back from the currently
30 selected frame to compare with. If the value is greater than the depth of
31 the stack from that point then the result is False.
35 True if the function's name at the specified frame is equal to NAME."""
38 super(CallerIs
, self
).__init
__("_caller_is")
40 def invoke(self
, name
, nframes
= 1):
42 raise ValueError("nframes must be >= 0")
43 frame
= gdb
.selected_frame()
49 return frame
.name() == name
.string()
51 class CallerMatches(gdb
.Function
):
52 """Compare the calling function's name with a regexp.
54 Usage: $_caller_matches (REGEX [, NUMBER-OF-FRAMES])
58 REGEX: The regular expression to compare the function's name with.
60 NUMBER-OF-FRAMES: How many stack frames to traverse back from the currently
61 selected frame to compare with. If the value is greater than the depth of
62 the stack from that point then the result is False.
66 True if the function's name at the specified frame matches REGEX."""
69 super(CallerMatches
, self
).__init
__("_caller_matches")
71 def invoke(self
, name
, nframes
= 1):
73 raise ValueError("nframes must be >= 0")
74 frame
= gdb
.selected_frame()
80 return re
.match(name
.string(), frame
.name()) is not None
82 class AnyCallerIs(gdb
.Function
):
83 """Check all calling function's names.
85 Usage: $_any_caller_is (NAME [, NUMBER-OF-FRAMES])
89 NAME: The name of the function to search for.
91 NUMBER-OF-FRAMES: How many stack frames to traverse back from the currently
92 selected frame to compare with. If the value is greater than the depth of
93 the stack from that point then the result is False.
97 True if any function's name is equal to NAME."""
100 super(AnyCallerIs
, self
).__init
__("_any_caller_is")
102 def invoke(self
, name
, nframes
= 1):
104 raise ValueError("nframes must be >= 0")
105 frame
= gdb
.selected_frame()
107 if frame
.name() == name
.string():
109 frame
= frame
.older()
112 nframes
= nframes
- 1
115 class AnyCallerMatches(gdb
.Function
):
116 """Compare all calling function's names with a regexp.
118 Usage: $_any_caller_matches (REGEX [, NUMBER-OF-FRAMES])
122 REGEX: The regular expression to compare the function's name with.
124 NUMBER-OF-FRAMES: How many stack frames to traverse back from the currently
125 selected frame to compare with. If the value is greater than the depth of
126 the stack from that point then the result is False.
130 True if any function's name matches REGEX."""
133 super(AnyCallerMatches
, self
).__init
__("_any_caller_matches")
135 def invoke(self
, name
, nframes
= 1):
137 raise ValueError("nframes must be >= 0")
138 frame
= gdb
.selected_frame()
139 name_re
= re
.compile(name
.string())
141 if name_re
.match(frame
.name()) is not None:
143 frame
= frame
.older()
146 nframes
= nframes
- 1
This page took 0.050463 seconds and 4 git commands to generate.