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.
This commit is contained in:
Christopher Haster
2025-04-05 18:44:33 -05:00
parent e5b430cb8c
commit 202636cccd
4 changed files with 16 additions and 16 deletions
+2 -2
View File
@@ -2771,9 +2771,9 @@ class Gstate:
def repr(self): def repr(self):
return 'grm %s' % ( return 'grm %s' % (
'none' if self.count == 0 '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 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 # keep track of known gstate
_known = [g for g in Gstate.__subclasses__() if g.tag is not None] _known = [g for g in Gstate.__subclasses__() if g.tag is not None]
+2 -2
View File
@@ -1803,10 +1803,10 @@ def main(disk, roots=None, *,
# corrupted? try to keep printing the tree # corrupted? try to keep printing the tree
if not rbyd: if not rbyd:
if not quiet: 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, rbyd.block, rbyd.trunk,
t_width, '', t_width, '',
'\x1b[31m' if color else '',
'(corrupted rbyd %s)' % rbyd.addr(), '(corrupted rbyd %s)' % rbyd.addr(),
'\x1b[m' if color else '')) '\x1b[m' if color else ''))
prbyd = None prbyd = None
+6 -6
View File
@@ -2702,9 +2702,9 @@ class Gstate:
def repr(self): def repr(self):
return 'grm %s' % ( return 'grm %s' % (
'none' if self.count == 0 '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 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 # keep track of known gstate
_known = [g for g in Gstate.__subclasses__() if g.tag is not None] _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 bid, rbyd = data
# corrupted? try to keep printing the tree # corrupted? try to keep printing the tree
if not rbyd: 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), '%04x.%04x' % (rbyd.block, rbyd.trunk),
2*w_width+1, '', 2*w_width+1, '',
bt_width, '', bt_width, '',
'\x1b[31m' if color else '',
'(corrupted rbyd %s)' % rbyd.addr(), '(corrupted rbyd %s)' % rbyd.addr(),
'\x1b[m' if color else '')) '\x1b[m' if color else ''))
pmdir = None pmdir = None
@@ -4466,14 +4466,14 @@ def dbg_ck(lfs, *,
or (data and isinstance(child, Bptr))) or (data and isinstance(child, Bptr)))
and not child): and not child):
if not quiet: if not quiet:
print('%11s: %s%s%s' % ( print('%s%11s: %s%s' % (
'\x1b[31m' if color else '',
'{%s}' % ','.join('%04x' % block '{%s}' % ','.join('%04x' % block
for block in child.blocks) for block in child.blocks)
if isinstance(child, Mdir) if isinstance(child, Mdir)
else '%04x.%04x' % (child.block, child.trunk) else '%04x.%04x' % (child.block, child.trunk)
if isinstance(child, Rbyd) if isinstance(child, Rbyd)
else '%04x.%04x' % (child.block, child.off), else '%04x.%04x' % (child.block, child.off),
'\x1b[31m' if color else '',
'(corrupted %s %s)' % ( '(corrupted %s %s)' % (
'mroot' if isinstance(child, Mdir) 'mroot' if isinstance(child, Mdir)
and child.mid == -1 and child.mid == -1
+6 -6
View File
@@ -2992,10 +2992,10 @@ def main(disk, mroots=None, *,
# corrupted? # corrupted?
if not mdir: if not mdir:
if not quiet: if not quiet:
print('{%s}: %s%s%s' % ( print('%s{%s}: %s%s' % (
'\x1b[31m' if color else '',
','.join('%04x' % block ','.join('%04x' % block
for block in mdir.blocks), for block in mdir.blocks),
'\x1b[31m' if color else '',
'(corrupted %s %s)' % ( '(corrupted %s %s)' % (
'mroot' if mdir.mid == -1 else 'mdir', 'mroot' if mdir.mid == -1 else 'mdir',
mdir.addr()), mdir.addr()),
@@ -3008,10 +3008,10 @@ def main(disk, mroots=None, *,
if mdir.mid == -1: if mdir.mid == -1:
if mdir in mrootseen: if mdir in mrootseen:
if not quiet: if not quiet:
print('{%s}: %s%s%s' % ( print('%s{%s}: %s%s' % (
'\x1b[31m' if color else '',
','.join('%04x' % block ','.join('%04x' % block
for block in mdir.blocks), for block in mdir.blocks),
'\x1b[31m' if color else '',
'(mroot cycle detected %s)' % mdir.addr(), '(mroot cycle detected %s)' % mdir.addr(),
'\x1b[m' if color else '')) '\x1b[m' if color else ''))
pmdir = None pmdir = None
@@ -3029,10 +3029,10 @@ def main(disk, mroots=None, *,
# corrupted? try to keep printing the tree # corrupted? try to keep printing the tree
if not rbyd: if not rbyd:
if not quiet: 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), '%04x.%04x' % (rbyd.block, rbyd.trunk),
t_width, '', t_width, '',
'\x1b[31m' if color else '',
'(corrupted rbyd %s)' % rbyd.addr(), '(corrupted rbyd %s)' % rbyd.addr(),
'\x1b[m' if color else '')) '\x1b[m' if color else ''))
pmdir = None pmdir = None