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 REGSTATE_I686_HH
32#define REGSTATE_I686_HH
33
34#include <sys/ptrace.h>
35#include <sys/types.h>
36#include <sys/user.h>
37
38#include <cassert>
39#include <string>
40
41#include "base/tracechild.hh"
42
43class I686TraceChild : public TraceChild
44{
45  public:
46    enum RegNum
47    {
48        //GPRs
49        EAX, EBX, ECX, EDX,
50        //Index registers
51        ESI, EDI,
52        //Base pointer and stack pointer
53        EBP, ESP,
54        //Segmentation registers
55        CS, DS, ES, FS, GS, SS,
56        //PC
57        EIP,
58        numregs
59    };
60  private:
61    int64_t getRegs(user_regs_struct & myregs, int num);
62    user_regs_struct regs;
63    user_regs_struct oldregs;
64    bool regDiffSinceUpdate[numregs];
65
66  protected:
67    bool update(int pid);
68
69  public:
70
71    I686TraceChild();
72
73    int64_t getRegVal(int num);
74    int64_t getOldRegVal(int num);
75    uint64_t getPC() {return getRegVal(EIP);}
76    uint64_t getSP() {return getRegVal(ESP);}
77    bool sendState(int socket);
78    std::ostream &
79    outputStartState(std::ostream & output)
80    {
81        output << "Printing i686 initial state not yet implemented"
82               << std::endl;
83        return output;
84    }
85};
86
87#endif
88