20"""GDB commands for working with xmethods."""
25 return re.compile(regexp)
27 raise SyntaxError(
"Invalid %s regexp: %s", part_name, regexp)
31 """Parses the arguments passed to a xmethod command.
34 arg: The argument string passed to a xmethod command.
37 A 3-tuple: (<locus matching regular expression>,
38 <matcher matching regular expression>,
39 <name matching regular experession>)
41 argv = gdb.string_to_argv(arg)
44 raise SyntaxError(
"Too many arguments to command.")
46 matcher_name_regexp =
""
49 locus_regexp = argv[0]
51 parts = argv[1].split(
";", 1)
52 matcher_name_regexp = parts[0]
54 xm_name_regexp = parts[1]
67 """Returns a dict of matching globally registered xmethods.
70 locus_re: Even though only globally registered xmethods are
71 looked up, they will be looked up only if 'global' matches
73 matcher_re: The regular expression matching the names of xmethods.
76 A dict of matching globally registered xmethod matchers. The only
77 key in the dict will be 'global'.
80 xm_dict = {locus_str: []}
81 if locus_re.match(
"global"):
82 xm_dict[locus_str].extend([m
for m
in gdb.xmethods
if matcher_re.match(m.name)])
87 """Returns a dict of matching registered xmethods in the LOCI.
90 loci: The list of loci to lookup matching xmethods in.
91 locus_re: If a locus is an objfile, then xmethod matchers will be
92 looked up in it only if its filename matches the regular
93 expression LOCUS_RE. If a locus is the current progspace,
94 then xmethod matchers will be looked up in it only if the
95 string "progspace" matches LOCUS_RE.
96 matcher_re: The regular expression to match the xmethod matcher
100 A dict of matching xmethod matchers. The keys of the dict are the
101 filenames of the loci the xmethod matchers belong to.
105 if isinstance(locus, gdb.Progspace):
106 if not locus_re.match(
"progspace"):
108 locus_type =
"progspace"
110 if not locus_re.match(locus.filename):
112 locus_type =
"objfile"
113 locus_str =
"%s %s" % (locus_type, locus.filename)
114 xm_dict[locus_str] = [m
for m
in locus.xmethods
if matcher_re.match(m.name)]
119 """Print a dictionary of xmethods."""
129 for locus_str
in xm_dict:
130 if not xm_dict[locus_str]:
132 print(
"Xmethods in %s:" % locus_str)
133 for matcher
in xm_dict[locus_str]:
135 if not matcher.methods:
137 for m
in matcher.methods:
138 if name_re
is None or name_re.match(m.name):
143 """Set the status (enabled/disabled) of a dictionary of xmethods."""
144 for locus_str, matchers
in xm_dict.items():
145 for matcher
in matchers:
149 matcher.enabled = status
151 if not matcher.methods:
154 for m
in matcher.methods:
155 if name_re.match(m.name):
160 """Set the status (enabled/disabled) of xmethods matching ARG.
161 This is a helper function for enable/disable commands. ARG is the
162 argument string passed to the commands.
179 """GDB command to list registered xmethod matchers.
181 Usage: info xmethod [LOCUS-REGEXP [NAME-REGEXP]]
183 LOCUS-REGEXP is a regular expression matching the location of the
184 xmethod matchers. If it is omitted, all registered xmethod matchers
185 from all loci are listed. A locus could be 'global', a regular expression
186 matching the current program space's filename, or a regular expression
187 matching filenames of objfiles. Locus could be 'progspace' to specify that
188 only xmethods from the current progspace should be listed.
190 NAME-REGEXP is a regular expression matching the names of xmethod
191 matchers. If this omitted for a specified locus, then all registered
192 xmethods in the locus are listed. To list only a certain xmethods
193 managed by a single matcher, the name regexp can be specified as
194 matcher-name-regexp;xmethod-name-regexp."""
197 super(InfoXMethod, self).
__init__(
"info xmethod", gdb.COMMAND_DATA)
214 """GDB command to enable a specified (group of) xmethod(s).
216 Usage: enable xmethod [LOCUS-REGEXP [NAME-REGEXP]]
218 LOCUS-REGEXP is a regular expression matching the location of the
219 xmethod matchers. If it is omitted, all registered xmethods matchers
220 from all loci are enabled. A locus could be 'global', a regular expression
221 matching the current program space's filename, or a regular expression
222 matching filenames of objfiles. Locus could be 'progspace' to specify that
223 only xmethods from the current progspace should be enabled.
225 NAME-REGEXP is a regular expression matching the names of xmethods
226 within a given locus. If this omitted for a specified locus, then all
227 registered xmethod matchers in the locus are enabled. To enable only
228 a certain xmethods managed by a single matcher, the name regexp can be
229 specified as matcher-name-regexp;xmethod-name-regexp."""
232 super(EnableXMethod, self).
__init__(
"enable xmethod", gdb.COMMAND_DATA)
239 """GDB command to disable a specified (group of) xmethod(s).
241 Usage: disable xmethod [LOCUS-REGEXP [NAME-REGEXP]]
243 LOCUS-REGEXP is a regular expression matching the location of the
244 xmethod matchers. If it is omitted, all registered xmethod matchers
245 from all loci are disabled. A locus could be 'global', a regular
246 expression matching the current program space's filename, or a regular
247 expression filenames of objfiles. Locus could be 'progspace' to specify
248 that only xmethods from the current progspace should be disabled.
250 NAME-REGEXP is a regular expression matching the names of xmethods
251 within a given locus. If this omitted for a specified locus, then all
252 registered xmethod matchers in the locus are disabled. To disable
253 only a certain xmethods managed by a single matcher, the name regexp
254 can be specified as matcher-name-regexp;xmethod-name-regexp."""
257 super(DisableXMethod, self).
__init__(
"disable xmethod", gdb.COMMAND_DATA)
264 """Installs the xmethod commands."""
static const char * get_status_string(amd_dbgapi_status_t status)
invoke(self, arg, from_tty)
invoke(self, arg, from_tty)
invoke(self, arg, from_tty)
validate_xm_regexp(part_name, regexp)
get_global_method_matchers(locus_re, matcher_re)
register_xmethod_commands()
print_xm_info(xm_dict, name_re)
get_method_matchers_in_loci(loci, locus_re, matcher_re)
set_xm_status1(xm_dict, name_re, status)
set_xm_status(arg, status)
parse_xm_command_args(arg)