gem5  v20.1.0.0
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 
37 class ThreadContext;
38 class PCEventQueue;
39 class System;
40 class PCEventScope;
41 
42 class PCEvent
43 {
44  protected:
45  std::string description;
48 
49  public:
50  PCEvent(PCEventScope *q, const std::string &desc, Addr pc);
51 
52  virtual ~PCEvent() { if (scope) remove(); }
53 
54  // for DPRINTF
55  virtual const std::string name() const { return description; }
56 
57  std::string descr() const { return description; }
58  Addr pc() const { return evpc; }
59 
60  bool remove();
61  virtual void process(ThreadContext *tc) = 0;
62 };
63 
65 {
66  public:
67  virtual bool remove(PCEvent *event) = 0;
68  virtual bool schedule(PCEvent *event) = 0;
69 };
70 
71 class PCEventQueue : public PCEventScope
72 {
73  protected:
74  class MapCompare {
75  public:
76  bool
77  operator()(PCEvent * const &l, PCEvent * const &r) const
78  {
79  return l->pc() < r->pc();
80  }
81  bool
82  operator()(PCEvent * const &l, Addr pc) const
83  {
84  return l->pc() < pc;
85  }
86  bool
87  operator()(Addr pc, PCEvent * const &r) const
88  {
89  return pc < r->pc();
90  }
91  };
93 
94  public:
95  typedef Map::iterator iterator;
96  typedef Map::const_iterator const_iterator;
97 
98  protected:
101 
102  protected:
104 
105  bool doService(Addr pc, ThreadContext *tc);
106 
107  public:
108  PCEventQueue();
109  ~PCEventQueue();
110 
111  bool remove(PCEvent *event) override;
112  bool schedule(PCEvent *event) override;
114  {
115  if (pcMap.empty())
116  return false;
117 
118  return doService(pc, tc);
119  }
120 
123 
124  void dump() const;
125 };
126 
127 
128 inline
129 PCEvent::PCEvent(PCEventScope *s, const std::string &desc, Addr pc)
130  : description(desc), scope(s), evpc(pc)
131 {
132  scope->schedule(this);
133 }
134 
135 inline bool
137 {
138  if (!scope)
139  panic("cannot remove an uninitialized event;");
140 
141  return scope->remove(this);
142 }
143 
144 class BreakPCEvent : public PCEvent
145 {
146  protected:
147  bool remove;
148 
149  public:
150  BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr,
151  bool del = false);
152  virtual void process(ThreadContext *tc);
153 };
154 
155 class PanicPCEvent : public PCEvent
156 {
157  public:
158  PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc);
159  virtual void process(ThreadContext *tc);
160 };
161 
162 #endif // __PC_EVENT_HH__
PCEventScope::remove
virtual bool remove(PCEvent *event)=0
PanicPCEvent::process
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:138
PCEvent::PCEvent
PCEvent(PCEventScope *q, const std::string &desc, Addr pc)
Definition: pc_event.hh:129
PCEventQueue::const_range_t
std::pair< const_iterator, const_iterator > const_range_t
Definition: pc_event.hh:100
PCEventQueue::pcMap
Map pcMap
Definition: pc_event.hh:103
PCEventQueue::equal_range
range_t equal_range(Addr pc)
Definition: pc_event.cc:111
PCEventQueue::Map
std::vector< PCEvent * > Map
Definition: pc_event.hh:92
PCEvent::process
virtual void process(ThreadContext *tc)=0
ArmISA::q
Bitfield< 27 > q
Definition: miscregs_types.hh:52
PCEventQueue::service
bool service(Addr pc, ThreadContext *tc)
Definition: pc_event.hh:113
PCEventQueue::MapCompare::operator()
bool operator()(PCEvent *const &l, PCEvent *const &r) const
Definition: pc_event.hh:77
std::vector< PCEvent * >
PCEventQueue
Definition: pc_event.hh:71
PCEventQueue::iterator
Map::iterator iterator
Definition: pc_event.hh:95
PCEvent::name
virtual const std::string name() const
Definition: pc_event.hh:55
PCEventQueue::range_t
std::pair< iterator, iterator > range_t
Definition: pc_event.hh:99
PCEvent::pc
Addr pc() const
Definition: pc_event.hh:58
BreakPCEvent::BreakPCEvent
BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del=false)
Definition: pc_event.cc:116
PCEvent::~PCEvent
virtual ~PCEvent()
Definition: pc_event.hh:52
PCEventQueue::equal_range
range_t equal_range(PCEvent *event)
Definition: pc_event.hh:122
PanicPCEvent::PanicPCEvent
PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc)
Definition: pc_event.cc:132
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
PCEvent::description
std::string description
Definition: pc_event.hh:45
PCEventQueue::doService
bool doService(Addr pc, ThreadContext *tc)
Definition: pc_event.cc:82
PCEventScope::schedule
virtual bool schedule(PCEvent *event)=0
System
Definition: system.hh:73
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:297
MipsISA::r
r
Definition: pra_constants.hh:95
PCEventQueue::schedule
bool schedule(PCEvent *event) override
Definition: pc_event.cc:70
PCEventScope
Definition: pc_event.hh:64
std::pair
STL pair class.
Definition: stl.hh:58
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
PCEventQueue::MapCompare
Definition: pc_event.hh:74
PCEventQueue::PCEventQueue
PCEventQueue()
Definition: pc_event.cc:43
PCEvent::evpc
Addr evpc
Definition: pc_event.hh:47
BreakPCEvent::remove
bool remove
Definition: pc_event.hh:147
PCEventQueue::const_iterator
Map::const_iterator const_iterator
Definition: pc_event.hh:96
types.hh
PCEventQueue::remove
bool remove(PCEvent *event) override
Definition: pc_event.cc:50
BreakPCEvent
Definition: pc_event.hh:144
addr
ip6_addr_t addr
Definition: inet.hh:423
PCEventQueue::~PCEventQueue
~PCEventQueue()
Definition: pc_event.cc:46
logging.hh
PCEventQueue::MapCompare::operator()
bool operator()(PCEvent *const &l, Addr pc) const
Definition: pc_event.hh:82
PCEvent
Definition: pc_event.hh:42
PCEvent::descr
std::string descr() const
Definition: pc_event.hh:57
PCEvent::remove
bool remove()
Definition: pc_event.hh:136
PCEventQueue::dump
void dump() const
Definition: pc_event.cc:100
ArmISA::s
Bitfield< 4 > s
Definition: miscregs_types.hh:556
MipsISA::l
Bitfield< 5 > l
Definition: pra_constants.hh:320
PCEvent::scope
PCEventScope * scope
Definition: pc_event.hh:46
PCEventQueue::MapCompare::operator()
bool operator()(Addr pc, PCEvent *const &r) const
Definition: pc_event.hh:87
BreakPCEvent::process
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:123
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
PanicPCEvent
Definition: pc_event.hh:155

Generated on Wed Sep 30 2020 14:02:09 for gem5 by doxygen 1.8.17