gem5 v24.1.0.1
Loading...
Searching...
No Matches
exetrace.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, 2019, 2023 Arm Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2001-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#include "cpu/exetrace.hh"
42
43#include <iomanip>
44#include <sstream>
45
46#include "arch/generic/mmu.hh"
47#include "base/loader/symtab.hh"
48#include "cpu/base.hh"
49#include "cpu/static_inst.hh"
50#include "cpu/thread_context.hh"
51#include "debug/ExecAll.hh"
52#include "debug/FmtTicksOff.hh"
53#include "enums/OpClass.hh"
54
55namespace gem5
56{
57
58namespace trace {
59
60void
62{
63 std::stringstream outs;
64
65 const bool in_user_mode = thread->getIsaPtr()->inUserMode();
66 if (in_user_mode && !debug::ExecUser)
67 return;
68 if (!in_user_mode && !debug::ExecKernel)
69 return;
70
71 if (debug::ExecAsid) {
72 outs << "A" << std::dec <<
74 }
75
76 if (debug::ExecThread)
77 outs << "T" << thread->threadId() << " : ";
78
79 Addr cur_pc = thread->getMMUPtr()->getValidAddr(
80 pc->instAddr(), thread, BaseMMU::Execute);
82 ccprintf(outs, "%#x", cur_pc);
83 if (debug::ExecSymbol && (!FullSystem || !in_user_mode) &&
84 (it = loader::debugSymbolTable.findNearest(cur_pc)) !=
86 Addr delta = cur_pc - it->address();
87 if (delta)
88 ccprintf(outs, " @%s+%d", it->name(), delta);
89 else
90 ccprintf(outs, " @%s", it->name());
91 }
92
93 if (inst->isMicroop()) {
94 ccprintf(outs, ".%2d", pc->microPC());
95 } else {
96 ccprintf(outs, " ");
97 }
98
99 ccprintf(outs, " : ");
100
101 //
102 // Print decoded instruction
103 //
104
105 outs << std::setw(26) << std::left;
107
108 if (ran) {
109 outs << " : ";
110
111 if (debug::ExecOpClass) {
112 outs << enums::OpClassStrings[inst->opClass()] << " : ";
113 }
114
115 if (debug::ExecResult && !predicate) {
116 outs << "Predicated False";
117 }
118
119 if (debug::ExecResult && dataStatus != DataInvalid) {
120 if (dataStatus == DataReg) {
121 if (vectorLengthInBytes > 0 && inst->isVector()) {
122 outs << " D=" << data.asReg.asString(vectorLengthInBytes);
123 } else {
124 ccprintf(outs, " D=%s", data.asReg.asString());
125 }
126 } else {
127 ccprintf(outs, " D=%#018x", data.asInt);
128 }
129 }
130
131 if (debug::ExecEffAddr && getMemValid())
132 outs << " A=0x" << std::hex << addr;
133
134 if (debug::ExecFetchSeq && fetch_seq_valid)
135 outs << " FetchSeq=" << std::dec << fetch_seq;
136
137 if (debug::ExecCPSeq && cp_seq_valid)
138 outs << " CPSeq=" << std::dec << cp_seq;
139
140 if (debug::ExecFlags) {
141 outs << " flags=(";
142 inst->printFlags(outs, "|");
143 outs << ")";
144 }
145 }
146
147 //
148 // End of line...
149 //
150 outs << std::endl;
151
153 when, thread->getCpuPtr()->name(), "ExecEnable", "%s",
154 outs.str().c_str());
155}
156
157void
159{
160 /*
161 * The behavior this check tries to achieve is that if ExecMacro is on,
162 * the macroop will be printed. If it's on and microops are also on, it's
163 * printed before the microops start printing to give context. If the
164 * microops aren't printed, then it's printed only when the final microop
165 * finishes. Macroops then behave like regular instructions and don't
166 * complete/print when they fault.
167 */
168 if (debug::ExecMacro && staticInst->isMicroop() &&
169 ((debug::ExecMicro &&
171 (!debug::ExecMicro &&
174 }
175 if (debug::ExecMicro || !staticInst->isMicroop()) {
176 traceInst(staticInst, true);
177 }
178}
179
180} // namespace trace
181} // namespace gem5
virtual bool inUserMode() const =0
virtual uint64_t getExecutingAsid() const
Definition isa.hh:87
virtual Addr getValidAddr(Addr vaddr, ThreadContext *tc, Mode mode)
Definition mmu.cc:132
std::string asString() const
Definition inst_res.hh:170
virtual std::string name() const
Definition named.hh:47
void printFlags(std::ostream &outs, const std::string &separator) const
Print a separator separated list of this instruction's set flag names on the given stream.
OpClass opClass() const
Operation class. Used to select appropriate function unit in issue.
bool isFirstMicroop() const
bool isVector() const
bool isLastMicroop() const
bool isMicroop() const
virtual BaseISA * getIsaPtr() const =0
virtual BaseCPU * getCpuPtr()=0
virtual int threadId() const =0
virtual BaseMMU * getMMUPtr()=0
SymbolVector::const_iterator const_iterator
Definition symtab.hh:272
const ExeTracer & tracer
Definition exetrace.hh:77
void traceInst(const StaticInstPtr &inst, bool ran)
Definition exetrace.cc:61
Addr addr
The address that was accessed.
Definition insttracer.hh:86
StaticInstPtr staticInst
Definition insttracer.hh:71
StaticInstPtr macroStaticInst
Definition insttracer.hh:73
ThreadContext * thread
Definition insttracer.hh:68
std::unique_ptr< PCStateBase > pc
Definition insttracer.hh:72
bool predicate
is the predicate for execution this inst true or false (not execed)?
union gem5::trace::InstRecord::Data data
std::string disassemble(StaticInstPtr inst, const PCStateBase &pc, const loader::SymbolTable *symtab=nullptr) const
void dprintf_flag(Tick when, const std::string &name, const std::string &flag, const char *fmt, const Args &...args)
Log a single message with a flag prefix.
Definition trace.hh:93
bool cp_seq_valid
Are the commit sequence number fields valid?
enum gem5::trace::InstRecord::DataStatus dataStatus
bool fetch_seq_valid
Are the fetch sequence number fields valid?
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
Definition symtab.cc:55
Logger * getDebugLogger()
Get the current global debug logger.
Definition trace.cc:68
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition root.cc:220
void ccprintf(cp::Print &print)
Definition cprintf.hh:130

Generated on Mon Jan 13 2025 04:28:31 for gem5 by doxygen 1.9.8