gem5
v20.1.0.0
cpu
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/core.hh
"
39
#include "
sim/system.hh
"
40
41
using namespace
std
;
42
43
PCEventQueue::PCEventQueue
()
44
{}
45
46
PCEventQueue::~PCEventQueue
()
47
{}
48
49
bool
50
PCEventQueue::remove
(
PCEvent
*
event
)
51
{
52
int
removed = 0;
53
range_t
range = equal_range(
event
);
54
iterator
i
= range.first;
55
while
(
i
!= range.second &&
i
!= pcMap.end()) {
56
if
(*
i
==
event
) {
57
DPRINTF
(
PCEvent
,
"PC based event removed at %#x: %s\n"
,
58
event
->pc(),
event
->descr());
59
i
= pcMap.erase(
i
);
60
++removed;
61
}
else
{
62
i
++;
63
}
64
}
65
66
return
removed > 0;
67
}
68
69
bool
70
PCEventQueue::schedule
(
PCEvent
*
event
)
71
{
72
pcMap.push_back(
event
);
73
sort(pcMap.begin(), pcMap.end(),
MapCompare
());
74
75
DPRINTF
(
PCEvent
,
"PC based event scheduled for %#x: %s\n"
,
76
event
->pc(),
event
->descr());
77
78
return
true
;
79
}
80
81
bool
82
PCEventQueue::doService
(
Addr
pc
,
ThreadContext
*tc)
83
{
84
// Using the raw PC address will fail to break on Alpha PALcode addresses,
85
// but that is a rare use case.
86
int
serviced = 0;
87
range_t
range = equal_range(
pc
);
88
for
(
iterator
i
= range.first;
i
!= range.second; ++
i
) {
89
DPRINTF
(
PCEvent
,
"PC based event serviced at %#x: %s\n"
,
90
(*i)->
pc
(), (*i)->descr());
91
92
(*i)->process(tc);
93
++serviced;
94
}
95
96
return
serviced > 0;
97
}
98
99
void
100
PCEventQueue::dump
()
const
101
{
102
const_iterator
i
= pcMap.begin();
103
const_iterator
e
= pcMap.end();
104
105
for
(;
i
!=
e
; ++
i
)
106
cprintf
(
"%d: event at %#x: %s\n"
,
curTick
(), (*i)->pc(),
107
(*i)->descr());
108
}
109
110
PCEventQueue::range_t
111
PCEventQueue::equal_range
(
Addr
pc
)
112
{
113
return
std::equal_range(pcMap.begin(), pcMap.end(),
pc
,
MapCompare
());
114
}
115
116
BreakPCEvent::BreakPCEvent
(
PCEventScope
*
s
,
const
std::string &desc,
Addr
addr
,
117
bool
del)
118
:
PCEvent
(
s
, desc,
addr
), remove(del)
119
{
120
}
121
122
void
123
BreakPCEvent::process
(
ThreadContext
*tc)
124
{
125
StringWrap
name
(
"break_event"
);
126
DPRINTFN
(
"break event %s triggered\n"
,
descr
());
127
Debug::breakpoint
();
128
if
(
remove
)
129
delete
this
;
130
}
131
132
PanicPCEvent::PanicPCEvent
(
PCEventScope
*
s
,
const
std::string &desc,
Addr
pc
)
133
:
PCEvent
(
s
, desc,
pc
)
134
{
135
}
136
137
void
138
PanicPCEvent::process
(
ThreadContext
*tc)
139
{
140
StringWrap
name
(
"panic_event"
);
141
panic
(
descr
());
142
}
PanicPCEvent::process
virtual void process(ThreadContext *tc)
Definition:
pc_event.cc:138
system.hh
PCEventQueue::equal_range
range_t equal_range(Addr pc)
Definition:
pc_event.cc:111
Debug::breakpoint
void breakpoint()
Definition:
debug.cc:62
ArmISA::i
Bitfield< 7 > i
Definition:
miscregs_types.hh:63
PCEventQueue::iterator
Map::iterator iterator
Definition:
pc_event.hh:95
PCEvent::name
virtual const std::string name() const
Definition:
pc_event.hh:55
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
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
PCEventQueue::doService
bool doService(Addr pc, ThreadContext *tc)
Definition:
pc_event.cc:82
cprintf
void cprintf(const char *format, const Args &...args)
Definition:
cprintf.hh:152
DPRINTF
#define DPRINTF(x,...)
Definition:
trace.hh:234
MipsISA::pc
Bitfield< 4 > pc
Definition:
pra_constants.hh:240
MipsISA::event
Bitfield< 10, 5 > event
Definition:
pra_constants.hh:297
debug.hh
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
core.hh
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
ArmISA::e
Bitfield< 9 > e
Definition:
miscregs_types.hh:61
BreakPCEvent::remove
bool remove
Definition:
pc_event.hh:147
PCEventQueue::const_iterator
Map::const_iterator const_iterator
Definition:
pc_event.hh:96
pc_event.hh
std
Overload hash function for BasicBlockRange type.
Definition:
vec_reg.hh:587
PCEventQueue::remove
bool remove(PCEvent *event) override
Definition:
pc_event.cc:50
addr
ip6_addr_t addr
Definition:
inet.hh:423
PCEventQueue::~PCEventQueue
~PCEventQueue()
Definition:
pc_event.cc:46
StringWrap
Definition:
trace.hh:134
PCEvent
Definition:
pc_event.hh:42
trace.hh
DPRINTFN
#define DPRINTFN(...)
Definition:
trace.hh:238
PCEvent::descr
std::string descr() const
Definition:
pc_event.hh:57
PCEventQueue::dump
void dump() const
Definition:
pc_event.cc:100
ArmISA::s
Bitfield< 4 > s
Definition:
miscregs_types.hh:556
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
curTick
Tick curTick()
The current simulated tick.
Definition:
core.hh:45
Generated on Wed Sep 30 2020 14:02:09 for gem5 by
doxygen
1.8.17