cpu: Clean up some style issues in pc_event.(hh|cc).
The record_t typedef isn't all that helpful, and is also not consistent with gem5 style. The map_t style is more useful but is also not compliant. This change eliminates the first typedef and replaces the second with a type called Map. There are some other small style fixups added in as well, like making the member variable pc_map pcMap. Change-Id: I8ffea529004fd6d5b42fdc60250804e2e4987e88 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21781 Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -57,17 +57,15 @@ PCEventQueue::remove(PCEvent *event)
|
||||
int removed = 0;
|
||||
range_t range = equal_range(event);
|
||||
iterator i = range.first;
|
||||
while (i != range.second &&
|
||||
i != pc_map.end()) {
|
||||
while (i != range.second && i != pcMap.end()) {
|
||||
if (*i == event) {
|
||||
DPRINTF(PCEvent, "PC based event removed at %#x: %s\n",
|
||||
event->pc(), event->descr());
|
||||
i = pc_map.erase(i);
|
||||
i = pcMap.erase(i);
|
||||
++removed;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return removed > 0;
|
||||
@@ -76,8 +74,8 @@ PCEventQueue::remove(PCEvent *event)
|
||||
bool
|
||||
PCEventQueue::schedule(PCEvent *event)
|
||||
{
|
||||
pc_map.push_back(event);
|
||||
sort(pc_map.begin(), pc_map.end(), MapCompare());
|
||||
pcMap.push_back(event);
|
||||
sort(pcMap.begin(), pcMap.end(), MapCompare());
|
||||
|
||||
DPRINTF(PCEvent, "PC based event scheduled for %#x: %s\n",
|
||||
event->pc(), event->descr());
|
||||
@@ -114,8 +112,8 @@ PCEventQueue::doService(ThreadContext *tc)
|
||||
void
|
||||
PCEventQueue::dump() const
|
||||
{
|
||||
const_iterator i = pc_map.begin();
|
||||
const_iterator e = pc_map.end();
|
||||
const_iterator i = pcMap.begin();
|
||||
const_iterator e = pcMap.end();
|
||||
|
||||
for (; i != e; ++i)
|
||||
cprintf("%d: event at %#x: %s\n", curTick(), (*i)->pc(),
|
||||
@@ -125,7 +123,7 @@ PCEventQueue::dump() const
|
||||
PCEventQueue::range_t
|
||||
PCEventQueue::equal_range(Addr pc)
|
||||
{
|
||||
return std::equal_range(pc_map.begin(), pc_map.end(), pc, MapCompare());
|
||||
return std::equal_range(pcMap.begin(), pcMap.end(), pc, MapCompare());
|
||||
}
|
||||
|
||||
BreakPCEvent::BreakPCEvent(PCEventQueue *q, const std::string &desc, Addr addr,
|
||||
|
||||
@@ -66,31 +66,36 @@ class PCEvent
|
||||
class PCEventQueue
|
||||
{
|
||||
protected:
|
||||
typedef PCEvent * record_t;
|
||||
class MapCompare {
|
||||
public:
|
||||
bool operator()(const record_t &l, const record_t &r) const {
|
||||
bool
|
||||
operator()(PCEvent * const &l, PCEvent * const &r) const
|
||||
{
|
||||
return l->pc() < r->pc();
|
||||
}
|
||||
bool operator()(const record_t &l, Addr pc) const {
|
||||
bool
|
||||
operator()(PCEvent * const &l, Addr pc) const
|
||||
{
|
||||
return l->pc() < pc;
|
||||
}
|
||||
bool operator()(Addr pc, const record_t &r) const {
|
||||
bool
|
||||
operator()(Addr pc, PCEvent * const &r) const
|
||||
{
|
||||
return pc < r->pc();
|
||||
}
|
||||
};
|
||||
typedef std::vector<record_t> map_t;
|
||||
typedef std::vector<PCEvent *> Map;
|
||||
|
||||
public:
|
||||
typedef map_t::iterator iterator;
|
||||
typedef map_t::const_iterator const_iterator;
|
||||
typedef Map::iterator iterator;
|
||||
typedef Map::const_iterator const_iterator;
|
||||
|
||||
protected:
|
||||
typedef std::pair<iterator, iterator> range_t;
|
||||
typedef std::pair<const_iterator, const_iterator> const_range_t;
|
||||
|
||||
protected:
|
||||
map_t pc_map;
|
||||
Map pcMap;
|
||||
|
||||
bool doService(ThreadContext *tc);
|
||||
|
||||
@@ -102,7 +107,7 @@ class PCEventQueue
|
||||
bool schedule(PCEvent *event);
|
||||
bool service(ThreadContext *tc)
|
||||
{
|
||||
if (pc_map.empty())
|
||||
if (pcMap.empty())
|
||||
return false;
|
||||
|
||||
return doService(tc);
|
||||
|
||||
Reference in New Issue
Block a user