2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
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.
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.
28 * Authors: Nathan Binkert
32 #include "cpu/pc_event.hh"
38 #include "base/debug.hh"
39 #include "base/trace.hh"
40 #include "debug/PCEvent.hh"
41 #include "sim/core.hh"
42 #include "sim/system.hh"
46 PCEventQueue::PCEventQueue()
49 PCEventQueue::~PCEventQueue()
53 PCEventQueue::remove(PCEvent
*event
)
56 range_t range
= equal_range(event
);
57 iterator i
= range
.first
;
58 while (i
!= range
.second
&& i
!= pcMap
.end()) {
60 DPRINTF(PCEvent
, "PC based event removed at %#x: %s\n",
61 event
->pc(), event
->descr());
73 PCEventQueue::schedule(PCEvent
*event
)
75 pcMap
.push_back(event
);
76 sort(pcMap
.begin(), pcMap
.end(), MapCompare());
78 DPRINTF(PCEvent
, "PC based event scheduled for %#x: %s\n",
79 event
->pc(), event
->descr());
85 PCEventQueue::doService(Addr pc
, ThreadContext
*tc
)
87 // Using the raw PC address will fail to break on Alpha PALcode addresses,
88 // but that is a rare use case.
90 range_t range
= equal_range(pc
);
91 for (iterator i
= range
.first
; i
!= range
.second
; ++i
) {
92 DPRINTF(PCEvent
, "PC based event serviced at %#x: %s\n",
93 (*i
)->pc(), (*i
)->descr());
103 PCEventQueue::dump() const
105 const_iterator i
= pcMap
.begin();
106 const_iterator e
= pcMap
.end();
109 cprintf("%d: event at %#x: %s\n", curTick(), (*i
)->pc(),
113 PCEventQueue::range_t
114 PCEventQueue::equal_range(Addr pc
)
116 return std::equal_range(pcMap
.begin(), pcMap
.end(), pc
, MapCompare());
119 BreakPCEvent::BreakPCEvent(PCEventScope
*s
, const std::string
&desc
, Addr addr
,
121 : PCEvent(s
, desc
, addr
), remove(del
)
126 BreakPCEvent::process(ThreadContext
*tc
)
128 StringWrap
name("break_event");
129 DPRINTFN("break event %s triggered\n", descr());
135 PanicPCEvent::PanicPCEvent(PCEventScope
*s
, const std::string
&desc
, Addr pc
)
136 : PCEvent(s
, desc
, pc
)
141 PanicPCEvent::process(ThreadContext
*tc
)
143 StringWrap
name("panic_event");