From: Alec Roelke Date: Fri, 15 Dec 2017 04:22:10 +0000 (-0500) Subject: arch-riscv: Don't crash when printing unknown CSRs X-Git-Tag: v19.0.0.0~2381 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b622601dfbabfb7cebf1a6df2eb8b0440d8365cb;p=gem5.git arch-riscv: Don't crash when printing unknown CSRs This patch fixes a potential crash if an unnamed CSR is accessed and debug flags are enabled that print disassembly. Unknown CSRs will be identified as "??" followed by the address that was used. Change-Id: If5ac57f1422bd59c72a1a06206fa9d9dc05d21ef Reviewed-on: https://gem5-review.googlesource.com/7321 Reviewed-by: Jason Lowe-Power Reviewed-by: Gabe Black Maintainer: Alec Roelke --- diff --git a/src/arch/riscv/insts/standard.cc b/src/arch/riscv/insts/standard.cc index bcf0741f9..60cf4fc2b 100644 --- a/src/arch/riscv/insts/standard.cc +++ b/src/arch/riscv/insts/standard.cc @@ -60,7 +60,11 @@ CSROp::generateDisassembly(Addr pc, const SymbolTable *symtab) const ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "; if (_numSrcRegs > 0) ss << registerName(_srcRegIdx[0]) << ", "; - ss << MiscRegNames.at(csr); + auto name = MiscRegNames.find(csr); + if (name != MiscRegNames.end()) + ss << name->second; + else + ss << "?? (" << hex << "0x" << csr << ")"; return ss.str(); }