diff options
author | Christopher Haster <chaster@utexas.edu> | 2019-07-27 04:09:24 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2019-07-27 04:09:24 +0300 |
commit | 51fabc672b43a6285bced7e6574989cfc203ebd9 (patch) | |
tree | 5861f90e4df3a7ec43ceccb757b4f93cbec36152 | |
parent | 72e3bb44482e417d8a0408ecd16cb7ef96a6c2fc (diff) |
Switched to using hex for blocks and ids in debug output
This is a minor quality of life change to help debugging, specifically
when debugging test failures.
Before, the test framework used hex, while the log output used decimal.
This was slightly annoying to convert between.
Why not output lengths/offset in hex? I don't have a big reason. I find
it easier to reason about lengths in decimal and ids (such as addresses
or block numbers) in hex. But this may just be me.
-rw-r--r-- | emubd/lfs_emubd.c | 6 | ||||
-rw-r--r-- | lfs.c | 32 | ||||
-rwxr-xr-x | scripts/debug.py | 2 |
3 files changed, 20 insertions, 20 deletions
diff --git a/emubd/lfs_emubd.c b/emubd/lfs_emubd.c index 943ddfb..2f729fb 100644 --- a/emubd/lfs_emubd.c +++ b/emubd/lfs_emubd.c @@ -151,7 +151,7 @@ void lfs_emubd_destroy(const struct lfs_config *cfg) { int lfs_emubd_read(const struct lfs_config *cfg, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size) { - LFS_TRACE("lfs_emubd_read(%p, %"PRIu32", %"PRIu32", %p, %"PRIu32")", + LFS_TRACE("lfs_emubd_read(%p, 0x%"PRIx32", %"PRIu32", %p, %"PRIu32")", (void*)cfg, block, off, buffer, size); lfs_emubd_t *emu = cfg->context; uint8_t *data = buffer; @@ -204,7 +204,7 @@ int lfs_emubd_read(const struct lfs_config *cfg, lfs_block_t block, int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size) { - LFS_TRACE("lfs_emubd_prog(%p, %"PRIu32", %"PRIu32", %p, %"PRIu32")", + LFS_TRACE("lfs_emubd_prog(%p, 0x%"PRIx32", %"PRIu32", %p, %"PRIu32")", (void*)cfg, block, off, buffer, size); lfs_emubd_t *emu = cfg->context; const uint8_t *data = buffer; @@ -276,7 +276,7 @@ int lfs_emubd_prog(const struct lfs_config *cfg, lfs_block_t block, } int lfs_emubd_erase(const struct lfs_config *cfg, lfs_block_t block) { - LFS_TRACE("lfs_emubd_erase(%p, %"PRIu32")", (void*)cfg, block); + LFS_TRACE("lfs_emubd_erase(%p, 0x%"PRIx32")", (void*)cfg, block); lfs_emubd_t *emu = cfg->context; // Check if erase is valid @@ -971,7 +971,7 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs, dir->rev = revs[(r+1)%2]; } - LFS_ERROR("Corrupted dir pair at %"PRIu32" %"PRIu32, + LFS_ERROR("Corrupted dir pair at %"PRIx32" %"PRIx32, dir->pair[0], dir->pair[1]); return LFS_ERR_CORRUPT; } @@ -1607,12 +1607,12 @@ relocate: relocated = true; lfs_cache_drop(lfs, &lfs->pcache); if (!exhausted) { - LFS_DEBUG("Bad block at %"PRIu32, dir->pair[1]); + LFS_DEBUG("Bad block at %"PRIx32, dir->pair[1]); } // can't relocate superblock, filesystem is now frozen if (lfs_pair_cmp(oldpair, (const lfs_block_t[2]){0, 1}) == 0) { - LFS_WARN("Superblock %"PRIu32" has become unwritable", oldpair[1]); + LFS_WARN("Superblock %"PRIx32" has become unwritable", oldpair[1]); return LFS_ERR_NOSPC; } @@ -1630,7 +1630,7 @@ relocate: lfs->gdelta = (struct lfs_gstate){0}; } else { // update references if we relocated - LFS_DEBUG("Relocating %"PRIu32" %"PRIu32" to %"PRIu32" %"PRIu32, + LFS_DEBUG("Relocating %"PRIx32" %"PRIx32" -> %"PRIx32" %"PRIx32, oldpair[0], oldpair[1], dir->pair[0], dir->pair[1]); int err = lfs_fs_relocate(lfs, oldpair, dir->pair); if (err) { @@ -2236,7 +2236,7 @@ static int lfs_ctz_extend(lfs_t *lfs, } relocate: - LFS_DEBUG("Bad block at %"PRIu32, nblock); + LFS_DEBUG("Bad block at %"PRIx32, nblock); // just clear cache and try a new block lfs_cache_drop(lfs, pcache); @@ -2291,7 +2291,7 @@ static int lfs_ctz_traverse(lfs_t *lfs, int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file, const char *path, int flags, const struct lfs_file_config *cfg) { - LFS_TRACE("lfs_file_opencfg(%p, %p, \"%s\", 0x%x, %p {" + LFS_TRACE("lfs_file_opencfg(%p, %p, \"%s\", %x, %p {" ".buffer=%p, .attrs=%p, .attr_count=%"PRIu32"})", (void*)lfs, (void*)file, path, flags, (void*)cfg, cfg->buffer, (void*)cfg->attrs, cfg->attr_count); @@ -2442,7 +2442,7 @@ cleanup: int lfs_file_open(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) { - LFS_TRACE("lfs_file_open(%p, %p, \"%s\", 0x%x)", + LFS_TRACE("lfs_file_open(%p, %p, \"%s\", %x)", (void*)lfs, (void*)file, path, flags); static const struct lfs_file_config defaults = {0}; int err = lfs_file_opencfg(lfs, file, path, flags, &defaults); @@ -2534,7 +2534,7 @@ static int lfs_file_relocate(lfs_t *lfs, lfs_file_t *file) { return 0; relocate: - LFS_DEBUG("Bad block at %"PRIu32, nblock); + LFS_DEBUG("Bad block at %"PRIx32, nblock); // just clear cache and try a new block lfs_cache_drop(lfs, &lfs->pcache); @@ -2597,7 +2597,7 @@ static int lfs_file_flush(lfs_t *lfs, lfs_file_t *file) { break; relocate: - LFS_DEBUG("Bad block at %"PRIu32, file->block); + LFS_DEBUG("Bad block at %"PRIx32, file->block); err = lfs_file_relocate(lfs, file); if (err) { return err; @@ -3641,7 +3641,7 @@ int lfs_mount(lfs_t *lfs, const struct lfs_config *cfg) { lfs->gpending.tag += !lfs_tag_isvalid(lfs->gpending.tag); lfs->gstate = lfs->gpending; if (lfs_gstate_hasmove(&lfs->gstate)) { - LFS_DEBUG("Found move %"PRIu32" %"PRIu32" %"PRIu16, + LFS_DEBUG("Found move %"PRIx32" %"PRIx32" %"PRIx16, lfs->gstate.pair[0], lfs->gstate.pair[1], lfs_tag_id(lfs->gstate.tag)); @@ -3828,7 +3828,7 @@ static int lfs_fs_relocate(lfs_t *lfs, const lfs_block_t oldpair[2], lfs_block_t newpair[2]) { // update internal root if (lfs_pair_cmp(oldpair, lfs->root) == 0) { - LFS_DEBUG("Relocating root %"PRIu32" %"PRIu32, + LFS_DEBUG("Relocating root %"PRIx32" %"PRIx32, newpair[0], newpair[1]); lfs->root[0] = newpair[0]; lfs->root[1] = newpair[1]; @@ -3906,7 +3906,7 @@ static int lfs_fs_demove(lfs_t *lfs) { } // Fix bad moves - LFS_DEBUG("Fixing move %"PRIu32" %"PRIu32" %"PRIu16, + LFS_DEBUG("Fixing move %"PRIx32" %"PRIx32" %"PRIx16, lfs->gstate.pair[0], lfs->gstate.pair[1], lfs_tag_id(lfs->gstate.tag)); @@ -3954,7 +3954,7 @@ static int lfs_fs_deorphan(lfs_t *lfs) { if (tag == LFS_ERR_NOENT) { // we are an orphan - LFS_DEBUG("Fixing orphan %"PRIu32" %"PRIu32, + LFS_DEBUG("Fixing orphan %"PRIx32" %"PRIx32, pdir.tail[0], pdir.tail[1]); err = lfs_dir_drop(lfs, &pdir, &dir); @@ -3975,7 +3975,7 @@ static int lfs_fs_deorphan(lfs_t *lfs) { if (!lfs_pair_sync(pair, pdir.tail)) { // we have desynced - LFS_DEBUG("Fixing half-orphan %"PRIu32" %"PRIu32, + LFS_DEBUG("Fixing half-orphan %"PRIx32" %"PRIx32, pair[0], pair[1]); lfs_pair_tole32(pair); @@ -4238,7 +4238,7 @@ static int lfs1_dir_fetch(lfs_t *lfs, } if (!valid) { - LFS_ERROR("Corrupted dir pair at %" PRIu32 " %" PRIu32 , + LFS_ERROR("Corrupted dir pair at %" PRIx32 " %" PRIx32 , tpair[0], tpair[1]); return LFS_ERR_CORRUPT; } @@ -4600,7 +4600,7 @@ int lfs_migrate(lfs_t *lfs, const struct lfs_config *cfg) { // Copy over first block to thread into fs. Unfortunately // if this fails there is not much we can do. - LFS_DEBUG("Migrating %"PRIu32" %"PRIu32" -> %"PRIu32" %"PRIu32, + LFS_DEBUG("Migrating %"PRIx32" %"PRIx32" -> %"PRIx32" %"PRIx32, lfs->root[0], lfs->root[1], dir1.head[0], dir1.head[1]); err = lfs_bd_erase(lfs, dir1.head[1]); diff --git a/scripts/debug.py b/scripts/debug.py index f8c0484..ba7525d 100755 --- a/scripts/debug.py +++ b/scripts/debug.py @@ -95,7 +95,7 @@ def main(*blocks): print '%04x: %08x %-15s %3s %4s %-23s %-8s' % ( off, tag, typeof(type) + (' bad!' if iscrc and ~crc else ''), - id if id != 0x3ff else '.', + hex(id)[2:] if id != 0x3ff else '.', size if size != 0x3ff else 'x', ' '.join('%02x' % ord(c) for c in data[:8]), ''.join(c if c >= ' ' and c <= '~' else '.' for c in data[:8])) |