gem5  v22.0.0.1
pc_event.cc
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 #include "cpu/pc_event.hh"
30 
31 #include <algorithm>
32 #include <string>
33 #include <utility>
34 
35 #include "base/debug.hh"
36 #include "base/trace.hh"
37 #include "debug/PCEvent.hh"
38 #include "sim/cur_tick.hh"
39 #include "sim/system.hh"
40 
41 namespace gem5
42 {
43 
45 {}
46 
48 {}
49 
50 bool
52 {
53  int removed = 0;
54  range_t range = equal_range(event);
55  iterator i = range.first;
56  while (i != range.second && i != pcMap.end()) {
57  if (*i == event) {
58  DPRINTF(PCEvent, "PC based event removed at %#x: %s\n",
59  event->pc(), event->descr());
60  i = pcMap.erase(i);
61  ++removed;
62  } else {
63  i++;
64  }
65  }
66 
67  return removed > 0;
68 }
69 
70 bool
72 {
73  pcMap.push_back(event);
74  std::sort(pcMap.begin(), pcMap.end(), MapCompare());
75 
76  DPRINTF(PCEvent, "PC based event scheduled for %#x: %s\n",
77  event->pc(), event->descr());
78 
79  return true;
80 }
81 
82 bool
84 {
85  // Using the raw PC address will fail to break on Alpha PALcode addresses,
86  // but that is a rare use case.
87  int serviced = 0;
88  range_t range = equal_range(pc);
89  for (iterator i = range.first; i != range.second; ++i) {
90  DPRINTF(PCEvent, "PC based event serviced at %#x: %s\n",
91  (*i)->pc(), (*i)->descr());
92 
93  (*i)->process(tc);
94  ++serviced;
95  }
96 
97  return serviced > 0;
98 }
99 
100 void
102 {
103  const_iterator i = pcMap.begin();
104  const_iterator e = pcMap.end();
105 
106  for (; i != e; ++i)
107  cprintf("%d: event at %#x: %s\n", curTick(), (*i)->pc(),
108  (*i)->descr());
109 }
110 
113 {
114  return std::equal_range(pcMap.begin(), pcMap.end(), pc, MapCompare());
115 }
116 
117 BreakPCEvent::BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr,
118  bool del)
119  : PCEvent(s, desc, addr), remove(del)
120 {
121 }
122 
123 void
125 {
126  StringWrap name("break_event");
127  DPRINTFN("break event %s triggered\n", descr());
129  if (remove)
130  delete this;
131 }
132 
133 PanicPCEvent::PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc)
134  : PCEvent(s, desc, pc)
135 {
136 }
137 
138 void
140 {
141  StringWrap name("panic_event");
142  panic(descr());
143 }
144 
145 } // namespace gem5
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::BreakPCEvent::remove
bool remove
Definition: pc_event.hh:151
gem5::VegaISA::s
Bitfield< 1 > s
Definition: pagetable.hh:64
gem5::cprintf
void cprintf(const char *format, const Args &...args)
Definition: cprintf.hh:155
system.hh
gem5::PCEventQueue::dump
void dump() const
Definition: pc_event.cc:101
gem5::PCEvent::descr
std::string descr() const
Definition: pc_event.hh:60
gem5::PCEventQueue::~PCEventQueue
~PCEventQueue()
Definition: pc_event.cc:47
gem5::MipsISA::event
Bitfield< 10, 5 > event
Definition: pra_constants.hh:300
cur_tick.hh
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:65
gem5::PCEventQueue::remove
bool remove(PCEvent *event) override
Definition: pc_event.cc:51
gem5::debug::breakpoint
void breakpoint()
Definition: debug.cc:65
gem5::PCEventQueue::schedule
bool schedule(PCEvent *event) override
Definition: pc_event.cc:71
gem5::PanicPCEvent::process
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:139
gem5::PCEventQueue::PCEventQueue
PCEventQueue()
Definition: pc_event.cc:44
gem5::PCEventQueue::iterator
Map::iterator iterator
Definition: pc_event.hh:99
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::PanicPCEvent::PanicPCEvent
PanicPCEvent(PCEventScope *s, const std::string &desc, Addr pc)
Definition: pc_event.cc:133
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:94
gem5::BreakPCEvent::BreakPCEvent
BreakPCEvent(PCEventScope *s, const std::string &desc, Addr addr, bool del=false)
Definition: pc_event.cc:117
gem5::PCEvent::pc
Addr pc() const
Definition: pc_event.hh:61
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::StringWrap
Definition: trace.hh:145
gem5::PCEvent
Definition: pc_event.hh:45
debug.hh
gem5::PCEventQueue::equal_range
range_t equal_range(Addr pc)
Definition: pc_event.cc:112
std::pair
STL pair class.
Definition: stl.hh:58
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::BreakPCEvent::process
virtual void process(ThreadContext *tc)
Definition: pc_event.cc:124
pc_event.hh
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
trace.hh
DPRINTFN
#define DPRINTFN(...)
Definition: trace.hh:214
gem5::PCEventQueue::MapCompare
Definition: pc_event.hh:77
gem5::PCEventQueue::pcMap
Map pcMap
Definition: pc_event.hh:107
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::PCEventQueue::const_iterator
Map::const_iterator const_iterator
Definition: pc_event.hh:100
gem5::PCEventQueue::doService
bool doService(Addr pc, ThreadContext *tc)
Definition: pc_event.cc:83
gem5::PCEventScope
Definition: pc_event.hh:67
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
gem5::PCEvent::name
virtual const std::string name() const
Definition: pc_event.hh:58
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84

Generated on Sat Jun 18 2022 08:12:21 for gem5 by doxygen 1.8.17