From 9d8273e341fd56f3faa821be84801367777879be Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 24 Aug 2020 01:52:12 -0700 Subject: [PATCH] sim: Style fixes in the base Fault classes. Change-Id: Iff8588aba929b3909ca1b5ec0e494acb8f838543 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33280 Maintainer: Gabe Black Tested-by: kokoro Reviewed-by: Bobby R. Bruce --- src/sim/faults.cc | 32 ++++++++++++++++++-------------- src/sim/faults.hh | 29 +++++++++++++---------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/sim/faults.cc b/src/sim/faults.cc index c2ce9784e..46485d49c 100644 --- a/src/sim/faults.cc +++ b/src/sim/faults.cc @@ -37,43 +37,47 @@ #include "sim/full_system.hh" #include "sim/process.hh" -void FaultBase::invoke(ThreadContext * tc, const StaticInstPtr &inst) +void +FaultBase::invoke(ThreadContext *tc, const StaticInstPtr &inst) { - if (FullSystem) { - DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState()); - } else { - panic("fault (%s) detected @ PC %s", name(), tc->pcState()); - } + panic_if(!FullSystem, "fault (%s) detected @ PC %s", + name(), tc->pcState()); + DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState()); } -void UnimpFault::invoke(ThreadContext * tc, const StaticInstPtr &inst) +void +UnimpFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) { - panic("Unimpfault: %s\n", panicStr.c_str()); + panic("Unimpfault: %s", panicStr.c_str()); } -void ReExec::invoke(ThreadContext *tc, const StaticInstPtr &inst) +void +ReExec::invoke(ThreadContext *tc, const StaticInstPtr &inst) { tc->pcState(tc->pcState()); } -void SyscallRetryFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) +void +SyscallRetryFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) { tc->pcState(tc->pcState()); } -void GenericPageTableFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) +void +GenericPageTableFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) { bool handled = false; if (!FullSystem) { Process *p = tc->getProcessPtr(); handled = p->fixupFault(vaddr); } - if (!handled) - panic("Page table fault when accessing virtual address %#x\n", vaddr); + panic_if(!handled, "Page table fault when accessing virtual address %#x", + vaddr); } -void GenericAlignmentFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) +void +GenericAlignmentFault::invoke(ThreadContext *tc, const StaticInstPtr &inst) { panic("Alignment fault when accessing virtual address %#x\n", vaddr); } diff --git a/src/sim/faults.hh b/src/sim/faults.hh index 646d24aa8..e9a57c6b4 100644 --- a/src/sim/faults.hh +++ b/src/sim/faults.hh @@ -35,14 +35,14 @@ class ThreadContext; -typedef const char * FaultName; +typedef const char *FaultName; typedef Stats::Scalar FaultStat; class FaultBase { public: virtual FaultName name() const = 0; - virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst = + virtual void invoke(ThreadContext * tc, const StaticInstPtr &inst= StaticInst::nullStaticInstPtr); virtual ~FaultBase() {}; @@ -53,22 +53,19 @@ class UnimpFault : public FaultBase private: std::string panicStr; public: - UnimpFault(std::string _str) - : panicStr(_str) - { } + UnimpFault(std::string _str) : panicStr(_str) {} FaultName name() const { return "Unimplemented simulator feature"; } - void invoke(ThreadContext * tc, const StaticInstPtr &inst = - StaticInst::nullStaticInstPtr); + void invoke(ThreadContext *tc, const StaticInstPtr &inst = + StaticInst::nullStaticInstPtr) override; }; class ReExec : public FaultBase { public: virtual FaultName name() const { return "Re-execution fault"; } - ReExec() {} - void invoke(ThreadContext *tc, const StaticInstPtr &inst = - StaticInst::nullStaticInstPtr); + void invoke(ThreadContext *tc, const StaticInstPtr &inst= + StaticInst::nullStaticInstPtr) override; }; /* @@ -83,8 +80,8 @@ class SyscallRetryFault : public FaultBase public: virtual FaultName name() const { return "System call retry fault"; } SyscallRetryFault() {} - void invoke(ThreadContext *tc, const StaticInstPtr &inst = - StaticInst::nullStaticInstPtr); + void invoke(ThreadContext *tc, const StaticInstPtr &inst= + StaticInst::nullStaticInstPtr) override; }; class GenericPageTableFault : public FaultBase @@ -94,8 +91,8 @@ class GenericPageTableFault : public FaultBase public: FaultName name() const { return "Generic page table fault"; } GenericPageTableFault(Addr va) : vaddr(va) {} - void invoke(ThreadContext * tc, const StaticInstPtr &inst = - StaticInst::nullStaticInstPtr); + void invoke(ThreadContext *tc, const StaticInstPtr &inst= + StaticInst::nullStaticInstPtr) override; Addr getFaultVAddr() const { return vaddr; } }; @@ -106,8 +103,8 @@ class GenericAlignmentFault : public FaultBase public: FaultName name() const { return "Generic alignment fault"; } GenericAlignmentFault(Addr va) : vaddr(va) {} - void invoke(ThreadContext * tc, const StaticInstPtr &inst = - StaticInst::nullStaticInstPtr); + void invoke(ThreadContext *tc, const StaticInstPtr &inst= + StaticInst::nullStaticInstPtr) override; Addr getFaultVAddr() const { return vaddr; } }; -- 2.30.2