aboutsummaryrefslogtreecommitdiff
path: root/riscv/interactive.cc
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2021-05-01 16:34:00 -0700
committerAndrew Waterman <andrew@sifive.com>2021-05-01 16:34:00 -0700
commit159a19f0248a92bce01dbdd9a7f429e1227c7175 (patch)
tree7750be150cb042846496a9e0f65cae1383b83af1 /riscv/interactive.cc
parentdbd59e9bbfd2cb933b984d899b783b6db12d71be (diff)
downloadspike-159a19f0248a92bce01dbdd9a7f429e1227c7175.zip
spike-159a19f0248a92bce01dbdd9a7f429e1227c7175.tar.gz
spike-159a19f0248a92bce01dbdd9a7f429e1227c7175.tar.bz2
Improve coding style of logging printfs
Diffstat (limited to 'riscv/interactive.cc')
-rw-r--r--riscv/interactive.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/riscv/interactive.cc b/riscv/interactive.cc
index 22929d4..5ed87d3 100644
--- a/riscv/interactive.cc
+++ b/riscv/interactive.cc
@@ -184,8 +184,7 @@ void sim_t::interactive_pc(const std::string& cmd, const std::vector<std::string
processor_t *p = get_core(args[0]);
int max_xlen = p->get_max_xlen();
- fprintf(stderr, max_xlen==32 ? "0x%08" PRIx64 "\n" :
- "0x%016" PRIx64 "\n", ERASE_32MSB(max_xlen,get_pc(args)));
+ fprintf(stderr, "0x%0*" PRIx64 "\n", max_xlen/4, zext(get_pc(args), max_xlen));
}
reg_t sim_t::get_reg(const std::vector<std::string>& args)
@@ -288,14 +287,14 @@ void sim_t::interactive_reg(const std::string& cmd, const std::vector<std::strin
// Show all the regs!
for (int r = 0; r < NXPR; ++r) {
- fprintf(stderr, max_xlen==32 ? "%-4s: 0x%08" PRIx64 " " :
- "%-4s: 0x%016" PRIx64 " ", xpr_name[r], ERASE_32MSB(max_xlen,p->get_state()->XPR[r]));
+ fprintf(stderr, "%-4s: 0x%0*" PRIx64 " ", xpr_name[r], max_xlen/4,
+ zext(p->get_state()->XPR[r], max_xlen));
if ((r + 1) % 4 == 0)
fprintf(stderr, "\n");
}
- } else
- fprintf(stderr, max_xlen==32 ? "0x%08" PRIx64 "\n" :
- "0x%016" PRIx64 "\n", ERASE_32MSB(max_xlen,get_reg(args)));
+ } else {
+ fprintf(stderr, "0x%0*" PRIx64 "\n", max_xlen/4, zext(get_reg(args), max_xlen));
+ }
}
union fpr
@@ -373,8 +372,7 @@ void sim_t::interactive_mem(const std::string& cmd, const std::vector<std::strin
{
int max_xlen = procs[0]->get_max_xlen();
- fprintf(stderr, max_xlen==32 ? "0x%08" PRIx64 "\n" :
- "0x%016" PRIx64 "\n", ERASE_32MSB(max_xlen,get_mem(args)));
+ fprintf(stderr, "0x%0*" PRIx64 "\n", max_xlen/4, zext(get_mem(args), max_xlen));
}
void sim_t::interactive_str(const std::string& cmd, const std::vector<std::string>& args)