Skip to content

Commit 3bdf157

Browse files
committed
enhance debugging output on pddb analyzer
1 parent 779cc61 commit 3bdf157

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tools/pddbcommon.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ def __init__(self, index, v2p, disk, key, name, dna=DNA):
277277
dict_header_vaddr = self.DICT_VSTRIDE * (index + 1)
278278
self.index = index
279279
self.vaddr = dict_header_vaddr
280+
self.num_keys = 0
280281
if dict_header_vaddr in v2p:
281282
self.valid = True
282283
pp = v2p[dict_header_vaddr]
@@ -302,7 +303,11 @@ def __init__(self, index, v2p, disk, key, name, dna=DNA):
302303
logging.info("decrypt dict '{}' with {} keys and {} free_key_index".format(self.name, self.num_keys, self.free_key_index))
303304
logging.debug("dict header len: {}".format(i-4)) # subtract 4 because of the journal
304305
except ValueError:
305-
logging.error("basisdicts: couldn't decrypt vpage @ {:x} ppage @ {:x}".format(dict_header_vaddr, v2p[dict_header_vaddr]))
306+
logging.error("\n") # make some whitespace so this stands out in the logs
307+
logging.error("**** basisdicts: encountered an invalid dict root record. Data loss may have occurred!")
308+
logging.error("**** couldn't decrypt vpage @ {:x} ppage @ {:x} in basis {}, dna {}".format(dict_header_vaddr, v2p[dict_header_vaddr], name, dna))
309+
logging.error("****** partial dump: {}\n".format(disk[pp:pp + 64].hex()))
310+
self.valid = False
306311

307312
if self.num_keys > 0:
308313
keys_found = 0
@@ -708,17 +713,23 @@ def decode_fscb(img, keys, FSCB_LEN_PAGES=2, dna=DNA):
708713
fscb_start = None
709714
pg = 0
710715
for page in pages:
716+
logging.debug("FSCB page {}: {}".format(pg, page[:40].hex()))
711717
if bytearray(page[:32]) == bytearray([0xff] * 32):
718+
logging.debug(" ...page is blank")
712719
# page is blank
713720
pass
714721
elif bytearray(page[:16]) == bytearray([0xff] * 16):
722+
logging.debug(" ...page is spaceupdate")
715723
space_update.append(page[16:])
716724
else:
717725
if fscb_start == None:
726+
logging.debug(" ...page is start of FSCB")
718727
fscb_start = pg
728+
else:
729+
logging.debug(" ...page is more FSCB data")
719730
pg += 1
720731

721-
if fscb_start:
732+
if fscb_start is not None:
722733
logging.debug("Found FSCB at {:x}".format(fscb_start))
723734
fscb_enc = img[fscb_start * 4096 : (fscb_start + FSCB_LEN_PAGES) * 4096]
724735
# print("data: {}".format(fscb_enc.hex()))

0 commit comments

Comments
 (0)