diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index 0dd356c3..ac253e92 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -845,7 +845,7 @@ def main(disk, roots=None, *, # dynamically size the id field - w_width = 2*m.ceil(m.log10(max(1, btree.weight)+1))+1 + w_width = m.ceil(m.log10(max(1, btree.weight)+1)) # prbyd here means the last rendered rbyd, we update # in dbg_branch to always print interleaved addresses @@ -855,32 +855,30 @@ def main(disk, roots=None, *, # show human-readable representation for i, (tag, j, d, data) in enumerate(tags): - print('%10s %s%*s %-22s %s' % ( + print('%10s %s%*s %-*s %s' % ( '%04x.%04x:' % (rbyd.block, rbyd.trunk) if prbyd is None or rbyd != prbyd else '', treerepr(bid, w, bd, rid, tag) if args.get('tree') or args.get('btree') else '', - w_width, '' if i != 0 + 2*w_width+1, '' if i != 0 else '%d-%d' % (bid-(w-1), bid) if w > 1 else bid if w > 0 else '', - tagrepr(tag, w if i == 0 else 0, len(data), None), - next(xxd(data, 8), '') if not args.get('no_truncate') + 21+w_width, tagrepr( + tag, w if i == 0 else 0, len(data), None), + next(xxd(data, 8), '') + if not args.get('raw') and not args.get('no_truncate') else '')) prbyd = rbyd # show in-device representation if args.get('device'): - print('%9s %*s%*s %-22s%s' % ( + print('%9s %*s%*s %04x %08x %07x' % ( '', t_width, '', - w_width, '', - '%04x %08x %07x' % (tag, w if i == 0 else 0, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - rbyd.data[j+d+i*4 : j+d + min(i*4+4,len(data))]) - for i in range(min(m.ceil(len(data)/4), 3)))[:23])) + 2*w_width+1, '', + tag, w if i == 0 else 0, len(data))) # show on-disk encoding of tags/data if args.get('raw'): @@ -888,14 +886,14 @@ def main(disk, roots=None, *, print('%9s: %*s%*s %s' % ( '%04x' % (j + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): print('%9s: %*s%*s %s' % ( '%04x' % (j+d + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index 885ceeb0..c94545b2 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -1345,8 +1345,7 @@ def dbg_fstruct(f, block_size, btree, inlined=False, *, # dynamically size the id field - w_width = 0 if inlined else 2*m.ceil(m.log10(max(1, btree.weight)+1))+1 - i_width = 0 if inlined else 1 + w_width = m.ceil(m.log10(max(1, btree.weight)+1)) # prbyd here means the last rendered rbyd, we update # in dbg_branch to always print interleaved addresses @@ -1356,55 +1355,48 @@ def dbg_fstruct(f, block_size, btree, inlined=False, *, # show human-readable representation for i, (tag, j, d, data) in enumerate(tags): - print('%12s %*s %s%*s%*s%-22s %s' % ( + print('%12s %*s %s%s%-*s %s' % ( '%04x.%04x:' % (rbyd.block, rbyd.trunk) if prbyd is None or rbyd != prbyd else '', m_width, '', treerepr(bid, w, bd, rid, tag, False) if args.get('tree') or args.get('btree') else '', - w_width, '' if i != 0 + '%*s ' % (2*w_width+1, '' if i != 0 else '%d-%d' % (bid-(w-1), bid) if w > 1 else bid if w > 0 - else '', - i_width, '', - tagrepr(tag, w if i == 0 else 0, len(data), None), - next(xxd(data, 8), '') if not args.get('no_truncate') + else '') if not inlined else '', + 21+w_width, tagrepr(tag, w if i == 0 else 0, len(data), None), + next(xxd(data, 8), '') + if not args.get('raw') and not args.get('no_truncate') else '')) prbyd = rbyd # show in-device representation if args.get('device'): - print('%11s %*s %*s%*s%*s%-22s%s' % ( + print('%11s %*s %*s%s%04x %08x %07x' % ( '', m_width, '', t_width, '', - w_width, '', - i_width, '', - '%04x %08x %07x' % (tag, w if i == 0 else 0, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - rbyd.data[j+d+i*4 : j+d + min(i*4+4,len(data))]) - for i in range(min(m.ceil(len(data)/4), 3)))[:23])) + '%*s ' % (2*w_width+1, '') if not inlined else '', + tag, w if i == 0 else 0, len(data))) # show on-disk encoding of tags/data if args.get('raw'): for o, line in enumerate(xxd(rbyd.data[j:j+d])): - print('%11s: %*s %*s%*s%*s%s' % ( + print('%11s: %*s %*s%s%s' % ( '%04x' % (j + o*16), m_width, '', t_width, '', - w_width, '', - i_width, '', + '%*s ' % (2*w_width+1, '') if not inlined else '', line)) if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): - print('%11s: %*s %*s%*s%*s%s' % ( + print('%11s: %*s %*s%s%s' % ( '%04x' % (j+d + o*16), m_width, '', t_width, '', - w_width, '', - i_width, '', + '%*s ' % (2*w_width+1, '') if not inlined else '', line)) def dbg_block(bid, w, rbyd, rid, bptr, block, off, size, data, bd): @@ -1412,69 +1404,61 @@ def dbg_fstruct(f, block_size, btree, inlined=False, *, tag, _, _, _ = bptr # show human-readable representation - print('%12s %*s %s%*s%*s%-22s %s' % ( + print('%12s %*s %s%s%-*s %s' % ( '%04x.%04x:' % (rbyd.block, rbyd.trunk) if prbyd is None or rbyd != prbyd else '', m_width, '', treerepr(bid, w, bd, rid, tag, True) if args.get('tree') or args.get('btree') else '', - w_width, '%d-%d' % (bid-(w-1), bid) if w > 1 + '%*s ' % (2*w_width+1, '%d-%d' % (bid-(w-1), bid) if w > 1 else bid if w > 0 - else '', - i_width, '', - 'block%s 0x%x.%x %d' % ( + else '') if not inlined else '', + 21+w_width, 'block%s 0x%x.%x %d' % ( ' w%d' % w if w else '', block, off, size), - next(xxd(data, 8), '') if not args.get('no_truncate') + next(xxd(data, 8), '') + if not args.get('raw') and not args.get('no_truncate') else '')) prbyd = rbyd # show in-device representation if args.get('device'): _, j, d, data_ = bptr - print('%11s %*s %*s%*s%*s%-22s%s' % ( + print('%11s %*s %*s%s%04x %08x %07x' % ( '', m_width, '', t_width, '', - w_width, '', - i_width, '', - '%04x %08x %07x' % (tag, w, len(data_)), - ' %s' % ' '.join( - '%08x' % fromle32( - rbyd.data[j+d+i*4 : j+d + min(i*4+4,len(data_))]) - for i in range(min(m.ceil(len(data_)/4), 3)))[:23])) + '%*s ' % (2*w_width+1, '') if not inlined else '', + tag, w, len(data_))) # show on-disk encoding of tags/bptr/data if args.get('raw'): _, j, d, data_ = bptr for o, line in enumerate(xxd(rbyd.data[j:j+d])): - print('%11s: %*s %*s%*s%*s%s' % ( + print('%11s: %*s %*s%s%s' % ( '%04x' % (j + o*16), m_width, '', t_width, '', - w_width, '', - i_width, '', + '%*s ' % (2*w_width+1, '') if not inlined else '', line)) if args.get('raw'): _, j, d, data_ = bptr for o, line in enumerate(xxd(data_)): - print('%11s: %*s %*s%*s%*s%s' % ( + print('%11s: %*s %*s%s%s' % ( '%04x' % (j+d + o*16), m_width, '', t_width, '', - w_width, '', - i_width, '', + '%*s ' % (2*w_width+1, '') if not inlined else '', line)) if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): - print('%11s: %*s %*s%*s%*s%s' % ( + print('%11s: %*s %*s%s%s' % ( '%04x.%04x' % (block, off + o*16) if o == 0 else '%04x' % (off + o*16), m_width, '', t_width, '', - w_width, '', - i_width, '', + '%*s ' % (2*w_width+1, '') if not inlined else '', line)) # if we show non-truncated file contents we need to # reset the rbyd address @@ -1782,40 +1766,35 @@ def main(disk, mroots=None, *, mroot.addr(), mroot.rev, bweight//mleaf_weight, 1*mleaf_weight)) # dynamically size the id field - w_width = (m.ceil(m.log10(max(1, bweight//mleaf_weight)+1)) - + 2*m.ceil(m.log10(max(1, rweight)+1)) - + 2) + w_width = max( + m.ceil(m.log10(max(1, bweight//mleaf_weight)+1)), + m.ceil(m.log10(max(1, rweight)+1)), + # in case of -1.-1 + 2) # print config? if args.get('config'): for i, (repr_, tag, j, data) in enumerate(config.repr()): print('%12s %-*s %s' % ( 'config:' if i == 0 else '', - w_width + 23, repr_, + 2*w_width+1 + 21+w_width + 1, repr_, next(xxd(data, 8), '') - if not args.get('no_truncate') else '')) + if not args.get('raw') + and not args.get('no_truncate') else '')) # show in-device representation if args.get('device'): - print('%11s %*s %s' % ( + print('%11s %*s %04x %08x %07x' % ( '', - w_width, '', - '%-22s%s' % ( - '%04x %08x %07x' % (tag, 0, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - data[i*4 : min(i*4+4,len(data))]) - for i in range( - min(m.ceil(len(data)/4), - 3)))[:23] - if not args.get('no_truncate') else ''))) + 2*w_width+1, '', + tag, 0, len(data))) # show on-disk encoding if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): print('%11s: %*s %s' % ( '%04x' % (j + o*16), - w_width, '', + 2*w_width+1, '', line)) # print gstate? @@ -1823,76 +1802,53 @@ def main(disk, mroots=None, *, for i, (repr_, tag, data) in enumerate(gstate.repr()): print('%12s %-*s %s' % ( 'gstate:' if i == 0 else '', - w_width + 23, repr_, + 2*w_width+1 + 21+w_width + 1, repr_, next(xxd(data, 8), '') - if not args.get('no_truncate') else '')) - - # show in-device representation - if args.get('device'): - print('%11s %*s %s' % ( - '', - w_width, '', - '%-22s%s' % ( - '', - ' %s' % ' '.join( - '%08x' % fromle32( - data[i*4 : min(i*4+4,len(data))]) - for i in range( - min(m.ceil(len(data)/4), - 3)))[:23] - if not args.get('no_truncate') else ''))) + if not args.get('raw') + and not args.get('no_truncate') else '')) # show on-disk encoding if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): print('%11s: %*s %s' % ( '%04x' % (o*16), - w_width, '', + 2*w_width+1, '', line)) # print gdeltas? if args.get('gdelta'): for mbid, mw, mdir, j, d, data in gstate.gdelta[tag]: - print('%s{%s}: %*s %-22s %s%s' % ( + print('%s{%s}: %*s %-*s %s%s' % ( '\x1b[90m' if color else '', ','.join('%04x' % block for block in it.chain([mdir.block], mdir.redund_blocks)), - w_width, mbid//mleaf_weight, - tagrepr(tag, 0, len(data)), + 2*w_width+1, mbid//mleaf_weight, + 21+w_width, tagrepr(tag, 0, len(data)), next(xxd(data, 8), '') - if not args.get('no_truncate') else '', + if not args.get('raw') + and not args.get('no_truncate') else '', '\x1b[m' if color else '')) # show in-device representation if args.get('device'): - print('%11s %*s %s' % ( + print('%11s %*s %04x %08x %07x' % ( '', - w_width, '', - '%-22s%s' % ( - '%04x %08x %07x' % (tag, 0, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - data[i*4 - : min(i*4+4,len(data))]) - for i in range( - min(m.ceil(len(data)/4), - 3)))[:23] - if not args.get('no_truncate') - else ''))) + 2*w_width+1, '', + tag, 0, len(data))) # show on-disk encoding if args.get('raw'): for o, line in enumerate(xxd(mdir.data[j:j+d])): print('%11s: %*s %s' % ( '%04x' % (j + o*16), - w_width, '', + 2*w_width+1, '', line)) if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): print('%11s: %*s %s' % ( '%04x' % (j+d + o*16), - w_width, '', + 2*w_width+1, '', line)) # print dtree? @@ -1960,7 +1916,7 @@ def main(disk, mroots=None, *, for block in it.chain([mdir.block], mdir.redund_blocks)) if mbid != pmbid else '', - w_width, '%d.%d-%d' % ( + 2*w_width+1, '%d.%d-%d' % ( mbid//mleaf_weight, rid-(w-1), rid) if w > 1 else '%d.%d' % (mbid//mleaf_weight, rid) if w > 0 else '', @@ -1986,43 +1942,34 @@ def main(disk, mroots=None, *, if done or rid_ != rid: break - print('%12s %*s %-22s %s' % ( + print('%12s %*s %-*s %s' % ( '', - w_width, '', - tagrepr(tag_, w_, len(data)), + 2*w_width+1, '', + 21+w_width, tagrepr(tag_, w_, len(data)), next(xxd(data, 8), '') - if not args.get('no_truncate') else '')) + if not args.get('raw') + and not args.get('no_truncate') + else '')) # show in-device representation if args.get('device'): - print('%11s %*s %s' % ( + print('%11s %*s %04x %08x %07x' % ( '', - w_width, '', - '%-22s%s' % ( - '%04x %08x %07x' % ( - tag_, w_, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - data[i*4 - : min(i*4+4,len(data))]) - for i in range( - min(m.ceil(len(data)/4), - 3)))[:23] - if not args.get('no_truncate') - else ''))) + 2*w_width+1, '', + tag_, w_, len(data))) # show on-disk encoding if args.get('raw'): for o, line in enumerate(xxd(mdir.data[j:j+d])): print('%11s: %*s %s' % ( '%04x' % (j + o*16), - w_width, '', + 2*w_width+1, '', line)) if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): print('%11s: %*s %s' % ( '%04x' % (j+d + o*16), - w_width, '', + 2*w_width+1, '', line)) # print file contents? @@ -2042,7 +1989,7 @@ def main(disk, mroots=None, *, j, 0), inlined=True, - m_width=w_width, + m_width=2*w_width+1, color=color, args=args) @@ -2055,7 +2002,7 @@ def main(disk, mroots=None, *, weight, d_ = fromleb128(data[d:]); d += d_ dbg_fstruct(f, block_size, Rbyd.fetch(f, block_size, mdir.block, trunk), - m_width=w_width, + m_width=2*w_width+1, color=color, args=args) @@ -2074,7 +2021,7 @@ def main(disk, mroots=None, *, j, 0), inlined=True, - m_width=w_width, + m_width=2*w_width+1, color=color, args=args) @@ -2089,7 +2036,7 @@ def main(disk, mroots=None, *, cksum = fromle32(data[d:]); d += 4 dbg_fstruct(f, block_size, Rbyd.fetch(f, block_size, block, trunk), - m_width=w_width, + m_width=2*w_width+1, color=color, args=args) diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index ca9bd2aa..321c11f4 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -1337,39 +1337,31 @@ def main(disk, mroots=None, *, def dbg_mdir(mdir, mbid, mw, md): for i, (rid, tag, w, j, d, data) in enumerate(mdir): # show human-readable tag representation - print('%12s %s%-57s' % ( + print('%12s %s%s' % ( '{%s}:' % ','.join('%04x' % block for block in it.chain([mdir.block], mdir.redund_blocks)) if i == 0 else '', treerepr(mbid-max(mw-1, 0), 0, md, 0, rid, tag) if args.get('tree') or args.get('btree') else '', - '%*s %-22s%s' % ( - w_width, '%d.%d-%d' % ( + '%*s %-*s%s' % ( + 2*w_width+1, '%d.%d-%d' % ( mbid//mleaf_weight, rid-(w-1), rid) if w > 1 else '%d.%d' % (mbid//mleaf_weight, rid) if w > 0 or i == 0 else '', - tagrepr(tag, w, len(data), j), + 21+w_width, tagrepr(tag, w, len(data), j), ' %s' % next(xxd(data, 8), '') - if not args.get('no_truncate') else ''))) + if not args.get('raw') + and not args.get('no_truncate') + else ''))) # show in-device representation if args.get('device'): - print('%11s %*s%*s %s' % ( + print('%11s %*s%*s %04x %08x %07x' % ( '', t_width, '', - w_width, '', - '%-22s%s' % ( - '%04x %08x %07x' % (tag, w, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - mdir.data[j+d+i*4 - : j+d+min(i*4+4,len(data))]) - for i in range( - min(m.ceil(len(data)/4), - 3)))[:23] - if not args.get('no_truncate') - and not tag & TAG_ALT else ''))) + 2*w_width+1, '', + tag, w, len(data))); # show on-disk encoding of tags if args.get('raw'): @@ -1377,7 +1369,7 @@ def main(disk, mroots=None, *, print('%11s: %*s%*s %s' % ( '%04x' % (j + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) if args.get('raw') or args.get('no_truncate'): if not tag & TAG_ALT: @@ -1385,7 +1377,7 @@ def main(disk, mroots=None, *, print('%11s: %*s%*s %s' % ( '%04x' % (j+d + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) # prbyd here means the last rendered rbyd, we update @@ -1396,36 +1388,33 @@ def main(disk, mroots=None, *, # show human-readable representation for i, (tag, j, d, data) in enumerate(tags): - print('%12s %s%*s %-22s %s' % ( + print('%12s %s%*s %-*s %s' % ( '%04x.%04x:' % (rbyd.block, rbyd.trunk) if prbyd is None or rbyd != prbyd else '', treerepr(bid, w, bd, rid, 0, tag) if args.get('tree') or args.get('btree') else '', - w_width, '' if i != 0 + 2*w_width+1, '' if i != 0 else '%d-%d' % ( (bid-(w-1))//mleaf_weight, bid//mleaf_weight) if (w//mleaf_weight) > 1 else bid//mleaf_weight if w > 0 else '', - tagrepr(tag, w if i == 0 else 0, len(data), None), - # note we render names a bit different here - next(xxd(data, 8), '') if not args.get('no_truncate') + 21+w_width, tagrepr( + tag, w if i == 0 else 0, len(data), None), + next(xxd(data, 8), '') + if not args.get('raw') and not args.get('no_truncate') else '')) prbyd = rbyd # show in-device representation if args.get('device'): - print('%11s %*s%*s %-22s%s' % ( + print('%11s %*s%*s %04x %08x %07x' % ( '', t_width, '', - w_width, '', - '%04x %08x %07x' % (tag, w if i == 0 else 0, len(data)), - ' %s' % ' '.join( - '%08x' % fromle32( - rbyd.data[j+d+i*4 : j+d + min(i*4+4,len(data))]) - for i in range(min(m.ceil(len(data)/4), 3)))[:23])) + 2*w_width+1, '', + tag, w if i == 0 else 0, len(data))); # show on-disk encoding of tags/data if args.get('raw'): @@ -1433,14 +1422,14 @@ def main(disk, mroots=None, *, print('%11s: %*s%*s %s' % ( '%04x' % (j + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) if args.get('raw') or args.get('no_truncate'): for o, line in enumerate(xxd(data)): print('%11s: %*s%*s %s' % ( '%04x' % (j+d + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) @@ -1451,9 +1440,11 @@ def main(disk, mroots=None, *, mroot.addr(), mroot.rev, bweight//mleaf_weight, 1*mleaf_weight)) # dynamically size the id field - w_width = (m.ceil(m.log10(max(1, bweight//mleaf_weight)+1)) - + 2*m.ceil(m.log10(max(1, rweight)+1)) - + 2) + w_width = max( + m.ceil(m.log10(max(1, bweight//mleaf_weight)+1)), + m.ceil(m.log10(max(1, rweight)+1)), + # in case of -1.-1 + 2) # show each mroot prbyd = None diff --git a/scripts/dbgrbyd.py b/scripts/dbgrbyd.py index b9478541..cdb103ee 100755 --- a/scripts/dbgrbyd.py +++ b/scripts/dbgrbyd.py @@ -478,14 +478,14 @@ def dbg_log(data, block_size, rev, eoff, weight, *, # found new weight? weight_ = max(weight_, weight__) - w_width = 2*m.ceil(m.log10(max(1, weight_)+1))+1 + w_width = m.ceil(m.log10(max(1, weight_)+1)) # print revision count if args.get('raw'): print('%8s: %*s%*s %s' % ( '%04x' % 0, lifetime_width, '', - w_width, '', + 2*w_width+1, '', next(xxd(data[0:4])))) # print tags @@ -530,20 +530,20 @@ def dbg_log(data, block_size, rev, eoff, weight, *, rid = lower_ + w-1 # show human-readable tag representation - print('%s%08x:%s %*s%s%*s %-57s%s%s' % ( + print('%s%08x:%s %*s%s%*s %-*s%s%s' % ( '\x1b[90m' if color and j >= eoff else '', j, '\x1b[m' if color and j >= eoff else '', lifetime_width, lifetimerepr(j) if args.get('lifetimes') else '', '\x1b[90m' if color and j >= eoff else '', - w_width, '' if (tag & 0xe000) != 0x0000 + 2*w_width+1, '' if (tag & 0xe000) != 0x0000 else '%d-%d' % (rid-(w-1), rid) if w > 1 else rid, - '%-22s%s' % ( - tagrepr(tag, w, size, j), + 56+w_width, '%-*s%s' % ( + 21+w_width, tagrepr(tag, w, size, j), ' %s' % next(xxd( data[j+d:j+d+min(size, 8)], 8), '') - if not args.get('no_truncate') + if not args.get('raw') and not args.get('no_truncate') and not tag & TAG_ALT else ''), '\x1b[m' if color and j >= eoff else '', ' (%s)' % ', '.join(notes) if notes @@ -554,19 +554,12 @@ def dbg_log(data, block_size, rev, eoff, weight, *, # show in-device representation, including some extra # cksum/parity info if args.get('device'): - print('%s%8s %*s%*s %-47s %08x %x%s' % ( + print('%s%8s %*s%*s %-*s %08x %x%s' % ( '\x1b[90m' if color and j >= eoff else '', '', lifetime_width, '', - w_width, '', - '%-22s%s' % ( - '%04x %08x %07x' % (tag, w, size), - ' %s' % ' '.join( - '%08x' % fromle32( - data[j+d+i*4:j+d+min(i*4+4,size)]) - for i in range(min(m.ceil(size/4), 3)))[:23] - if not args.get('no_truncate') - and not tag & TAG_ALT else ''), + 2*w_width+1, '', + 21+w_width, '%04x %08x %07x' % (tag, w, size), cksum, popc(cksum) & 1, '\x1b[m' if color and j >= eoff else '')) @@ -578,7 +571,7 @@ def dbg_log(data, block_size, rev, eoff, weight, *, '\x1b[90m' if color and j >= eoff else '', '%04x' % (j + o*16), lifetime_width, '', - w_width, '', + 2*w_width+1, '', line, '\x1b[m' if color and j >= eoff else '')) if args.get('raw') or args.get('no_truncate'): @@ -588,7 +581,7 @@ def dbg_log(data, block_size, rev, eoff, weight, *, '\x1b[90m' if color and j >= eoff else '', '%04x' % (j+d + o*16), lifetime_width, '', - w_width, '', + 2*w_width+1, '', line, '\x1b[m' if color and j >= eoff else '')) @@ -800,7 +793,7 @@ def dbg_tree(data, block_size, rev, trunk, weight, *, # dynamically size the id field - w_width = 2*m.ceil(m.log10(max(1, weight)+1))+1 + w_width = m.ceil(m.log10(max(1, weight)+1)) rid, tag = -1, 0 for i in it.count(): @@ -810,33 +803,26 @@ def dbg_tree(data, block_size, rev, trunk, weight, *, break # show human-readable tag representation - print('%08x: %s%-57s' % ( + print('%08x: %s%s' % ( j, treerepr(rid, tag) if args.get('tree') else '', - '%*s %-22s%s' % ( - w_width, '%d-%d' % (rid-(w-1), rid) + '%*s %-*s%s' % ( + 2*w_width+1, '%d-%d' % (rid-(w-1), rid) if w > 1 else rid if w > 0 or i == 0 else '', - tagrepr(tag, w, size, j), + 21+w_width, tagrepr(tag, w, size, j), ' %s' % next(xxd( data[j+d:j+d+min(size, 8)], 8), '') - if not args.get('no_truncate') + if not args.get('raw') and not args.get('no_truncate') and not tag & TAG_ALT else ''))) # show in-device representation if args.get('device'): - print('%8s %*s%*s %s' % ( + print('%8s %*s%*s %04x %08x %07x' % ( '', t_width, '', - w_width, '', - '%-22s%s' % ( - '%04x %08x %07x' % (tag, w, size), - ' %s' % ' '.join( - '%08x' % fromle32( - data[j+d+i*4:j+d+min(i*4+4,size)]) - for i in range(min(m.ceil(size/4), 3)))[:23] - if not args.get('no_truncate') - and not tag & TAG_ALT else ''))) + 2*w_width+1, '', + tag, w, size)) # show on-disk encoding of tags if args.get('raw'): @@ -844,7 +830,7 @@ def dbg_tree(data, block_size, rev, trunk, weight, *, print('%8s: %*s%*s %s' % ( '%04x' % (j + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line)) if args.get('raw') or args.get('no_truncate'): if not tag & TAG_ALT: @@ -852,7 +838,7 @@ def dbg_tree(data, block_size, rev, trunk, weight, *, print('%8s: %*s%*s %s' % ( '%04x' % (j+d + o*16), t_width, '', - w_width, '', + 2*w_width+1, '', line))