gem5 v24.0.0.0
Loading...
Searching...
No Matches
nativetrace.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006 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
30
31#include "arch/sparc/pcstate.hh"
33#include "cpu/thread_context.hh"
34#include "params/SparcNativeTrace.hh"
35#include "sim/byteswap.hh"
36
37namespace gem5
38{
39
40namespace trace {
41
43 // Global registers
44 "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
45 // Output registers
46 "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7",
47 // Local registers
48 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
49 // Input registers
50 "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
51};
52
53void
55{
56 ThreadContext *tc = record->getThread();
57
58 uint64_t regVal, realRegVal;
59
60 // Integer registers
61
62 // I doubt a real SPARC will describe more integer registers than this.
64 const char **regName = intRegNames;
65 for (int i = 0; i < SparcISA::int_reg::NumArchRegs; i++) {
66 regVal = tc->getReg(SparcISA::intRegClass[i]);
67 read(&realRegVal, sizeof(realRegVal));
68 realRegVal = betoh(realRegVal);
69 checkReg(*(regName++), regVal, realRegVal);
70 }
71
72 auto &pc = tc->pcState().as<SparcISA::PCState>();
73 // PC
74 read(&realRegVal, sizeof(realRegVal));
75 realRegVal = betoh(realRegVal);
76 regVal = pc.npc();
77 checkReg("pc", regVal, realRegVal);
78
79 // NPC
80 read(&realRegVal, sizeof(realRegVal));
81 realRegVal = betoh(realRegVal);
82 regVal = pc.nnpc();
83 checkReg("npc", regVal, realRegVal);
84
85 // CCR
86 read(&realRegVal, sizeof(realRegVal));
87 realRegVal = betoh(realRegVal);
88 regVal = tc->getReg(SparcISA::int_reg::Ccr);
89 checkReg("ccr", regVal, realRegVal);
90}
91
92} // namespace trace
93} // namespace gem5
Target & as()
Definition pcstate.hh:73
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId &reg) const
virtual const PCStateBase & pcState() const =0
ThreadContext * getThread() const
bool checkReg(const char *regName, T &val, T &realVal)
void read(void *ptr, size_t size)
void check(NativeTraceRecord *record)
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 4 > pc
constexpr RegId Ccr
Definition int.hh:132
constexpr RegClass intRegClass
Definition int.hh:78
static const char * intRegNames[SparcISA::int_reg::NumArchRegs]
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
T betoh(T value)
Definition byteswap.hh:175

Generated on Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0