gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
pc_event.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __PC_EVENT_HH__
30#define __PC_EVENT_HH__
31
32#include <vector>
33
34#include "base/logging.hh"
35#include "base/types.hh"
36
37namespace gem5
38{
39
40class ThreadContext;
41class PCEventQueue;
42class System;
43class PCEventScope;
44
46{
47 protected:
48 std::string description;
51
52 public:
53 PCEvent(PCEventScope *q, const std::string &desc, Addr pc);
54
55 virtual ~PCEvent() { if (scope) remove(); }
56
57 // for DPRINTF
58 virtual const std::string name() const { return description; }
59
60 std::string descr() const { return description; }
61 Addr pc() const { return evpc; }
62
63 bool remove();
64 virtual void process(ThreadContext *tc) = 0;
65};
66
68{
69 public:
70 virtual bool remove(PCEvent *event) = 0;
71 virtual bool schedule(PCEvent *event) = 0;
72 virtual ~PCEventScope() = default;
73};
74
76{
77 protected:
79 {
80 public:
81 bool
82 operator()(PCEvent * const &l, PCEvent * const &r) const
83 {
84 return l->pc() < r->pc();
85 }
86 bool
87 operator()(PCEvent * const &l, Addr pc) const
88 {
89 return l->pc() < pc;
90 }
91 bool
92 operator()(Addr pc, PCEvent * const &r) const
93 {
94 return pc < r->pc();
95 }
96 };
98
99 public:
100 typedef Map::iterator iterator;
101 typedef Map::const_iterator const_iterator;
102
103 protected:
106
107 protected:
109
110 bool doService(Addr pc, ThreadContext *tc);
111
112 public:
113 PCEventQueue();
115
116 bool remove(PCEvent *event) override;
117 bool schedule(PCEvent *event) override;
119 {
120 if (pcMap.empty())
121 return false;
122
123 return doService(pc, tc);
124 }
125
128
129 void dump() const;
130};
131
132
133inline
134PCEvent::PCEvent(PCEventScope *s, const std::string &desc, Addr pc)
135 : description(desc), scope(s), evpc(pc)
136{
137 scope->schedule(this);
138}
139
140inline bool
142{
143 if (!scope)
144 panic("cannot remove an uninitialized event;");
145
146 return scope->remove(this);
147}
148
149class BreakPCEvent : public PCEvent
150{
151 protected:
152 bool remove;
153
154 public:
155 BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr,
156 bool del = false);
157 virtual void process(ThreadContext *tc);
158};
159
160class PanicPCEvent : public PCEvent
161{
162 public:
163 PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc);
164 virtual void process(ThreadContext *tc);
165};
166
167} // namespace gem5
168
169#endif // __PC_EVENT_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del=false)
Definition pc_event.cc:117
virtual void process(ThreadContext *tc)
Definition pc_event.cc:124
bool operator()(PCEvent *const &l, PCEvent *const &r) const
Definition pc_event.hh:82
bool operator()(Addr pc, PCEvent *const &r) const
Definition pc_event.hh:92
bool operator()(PCEvent *const &l, Addr pc) const
Definition pc_event.hh:87
range_t equal_range(PCEvent *event)
Definition pc_event.hh:127
range_t equal_range(Addr pc)
Definition pc_event.cc:112
Map::iterator iterator
Definition pc_event.hh:100
std::pair< iterator, iterator > range_t
Definition pc_event.hh:104
Map::const_iterator const_iterator
Definition pc_event.hh:101
bool remove(PCEvent *event) override
Definition pc_event.cc:51
void dump() const
Definition pc_event.cc:101
std::vector< PCEvent * > Map
Definition pc_event.hh:97
std::pair< const_iterator, const_iterator > const_range_t
Definition pc_event.hh:105
bool service(Addr pc, ThreadContext *tc)
Definition pc_event.hh:118
bool doService(Addr pc, ThreadContext *tc)
Definition pc_event.cc:83
bool schedule(PCEvent *event) override
Definition pc_event.cc:71
virtual ~PCEventScope()=default
virtual bool schedule(PCEvent *event)=0
virtual bool remove(PCEvent *event)=0
virtual const std::string name() const
Definition pc_event.hh:58
bool remove()
Definition pc_event.hh:141
PCEventScope * scope
Definition pc_event.hh:49
virtual ~PCEvent()
Definition pc_event.hh:55
Addr pc() const
Definition pc_event.hh:61
PCEvent(PCEventScope *q, const std::string &desc, Addr pc)
Definition pc_event.hh:134
std::string description
Definition pc_event.hh:48
virtual void process(ThreadContext *tc)=0
std::string descr() const
Definition pc_event.hh:60
PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc)
Definition pc_event.cc:133
virtual void process(ThreadContext *tc)
Definition pc_event.cc:139
ThreadContext is the external interface to all thread state for anything outside of the CPU.
STL pair class.
Definition stl.hh:58
STL vector class.
Definition stl.hh:37
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
Bitfield< 4 > s
Bitfield< 27 > q
Definition misc_types.hh:55
Bitfield< 4 > pc
Bitfield< 10, 5 > event
Bitfield< 5 > l
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147

Generated on Mon Oct 27 2025 04:13:00 for gem5 by doxygen 1.14.0