nativetrace.hh revision 6419:2192dac4ad82
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 * Authors: Gabe Black
29 */
30
31#ifndef __ARCH_ARM_NATIVETRACE_HH__
32#define __ARCH_ARM_NATIVETRACE_HH__
33
34#include "base/types.hh"
35#include "cpu/nativetrace.hh"
36#include "params/ArmNativeTrace.hh"
37
38namespace Trace {
39
40class ArmNativeTrace : public NativeTrace
41{
42  public:
43    enum StateID {
44        STATE_R0,
45        STATE_R1,
46        STATE_R2,
47        STATE_R3,
48        STATE_R4,
49        STATE_R5,
50        STATE_R6,
51        STATE_R7,
52        STATE_R8,
53        STATE_R9,
54        STATE_R10,
55        STATE_R11,
56        STATE_FP = STATE_R11,
57        STATE_R12,
58        STATE_R13,
59        STATE_SP = STATE_R13,
60        STATE_R14,
61        STATE_LR = STATE_R14,
62        STATE_R15,
63        STATE_PC = STATE_R15,
64        STATE_CPSR,
65        STATE_NUMVALS
66    };
67
68  protected:
69    struct ThreadState {
70        bool changed[STATE_NUMVALS];
71        uint32_t state[2][STATE_NUMVALS];
72        uint32_t *newState;
73        uint32_t *oldState;
74        int current;
75        void update(NativeTrace *parent);
76        void update(ThreadContext *tc);
77
78        ThreadState()
79        {
80            for (int i = 0; i < STATE_NUMVALS; i++) {
81                changed[i] = false;
82                state[0][i] = state[1][i] = 0;
83                current = 0;
84                newState = state[0];
85                oldState = state[1];
86            }
87        }
88    };
89
90    ThreadState nState, mState;
91
92    bool stopOnPCError;
93
94  public:
95    typedef ArmNativeTraceParams Params;
96
97    const Params *
98    params() const
99    {
100        return dynamic_cast<const Params *>(_params);
101    }
102
103    ArmNativeTrace(const Params *p) :
104        NativeTrace(p), stopOnPCError(p->stop_on_pc_error)
105    {}
106
107    void check(NativeTraceRecord *record);
108};
109
110} /* namespace Trace */
111
112#endif // __ARCH_ARM_NATIVETRACE_HH__
113