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.
29 #include "cpu/pc_event.hh"
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"
43 PCEventQueue::PCEventQueue()
46 PCEventQueue::~PCEventQueue()
50 PCEventQueue::remove(PCEvent
*event
)
53 range_t range
= equal_range(event
);
54 iterator i
= range
.first
;
55 while (i
!= range
.second
&& i
!= pcMap
.end()) {
57 DPRINTF(PCEvent
, "PC based event removed at %#x: %s\n",
58 event
->pc(), event
->descr());
70 PCEventQueue::schedule(PCEvent
*event
)
72 pcMap
.push_back(event
);
73 sort(pcMap
.begin(), pcMap
.end(), MapCompare());
75 DPRINTF(PCEvent
, "PC based event scheduled for %#x: %s\n",
76 event
->pc(), event
->descr());
82 PCEventQueue::doService(Addr pc
, ThreadContext
*tc
)
84 // Using the raw PC address will fail to break on Alpha PALcode addresses,
85 // but that is a rare use case.
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());
100 PCEventQueue::dump() const
102 const_iterator i
= pcMap
.begin();
103 const_iterator e
= pcMap
.end();
106 cprintf("%d: event at %#x: %s\n", curTick(), (*i
)->pc(),
110 PCEventQueue::range_t
111 PCEventQueue::equal_range(Addr pc
)
113 return std::equal_range(pcMap
.begin(), pcMap
.end(), pc
, MapCompare());
116 BreakPCEvent::BreakPCEvent(PCEventScope
*s
, const std::string
&desc
, Addr addr
,
118 : PCEvent(s
, desc
, addr
), remove(del
)
123 BreakPCEvent::process(ThreadContext
*tc
)
125 StringWrap
name("break_event");
126 DPRINTFN("break event %s triggered\n", descr());
132 PanicPCEvent::PanicPCEvent(PCEventScope
*s
, const std::string
&desc
, Addr pc
)
133 : PCEvent(s
, desc
, pc
)
138 PanicPCEvent::process(ThreadContext
*tc
)
140 StringWrap
name("panic_event");