2 * Copyright (c) 2006 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.
31 #include "base/annotate.hh"
32 #include "base/callback.hh"
33 #include "base/output.hh"
34 #include "base/trace.hh"
35 #include "sim/core.hh"
36 #include "sim/sim_exit.hh"
37 #include "sim/system.hh"
41 class AnnotateDumpCallback
: public Callback
44 virtual void process();
48 AnnotateDumpCallback::process()
50 Annotate::annotations
.dump();
60 registerExitCallback(new AnnotateDumpCallback
);
64 Annotate::add(System
*sys
, Addr stack
, uint32_t sm
, uint32_t st
,
65 uint32_t wm
, uint32_t ws
)
69 an
= new AnnotateData
;
72 std::map
<System
*, std::string
>::iterator i
= nameCache
.find(sys
);
73 if (i
== nameCache
.end()) {
74 nameCache
[sys
] = sys
->name();
77 an
->system
= nameCache
[sys
];
79 an
->stateMachine
= sm
;
86 DPRINTF(Annotate
, "Annotating: %s(%#llX) %d:%d waiting on %d:%d\n",
87 an
->system
, an
->stack
, an
->stateMachine
, an
->curState
,
88 an
->waitMachine
, an
->waitState
);
90 DPRINTF(Annotate
, "Annotating: %s(%#llX) %d:%d beginning\n", an
->system
,
91 an
->stack
, an
->stateMachine
, an
->curState
);
93 DPRINTF(Annotate
, "Now %d events on list\n", data
.size());
101 std::list
<AnnotateData
*>::iterator i
;
108 std::ostream
*os
= simout
.create("annotate.dat");
112 while (i
!= data
.end()) {
113 DPRINTF(Annotate
, "Writing\n", data
.size());
115 ccprintf(*os
, "%d %s(%#llX) %d %d %d %d\n", an
->time
, an
->system
,
116 an
->stack
, an
->stateMachine
, an
->curState
, an
->waitMachine
,
122 } //namespace Annotate