return 0
print(title)
- print(" Priority Enabled Name")
+ style = gdb.Style("title")
+ print(
+ " %s %s %s"
+ % (style.apply("Priority"), style.apply("Enabled"), style.apply("Name"))
+ )
for frame_filter in sorted_frame_filters:
name = frame_filter[0]
try:
self.enabled_string(gdb.frames.get_enabled(frame_filter[1]))
)
print(" %s %s %s" % (priority, enabled, name))
- except Exception:
- e = sys.exc_info()[1]
- print(" Error printing filter '" + name + "': " + str(e))
+ except Exception as e:
+ gdb.warning("Error printing filter '" + name + "': " + str(e))
if blank_line:
print("")
return 1
def invoke(self, arg, from_tty):
any_printed = self.print_list("global frame-filters:", gdb.frame_filters, True)
+ file_style = gdb.Style("filename")
cp = gdb.current_progspace()
+ cp_filename = cp.filename
+ if cp_filename is None:
+ cp_filename = "<no-file>"
+ else:
+ cp_filename = file_style.apply(cp_filename)
any_printed += self.print_list(
- "progspace %s frame-filters:" % cp.filename, cp.frame_filters, True
+ "progspace %s frame-filters:" % cp_filename, cp.frame_filters, True
)
for objfile in gdb.objfiles():
any_printed += self.print_list(
- "objfile %s frame-filters:" % objfile.filename,
+ "objfile %s frame-filters:" % file_style.apply(objfile.filename),
objfile.frame_filters,
False,
)
def invoke(self, arg, from_tty):
locus_re, name_re = parse_missing_file_command_args(arg)
+ file_style = gdb.Style("filename")
if locus_re.match("progspace") and locus_re.pattern != "":
cp = gdb.current_progspace()
+ cp_filename = cp.filename
+ if cp.filename is None:
+ cp_filename = "<no-file>"
+ else:
+ cp_filename = file_style.apply(cp_filename)
self.list_handlers(
- "Progspace %s:" % cp.filename, cp.missing_file_handlers, name_re
+ "Progspace %s:" % cp_filename, cp.missing_file_handlers, name_re
)
for progspace in gdb.progspaces():
else:
msg = "Progspace <no-file>:"
else:
- msg = "Progspace %s:" % filename
+ msg = "Progspace %s:" % file_style.apply(filename)
self.list_handlers(
msg,
progspace.missing_file_handlers,
name_re,
subname_re,
)
+ file_style = gdb.Style("filename")
cp = gdb.current_progspace()
+ cp_filename = cp.filename
+ if cp_filename is None:
+ cp_filename = "<no-file>"
+ else:
+ cp_filename = file_style.apply(cp_filename)
self.invoke1(
- "progspace %s pretty-printers:" % cp.filename,
+ "progspace %s pretty-printers:" % cp_filename,
cp.pretty_printers,
"progspace",
object_re,
)
for objfile in gdb.objfiles():
self.invoke1(
- "objfile %s pretty-printers:" % objfile.filename,
+ "objfile %s pretty-printers:" % file_style.apply(objfile.filename),
objfile.pretty_printers,
objfile.filename,
object_re,
A dict of matching xmethod matchers. The keys of the dict are the
filenames of the loci the xmethod matchers belong to.
"""
+ file_style = gdb.Style("filename")
xm_dict = {}
for locus in loci:
if isinstance(locus, gdb.Progspace):
if not locus_re.match(locus.filename):
continue
locus_type = "objfile"
- locus_str = "%s %s" % (locus_type, locus.filename)
+ filename = locus.filename
+ if filename is None:
+ filename = "<no-file>"
+ else:
+ filename = file_style.apply(filename)
+ locus_str = "%s %s" % (locus_type, filename)
xm_dict[locus_str] = [m for m in locus.xmethods if matcher_re.match(m.name)]
return xm_dict
# Now print the dictionary of registered disassemblers out to
# the user.
match_tag = "\t(Matches current architecture)"
- fmt_len = max(longest_arch_name, len("Architecture"))
- format_string = "{:" + str(fmt_len) + "s} {:s}"
- print(format_string.format("Architecture", "Disassember Name"))
+ arch_title = "Architecture"
+ fmt_len = max(longest_arch_name, len(arch_title))
+ format_string = "{:" + str(fmt_len) + "s} {:s}"
+ padding_string = " " * (fmt_len - len(arch_title))
+ title_style = gdb.Style("title")
+ # We cannot use FORMAT_STRING to layout the title line, as
+ # Python is unable to calculate the length of a styled string.
+ # Instead use PADDING_STRING to manually layout the columns.
+ print(
+ "{:s}{:s} {:s}".format(
+ title_style.apply(arch_title),
+ padding_string,
+ title_style.apply("Disassember Name"),
+ )
+ )
for architecture in _disassemblers_dict:
if architecture is not None:
name = _disassemblers_dict[architecture].name