cpu: modified with review feedback

x86-global-inst-tracker.py:
- change the incorrect use of comment styly
- add more comments about the usage of the script and the purpose of
the script

src/cpu/probes/inst_tracker.cc:
- change the way of stopListening to use the manager function to remove
listeners. If in the future, the ProbeListner object does not call the
manager to remove itself in the destruction, then we should call it
here.
- fix stlying

src/cpu/probes/inst_tracker.hh:
- fix stlying

Change-Id: I6f3d745e15883a8a702593f72f984e0d4cc4c526
This commit is contained in:
studyztp
2024-08-18 09:50:50 -07:00
committed by Bobby R. Bruce
parent 6e39b737c8
commit 9fede07f44
3 changed files with 56 additions and 35 deletions

View File

@@ -43,8 +43,7 @@ void
LocalInstTracker::regProbeListeners()
{
if (ifListening) {
if (listeners.empty())
{
if (listeners.empty()) {
listeners.push_back(new LocalInstTrackerListener(this,
"RetiredInsts",
&LocalInstTracker::retiredInstsHandler));
@@ -63,11 +62,14 @@ void
LocalInstTracker::stopListening()
{
ifListening = false;
for (auto l = listeners.begin(); l != listeners.end(); ++l) {
delete (*l);
bool _ifRemoved;
for (auto &listener : listeners) {
_ifRemoved = getProbeManager()->removeListener(
"RetiredInsts",
*listener
);
DPRINTF(InstTracker, "If removed: %s\n", _ifRemoved ? "Yes" : "No");
}
listeners.clear();
DPRINTF(InstTracker, "Stopped listening\n");
}

View File

@@ -55,7 +55,7 @@ class LocalInstTracker : public ProbeListenerObject
private:
typedef ProbeListenerArg<LocalInstTracker, uint64_t>
LocalInstTrackerListener;
LocalInstTrackerListener;
/** a boolean variable that determines if the LocalInstTracker is
* listening to the ProbePoints or not
@@ -74,10 +74,11 @@ class LocalInstTracker : public ProbeListenerObject
void stopListening();
/** start listening to the ProbePoints */
void startListening()
void
startListening()
{
ifListening = true;
regProbeListeners();
ifListening = true;
regProbeListeners();
}
};
@@ -99,7 +100,6 @@ class GlobalInstTracker : public SimObject
*/
uint64_t instCount;
/**
* the threshold for the number of instructions that should be executed
* before the simulation exits
@@ -107,23 +107,26 @@ class GlobalInstTracker : public SimObject
uint64_t instThreshold;
public:
void changeThreshold(uint64_t new_threshold)
void
changeThreshold(uint64_t new_threshold)
{
instThreshold = new_threshold;
DPRINTF(InstTracker, "Changing the instruction threshold\n"
"instThreshold = %lu\n", instThreshold);
instThreshold = new_threshold;
DPRINTF(InstTracker, "Changing the instruction threshold\n"
"instThreshold = %lu\n", instThreshold);
};
void resetCounter()
void
resetCounter()
{
instCount = 0;
DPRINTF(InstTracker, "Resetting the instruction counter\n"
instCount = 0;
DPRINTF(InstTracker, "Resetting the instruction counter\n"
"instCount = %lu\n", instCount);
};
uint64_t getThreshold() const
uint64_t
getThreshold() const
{
return instThreshold;
return instThreshold;
};
};