summaryrefslogtreecommitdiff
path: root/gdb/python/lib/gdb/command/xmethods.py
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/lib/gdb/command/xmethods.py')
-rw-r--r--gdb/python/lib/gdb/command/xmethods.py133
1 files changed, 66 insertions, 67 deletions
diff --git a/gdb/python/lib/gdb/command/xmethods.py b/gdb/python/lib/gdb/command/xmethods.py
index b8ac4cac0f1..cda234f9ce1 100644
--- a/gdb/python/lib/gdb/command/xmethods.py
+++ b/gdb/python/lib/gdb/command/xmethods.py
@@ -56,9 +56,11 @@ def parse_xm_command_args(arg):
name_re = validate_xm_regexp("xmethod name", xm_name_regexp)
else:
name_re = None
- return (validate_xm_regexp("locus", locus_regexp),
- validate_xm_regexp("matcher name", matcher_name_regexp),
- name_re)
+ return (
+ validate_xm_regexp("locus", locus_regexp),
+ validate_xm_regexp("matcher name", matcher_name_regexp),
+ name_re,
+ )
def get_global_method_matchers(locus_re, matcher_re):
@@ -75,10 +77,9 @@ def get_global_method_matchers(locus_re, matcher_re):
key in the dict will be 'global'.
"""
locus_str = "global"
- xm_dict = { locus_str: [] }
+ xm_dict = {locus_str: []}
if locus_re.match("global"):
- xm_dict[locus_str].extend(
- [m for m in gdb.xmethods if matcher_re.match(m.name)])
+ xm_dict[locus_str].extend([m for m in gdb.xmethods if matcher_re.match(m.name)])
return xm_dict
@@ -102,7 +103,7 @@ def get_method_matchers_in_loci(loci, locus_re, matcher_re):
xm_dict = {}
for locus in loci:
if isinstance(locus, gdb.Progspace):
- if not locus_re.match('progspace'):
+ if not locus_re.match("progspace"):
continue
locus_type = "progspace"
else:
@@ -110,32 +111,32 @@ def get_method_matchers_in_loci(loci, locus_re, matcher_re):
continue
locus_type = "objfile"
locus_str = "%s %s" % (locus_type, locus.filename)
- xm_dict[locus_str] = [
- m for m in locus.xmethods if matcher_re.match(m.name)]
+ xm_dict[locus_str] = [m for m in locus.xmethods if matcher_re.match(m.name)]
return xm_dict
def print_xm_info(xm_dict, name_re):
"""Print a dictionary of xmethods."""
+
def get_status_string(m):
if not m.enabled:
return " [disabled]"
else:
- return ""
+ return ""
if not xm_dict:
return
for locus_str in xm_dict:
if not xm_dict[locus_str]:
continue
- print ("Xmethods in %s:" % locus_str)
+ print("Xmethods in %s:" % locus_str)
for matcher in xm_dict[locus_str]:
- print (" %s%s" % (matcher.name, get_status_string(matcher)))
+ print(" %s%s" % (matcher.name, get_status_string(matcher)))
if not matcher.methods:
continue
for m in matcher.methods:
if name_re is None or name_re.match(m.name):
- print (" %s%s" % (m.name, get_status_string(m)))
+ print(" %s%s" % (m.name, get_status_string(m)))
def set_xm_status1(xm_dict, name_re, status):
@@ -161,75 +162,74 @@ def set_xm_status(arg, status):
argument string passed to the commands.
"""
locus_re, matcher_re, name_re = parse_xm_command_args(arg)
- set_xm_status1(get_global_method_matchers(locus_re, matcher_re), name_re,
- status)
+ set_xm_status1(get_global_method_matchers(locus_re, matcher_re), name_re, status)
set_xm_status1(
- get_method_matchers_in_loci(
- [gdb.current_progspace()], locus_re, matcher_re),
+ get_method_matchers_in_loci([gdb.current_progspace()], locus_re, matcher_re),
name_re,
- status)
+ status,
+ )
set_xm_status1(
get_method_matchers_in_loci(gdb.objfiles(), locus_re, matcher_re),
name_re,
- status)
+ status,
+ )
class InfoXMethod(gdb.Command):
"""GDB command to list registered xmethod matchers.
-Usage: info xmethod [LOCUS-REGEXP [NAME-REGEXP]]
+ Usage: info xmethod [LOCUS-REGEXP [NAME-REGEXP]]
-LOCUS-REGEXP is a regular expression matching the location of the
-xmethod matchers. If it is omitted, all registered xmethod matchers
-from all loci are listed. A locus could be 'global', a regular expression
-matching the current program space's filename, or a regular expression
-matching filenames of objfiles. Locus could be 'progspace' to specify that
-only xmethods from the current progspace should be listed.
+ LOCUS-REGEXP is a regular expression matching the location of the
+ xmethod matchers. If it is omitted, all registered xmethod matchers
+ from all loci are listed. A locus could be 'global', a regular expression
+ matching the current program space's filename, or a regular expression
+ matching filenames of objfiles. Locus could be 'progspace' to specify that
+ only xmethods from the current progspace should be listed.
-NAME-REGEXP is a regular expression matching the names of xmethod
-matchers. If this omitted for a specified locus, then all registered
-xmethods in the locus are listed. To list only a certain xmethods
-managed by a single matcher, the name regexp can be specified as
-matcher-name-regexp;xmethod-name-regexp."""
+ NAME-REGEXP is a regular expression matching the names of xmethod
+ matchers. If this omitted for a specified locus, then all registered
+ xmethods in the locus are listed. To list only a certain xmethods
+ managed by a single matcher, the name regexp can be specified as
+ matcher-name-regexp;xmethod-name-regexp."""
def __init__(self):
- super(InfoXMethod, self).__init__("info xmethod",
- gdb.COMMAND_DATA)
+ super(InfoXMethod, self).__init__("info xmethod", gdb.COMMAND_DATA)
def invoke(self, arg, from_tty):
locus_re, matcher_re, name_re = parse_xm_command_args(arg)
- print_xm_info(get_global_method_matchers(locus_re, matcher_re),
- name_re)
+ print_xm_info(get_global_method_matchers(locus_re, matcher_re), name_re)
print_xm_info(
get_method_matchers_in_loci(
- [gdb.current_progspace()], locus_re, matcher_re),
- name_re)
+ [gdb.current_progspace()], locus_re, matcher_re
+ ),
+ name_re,
+ )
print_xm_info(
- get_method_matchers_in_loci(gdb.objfiles(), locus_re, matcher_re),
- name_re)
+ get_method_matchers_in_loci(gdb.objfiles(), locus_re, matcher_re), name_re
+ )
class EnableXMethod(gdb.Command):
"""GDB command to enable a specified (group of) xmethod(s).
-Usage: enable xmethod [LOCUS-REGEXP [NAME-REGEXP]]
+ Usage: enable xmethod [LOCUS-REGEXP [NAME-REGEXP]]
-LOCUS-REGEXP is a regular expression matching the location of the
-xmethod matchers. If it is omitted, all registered xmethods matchers
-from all loci are enabled. A locus could be 'global', a regular expression
-matching the current program space's filename, or a regular expression
-matching filenames of objfiles. Locus could be 'progspace' to specify that
-only xmethods from the current progspace should be enabled.
+ LOCUS-REGEXP is a regular expression matching the location of the
+ xmethod matchers. If it is omitted, all registered xmethods matchers
+ from all loci are enabled. A locus could be 'global', a regular expression
+ matching the current program space's filename, or a regular expression
+ matching filenames of objfiles. Locus could be 'progspace' to specify that
+ only xmethods from the current progspace should be enabled.
-NAME-REGEXP is a regular expression matching the names of xmethods
-within a given locus. If this omitted for a specified locus, then all
-registered xmethod matchers in the locus are enabled. To enable only
-a certain xmethods managed by a single matcher, the name regexp can be
-specified as matcher-name-regexp;xmethod-name-regexp."""
+ NAME-REGEXP is a regular expression matching the names of xmethods
+ within a given locus. If this omitted for a specified locus, then all
+ registered xmethod matchers in the locus are enabled. To enable only
+ a certain xmethods managed by a single matcher, the name regexp can be
+ specified as matcher-name-regexp;xmethod-name-regexp."""
def __init__(self):
- super(EnableXMethod, self).__init__("enable xmethod",
- gdb.COMMAND_DATA)
+ super(EnableXMethod, self).__init__("enable xmethod", gdb.COMMAND_DATA)
def invoke(self, arg, from_tty):
set_xm_status(arg, True)
@@ -238,24 +238,23 @@ specified as matcher-name-regexp;xmethod-name-regexp."""
class DisableXMethod(gdb.Command):
"""GDB command to disable a specified (group of) xmethod(s).
-Usage: disable xmethod [LOCUS-REGEXP [NAME-REGEXP]]
+ Usage: disable xmethod [LOCUS-REGEXP [NAME-REGEXP]]
-LOCUS-REGEXP is a regular expression matching the location of the
-xmethod matchers. If it is omitted, all registered xmethod matchers
-from all loci are disabled. A locus could be 'global', a regular
-expression matching the current program space's filename, or a regular
-expression filenames of objfiles. Locus could be 'progspace' to specify
-that only xmethods from the current progspace should be disabled.
+ LOCUS-REGEXP is a regular expression matching the location of the
+ xmethod matchers. If it is omitted, all registered xmethod matchers
+ from all loci are disabled. A locus could be 'global', a regular
+ expression matching the current program space's filename, or a regular
+ expression filenames of objfiles. Locus could be 'progspace' to specify
+ that only xmethods from the current progspace should be disabled.
-NAME-REGEXP is a regular expression matching the names of xmethods
-within a given locus. If this omitted for a specified locus, then all
-registered xmethod matchers in the locus are disabled. To disable
-only a certain xmethods managed by a single matcher, the name regexp
-can be specified as matcher-name-regexp;xmethod-name-regexp."""
+ NAME-REGEXP is a regular expression matching the names of xmethods
+ within a given locus. If this omitted for a specified locus, then all
+ registered xmethod matchers in the locus are disabled. To disable
+ only a certain xmethods managed by a single matcher, the name regexp
+ can be specified as matcher-name-regexp;xmethod-name-regexp."""
def __init__(self):
- super(DisableXMethod, self).__init__("disable xmethod",
- gdb.COMMAND_DATA)
+ super(DisableXMethod, self).__init__("disable xmethod", gdb.COMMAND_DATA)
def invoke(self, arg, from_tty):
set_xm_status(arg, False)