tracechild.hh revision 8113
16899SN/A/*
26899SN/A * Copyright (c) 2006 The Regents of The University of Michigan
36899SN/A * All rights reserved.
46899SN/A *
56899SN/A * Redistribution and use in source and binary forms, with or without
66899SN/A * modification, are permitted provided that the following conditions are
76899SN/A * met: redistributions of source code must retain the above copyright
86899SN/A * notice, this list of conditions and the following disclaimer;
96899SN/A * redistributions in binary form must reproduce the above copyright
106899SN/A * notice, this list of conditions and the following disclaimer in the
116899SN/A * documentation and/or other materials provided with the distribution;
126899SN/A * neither the name of the copyright holders nor the names of its
136899SN/A * contributors may be used to endorse or promote products derived from
146899SN/A * this software without specific prior written permission.
156899SN/A *
166899SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176899SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186899SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196899SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206899SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216899SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226899SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236899SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246899SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256899SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266899SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276899SN/A *
286899SN/A * Authors: Gabe Black
296899SN/A */
307632SBrad.Beckmann@amd.com
318232Snate@binkert.org#ifndef REGSTATE_I386_HH
327053SN/A#define REGSTATE_I386_HH
336899SN/A
346899SN/A#include <linux/user.h>
356899SN/A#include <sys/types.h>
367053SN/A#include <sys/ptrace.h>
377053SN/A#include <cassert>
387053SN/A#include <string>
398932SBrad.Beckmann@amd.com
408932SBrad.Beckmann@amd.com#include "base/tracechild.hh"
418932SBrad.Beckmann@amd.com
426899SN/Aclass I386TraceChild : public TraceChild
437053SN/A{
446899SN/A  public:
457053SN/A    enum RegNum
467053SN/A    {
477053SN/A        //GPRs
487053SN/A        EAX, EBX, ECX, EDX,
498164Snilay@cs.wisc.edu        //Index registers
507053SN/A        ESI, EDI,
516899SN/A        //Base pointer and stack pointer
526899SN/A        EBP, ESP,
537053SN/A        //Segmentation registers
547053SN/A        CS, DS, ES, FS, GS, SS,
556899SN/A        //PC
567053SN/A        EIP,
577053SN/A        numregs
586899SN/A    };
597053SN/A  private:
607053SN/A    int64_t getRegs(user_regs_struct & myregs, int num);
617053SN/A    user_regs_struct regs;
627053SN/A    user_regs_struct oldregs;
636899SN/A    bool regDiffSinceUpdate[numregs];
648184Ssomayeh@cs.wisc.edu
658184Ssomayeh@cs.wisc.edu  protected:
668184Ssomayeh@cs.wisc.edu    bool update(int pid);
678184Ssomayeh@cs.wisc.edu
687053SN/A  public:
697053SN/A
707053SN/A    I386TraceChild();
717053SN/A
727053SN/A    int64_t getRegVal(int num);
737053SN/A    int64_t getOldRegVal(int num);
747053SN/A    uint64_t getPC() {return getRegVal(EIP);}
757053SN/A    uint64_t getSP() {return getRegVal(ESP);}
767053SN/A    std::ostream &
776899SN/A    outputStartState(std::ostream & output)
786899SN/A    {
797053SN/A        output << "Printing i386 initial state not yet implemented"
807053SN/A               << std::endl;
816899SN/A        return output;
827053SN/A    }
836899SN/A};
848932SBrad.Beckmann@amd.com
858950Sandreas.hansson@arm.com#endif
866899SN/A