diff --git a/src/arch/arm/pmu.cc b/src/arch/arm/pmu.cc index ad4ea241c2..57df5f6b34 100644 --- a/src/arch/arm/pmu.cc +++ b/src/arch/arm/pmu.cc @@ -118,7 +118,7 @@ PMU::addSoftwareIncrementEvent(unsigned int id) fatal_if(old_event != eventMap.end(), "An event with id %d has " "been previously defined\n", id); - swIncrementEvent = new SWIncrementEvent(); + swIncrementEvent = std::make_shared(); eventMap[id] = swIncrementEvent; registerEvent(id); } @@ -130,18 +130,14 @@ PMU::addEventProbe(unsigned int id, SimObject *obj, const char *probe_name) DPRINTF(PMUVerbose, "PMU: Adding Probe Driven event with id '0x%x'" "as probe %s:%s\n",id, obj->name(), probe_name); - RegularEvent *event = nullptr; + std::shared_ptr event; auto event_entry = eventMap.find(id); if (event_entry == eventMap.end()) { - - event = new RegularEvent(); + event = std::make_shared(); eventMap[id] = event; - } else { - event = dynamic_cast(event_entry->second); - if (!event) { - fatal("Event with id %d is not probe driven\n", id); - } + event = std::dynamic_pointer_cast(event_entry->second); + fatal_if(!event, "Event with id %d is not probe driven\n", id); } event->addMicroarchitectureProbe(obj, probe_name); @@ -182,7 +178,7 @@ PMU::regProbeListeners() counters.emplace_back(*this, index); } - PMUEvent *event = getEvent(cycleCounterEventId); + std::shared_ptr event = getEvent(cycleCounterEventId); panic_if(!event, "core cycle event is not present\n"); cycleCounter.enabled = true; cycleCounter.attach(event); @@ -531,7 +527,7 @@ PMU::CounterState::detach() } void -PMU::CounterState::attach(PMUEvent* event) +PMU::CounterState::attach(const std::shared_ptr &event) { if (!resetValue) { value = 0; @@ -734,7 +730,7 @@ PMU::unserialize(CheckpointIn &cp) cycleCounter.unserializeSection(cp, "cycleCounter"); } -PMU::PMUEvent* +std::shared_ptr PMU::getEvent(uint64_t eventId) { auto entry = eventMap.find(eventId); diff --git a/src/arch/arm/pmu.hh b/src/arch/arm/pmu.hh index b9b2747fad..46b10d0a8a 100644 --- a/src/arch/arm/pmu.hh +++ b/src/arch/arm/pmu.hh @@ -408,7 +408,7 @@ class PMU : public SimObject, public ArmISA::BaseISADevice * @param the id of the event to obtain * @return a pointer to the event with id eventId */ - PMUEvent* getEvent(uint64_t eventId); + std::shared_ptr getEvent(uint64_t eventId); /** State of a counter within the PMU. **/ struct CounterState : public Serializable @@ -442,7 +442,7 @@ class PMU : public SimObject, public ArmISA::BaseISADevice * * @param the event to attach the counter to */ - void attach(PMUEvent* event); + void attach(const std::shared_ptr &event); /** * Obtain the counter id @@ -482,7 +482,7 @@ class PMU : public SimObject, public ArmISA::BaseISADevice protected: /* Configuration */ /** PmuEvent currently in use (if any) **/ - PMUEvent *sourceEvent; + std::shared_ptr sourceEvent; /** id of the counter instance **/ uint64_t counterId; @@ -612,7 +612,7 @@ class PMU : public SimObject, public ArmISA::BaseISADevice const uint64_t cycleCounterEventId; /** The event that implements the software increment **/ - SWIncrementEvent *swIncrementEvent; + std::shared_ptr swIncrementEvent; protected: /* Configuration and constants */ /** Constant (configuration-dependent) part of the PMCR */ @@ -627,7 +627,7 @@ class PMU : public SimObject, public ArmISA::BaseISADevice /** * List of event types supported by this PMU. */ - std::map eventMap; + std::map> eventMap; }; } // namespace ArmISA