sim: Align coding style of probes

Fix coding style of probes for the following aspects:
- Long lines
- Return type of multi-line functions
- Name of local parameters

Also, added missing overrides

Jira: https://gem5.atlassian.net/browse/GEM5-857

Change-Id: Ibd905d1941fc203ca8308f7a3930d58515b19a97
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/38697
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
Daniel R. Carvalho
2020-12-15 13:57:28 -03:00
committed by Daniel Carvalho
parent 7bdd8b56e3
commit 80b5f43d29
2 changed files with 49 additions and 31 deletions

View File

@@ -11,6 +11,9 @@
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
@@ -78,35 +81,39 @@ ProbeListener::~ProbeListener()
}
bool
ProbeManager::addListener(std::string pointName, ProbeListener &listener)
ProbeManager::addListener(std::string point_name, ProbeListener &listener)
{
DPRINTFR(ProbeVerbose, "Probes: Call to addListener to \"%s\" on %s.\n", pointName, object->name());
DPRINTFR(ProbeVerbose, "Probes: Call to addListener to \"%s\" on %s.\n",
point_name, object->name());
bool added = false;
for (auto p = points.begin(); p != points.end(); ++p) {
if ((*p)->getName() == pointName) {
if ((*p)->getName() == point_name) {
(*p)->addListener(&listener);
added = true;
}
}
if (!added) {
DPRINTFR(ProbeVerbose, "Probes: Call to addListener to \"%s\" on %s failed, no such point.\n", pointName, object->name());
DPRINTFR(ProbeVerbose, "Probes: Call to addListener to \"%s\" on "
"%s failed, no such point.\n", point_name, object->name());
}
return added;
}
bool
ProbeManager::removeListener(std::string pointName, ProbeListener &listener)
ProbeManager::removeListener(std::string point_name, ProbeListener &listener)
{
DPRINTFR(ProbeVerbose, "Probes: Call to removeListener from \"%s\" on %s.\n", pointName, object->name());
DPRINTFR(ProbeVerbose, "Probes: Call to removeListener from \"%s\" on "
"%s.\n", point_name, object->name());
bool removed = false;
for (auto p = points.begin(); p != points.end(); ++p) {
if ((*p)->getName() == pointName) {
if ((*p)->getName() == point_name) {
(*p)->removeListener(&listener);
removed = true;
}
}
if (!removed) {
DPRINTFR(ProbeVerbose, "Probes: Call to removeListener from \"%s\" on %s failed, no such point.\n", pointName, object->name());
DPRINTFR(ProbeVerbose, "Probes: Call to removeListener from \"%s\" "
"on %s failed, no such point.\n", point_name, object->name());
}
return removed;
}
@@ -114,11 +121,13 @@ ProbeManager::removeListener(std::string pointName, ProbeListener &listener)
void
ProbeManager::addPoint(ProbePoint &point)
{
DPRINTFR(ProbeVerbose, "Probes: Call to addPoint \"%s\" to %s.\n", point.getName(), object->name());
DPRINTFR(ProbeVerbose, "Probes: Call to addPoint \"%s\" to %s.\n",
point.getName(), object->name());
for (auto p = points.begin(); p != points.end(); ++p) {
if ((*p)->getName() == point.getName()) {
DPRINTFR(ProbeVerbose, "Probes: Call to addPoint \"%s\" to %s failed, already added.\n", point.getName(), object->name());
DPRINTFR(ProbeVerbose, "Probes: Call to addPoint \"%s\" to %s "
"failed, already added.\n", point.getName(), object->name());
return;
}
}

View File

@@ -11,6 +11,9 @@
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Copyright (c) 2020 Inria
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
@@ -39,21 +42,22 @@
* @file This file describes the base components used for the probe system.
* There are currently 3 components:
*
* ProbePoint: an event probe point i.e. send a notify from the point
* at which an instruction was committed.
* ProbePoint: an event probe point i.e. sends a notify from the
* point at which an instruction was committed.
*
* ProbeListener: a listener provide a notify method that is called when
* ProbeListener: a listener provides a notify method that is called when
* a probe point event occurs. Multiple ProbeListeners
* can be added to each ProbePoint.
*
* ProbeListenerObject: a wrapper around a SimObject that can connect to another
* SimObject on which is will add ProbeListeners.
* ProbeListenerObject: a wrapper around a SimObject that can connect to
* another SimObject on which it will add ProbeListeners.
*
* ProbeManager: used to match up ProbeListeners and ProbePoints.
* At <b>simulation init</b> this is handled by regProbePoints
* followed by regProbeListeners being called on each
* SimObject in hierarchical ordering.
* ProbeListeners can be added/removed dynamically at runtime.
* At <b>simulation init</b> this is handled by
* regProbePoints followed by regProbeListeners being
* called on each SimObject in hierarchical ordering.
* ProbeListeners can be added/removed dynamically at
* runtime.
*/
#ifndef __SIM_PROBE_PROBE_HH__
@@ -173,21 +177,21 @@ class ProbeManager
/**
* @brief Add a ProbeListener to the ProbePoint named by pointName.
* If the name doesn't resolve a ProbePoint return false.
* @param pointName the name of the ProbePoint to add the ProbeListener to.
* @param point_name name of the ProbePoint to add the ProbeListener to.
* @param listener the ProbeListener to add.
* @return true if added, false otherwise.
*/
bool addListener(std::string pointName, ProbeListener &listener);
bool addListener(std::string point_name, ProbeListener &listener);
/**
* @brief Remove a ProbeListener from the ProbePoint named by pointName.
* If the name doesn't resolve a ProbePoint return false.
* @param pointName the name of the ProbePoint to remove the ProbeListener
* @param point_name the name of the ProbePoint to remove the ProbeListener
* from.
* @param listener the ProbeListener to remove.
* @return true if removed, false otherwise.
*/
bool removeListener(std::string pointName, ProbeListener &listener);
bool removeListener(std::string point_name, ProbeListener &listener);
/**
* @brief Add a ProbePoint to this SimObject ProbeManager.
@@ -233,18 +237,19 @@ class ProbeListenerArg : public ProbeListenerArgBase<Arg>
* @param name the name of the ProbePoint to add this listener to.
* @param func a pointer to the function on obj (called on notify).
*/
ProbeListenerArg(T *obj, const std::string &name, void (T::* func)(const Arg &))
ProbeListenerArg(T *obj, const std::string &name,
void (T::* func)(const Arg &))
: ProbeListenerArgBase<Arg>(obj->getProbeManager(), name),
object(obj),
function(func)
{}
/**
* @brief called when the ProbePoint calls notify. This is a shim through to
* the function passed during construction.
* @brief called when the ProbePoint calls notify. This is a shim through
* to the function passed during construction.
* @param val the argument value to pass.
*/
virtual void notify(const Arg &val) { (object->*function)(val); }
void notify(const Arg &val) override { (object->*function)(val); }
};
/**
@@ -279,10 +284,12 @@ class ProbePointArg : public ProbePoint
* @brief adds a ProbeListener to this ProbePoints notify list.
* @param l the ProbeListener to add to the notify list.
*/
void addListener(ProbeListener *l)
void
addListener(ProbeListener *l) override
{
// check listener not already added
if (std::find(listeners.begin(), listeners.end(), l) == listeners.end()) {
if (std::find(listeners.begin(), listeners.end(), l) ==
listeners.end()) {
listeners.push_back(static_cast<ProbeListenerArgBase<Arg> *>(l));
}
}
@@ -291,7 +298,8 @@ class ProbePointArg : public ProbePoint
* @brief remove a ProbeListener from this ProbePoints notify list.
* @param l the ProbeListener to remove from the notify list.
*/
void removeListener(ProbeListener *l)
void
removeListener(ProbeListener *l) override
{
listeners.erase(std::remove(listeners.begin(), listeners.end(), l),
listeners.end());
@@ -301,7 +309,8 @@ class ProbePointArg : public ProbePoint
* @brief called at the ProbePoint call site, passes arg to each listener.
* @param arg the argument to pass to each listener.
*/
void notify(const Arg &arg)
void
notify(const Arg &arg)
{
for (auto l = listeners.begin(); l != listeners.end(); ++l) {
(*l)->notify(arg);