From 202636cccd05b701d919e2e530d6b49bd33a30f8 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sat, 5 Apr 2025 18:44:33 -0500 Subject: [PATCH] scripts: Tweaked corrupt rbyd coloring to include addresses This matches the coloring in dbglfs.py for other erroneous conditions, and also matches how we color hidden items when shown. Also fixed some minor bugs in grm printing. --- scripts/dbgbmapd3.py | 4 ++-- scripts/dbgbtree.py | 4 ++-- scripts/dbglfs.py | 12 ++++++------ scripts/dbgmtree.py | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/dbgbmapd3.py b/scripts/dbgbmapd3.py index 7156a431..672f4b13 100755 --- a/scripts/dbgbmapd3.py +++ b/scripts/dbgbmapd3.py @@ -2771,9 +2771,9 @@ class Gstate: def repr(self): return 'grm %s' % ( 'none' if self.count == 0 - else ' '.join(str(mid) for mid in self.rms) + else ' '.join(mid.repr() for mid in self.rms) if self.count <= 2 - else '0x%x %d' % (count, len(data))) + else '0x%x %d' % (self.count, len(self.data))) # keep track of known gstate _known = [g for g in Gstate.__subclasses__() if g.tag is not None] diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index 6e2df604..101f8242 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -1803,10 +1803,10 @@ def main(disk, roots=None, *, # corrupted? try to keep printing the tree if not rbyd: if not quiet: - print('%04x.%04x: %*s%s%s%s' % ( + print('%s%04x.%04x: %*s%s%s' % ( + '\x1b[31m' if color else '', rbyd.block, rbyd.trunk, t_width, '', - '\x1b[31m' if color else '', '(corrupted rbyd %s)' % rbyd.addr(), '\x1b[m' if color else '')) prbyd = None diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index 1acb3ad1..309b1862 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -2702,9 +2702,9 @@ class Gstate: def repr(self): return 'grm %s' % ( 'none' if self.count == 0 - else ' '.join(str(mid) for mid in self.rms) + else ' '.join(mid.repr() for mid in self.rms) if self.count <= 2 - else '0x%x %d' % (count, len(data))) + else '0x%x %d' % (self.count, len(self.data))) # keep track of known gstate _known = [g for g in Gstate.__subclasses__() if g.tag is not None] @@ -4430,11 +4430,11 @@ def dbg_files(lfs, paths, *, bid, rbyd = data # corrupted? try to keep printing the tree if not rbyd: - print('%11s: %*s %*s%s%s%s' % ( + print('%s%11s: %*s %*s%s%s' % ( + '\x1b[31m' if color else '', '%04x.%04x' % (rbyd.block, rbyd.trunk), 2*w_width+1, '', bt_width, '', - '\x1b[31m' if color else '', '(corrupted rbyd %s)' % rbyd.addr(), '\x1b[m' if color else '')) pmdir = None @@ -4466,14 +4466,14 @@ def dbg_ck(lfs, *, or (data and isinstance(child, Bptr))) and not child): if not quiet: - print('%11s: %s%s%s' % ( + print('%s%11s: %s%s' % ( + '\x1b[31m' if color else '', '{%s}' % ','.join('%04x' % block for block in child.blocks) if isinstance(child, Mdir) else '%04x.%04x' % (child.block, child.trunk) if isinstance(child, Rbyd) else '%04x.%04x' % (child.block, child.off), - '\x1b[31m' if color else '', '(corrupted %s %s)' % ( 'mroot' if isinstance(child, Mdir) and child.mid == -1 diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index a6ea902e..524afb0f 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -2992,10 +2992,10 @@ def main(disk, mroots=None, *, # corrupted? if not mdir: if not quiet: - print('{%s}: %s%s%s' % ( + print('%s{%s}: %s%s' % ( + '\x1b[31m' if color else '', ','.join('%04x' % block for block in mdir.blocks), - '\x1b[31m' if color else '', '(corrupted %s %s)' % ( 'mroot' if mdir.mid == -1 else 'mdir', mdir.addr()), @@ -3008,10 +3008,10 @@ def main(disk, mroots=None, *, if mdir.mid == -1: if mdir in mrootseen: if not quiet: - print('{%s}: %s%s%s' % ( + print('%s{%s}: %s%s' % ( + '\x1b[31m' if color else '', ','.join('%04x' % block for block in mdir.blocks), - '\x1b[31m' if color else '', '(mroot cycle detected %s)' % mdir.addr(), '\x1b[m' if color else '')) pmdir = None @@ -3029,10 +3029,10 @@ def main(disk, mroots=None, *, # corrupted? try to keep printing the tree if not rbyd: if not quiet: - print('%11s: %*s%s%s%s' % ( + print('%s%11s: %*s%s%s' % ( + '\x1b[31m' if color else '', '%04x.%04x' % (rbyd.block, rbyd.trunk), t_width, '', - '\x1b[31m' if color else '', '(corrupted rbyd %s)' % rbyd.addr(), '\x1b[m' if color else '')) pmdir = None