tracechild.hh revision 8118
13115SN/A/*
23115SN/A * Copyright (c) 2006 The Regents of The University of Michigan
33115SN/A * All rights reserved.
43115SN/A *
53115SN/A * Redistribution and use in source and binary forms, with or without
63115SN/A * modification, are permitted provided that the following conditions are
73115SN/A * met: redistributions of source code must retain the above copyright
83115SN/A * notice, this list of conditions and the following disclaimer;
93115SN/A * redistributions in binary form must reproduce the above copyright
103115SN/A * notice, this list of conditions and the following disclaimer in the
113115SN/A * documentation and/or other materials provided with the distribution;
123115SN/A * neither the name of the copyright holders nor the names of its
133115SN/A * contributors may be used to endorse or promote products derived from
143115SN/A * this software without specific prior written permission.
153115SN/A *
163115SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
173115SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
183115SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
193115SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
203115SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
213115SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
223115SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
233115SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243115SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253115SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
263115SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273115SN/A *
283115SN/A * Authors: Gabe Black
293115SN/A */
303115SN/A
318117Sgblack@eecs.umich.edu#ifndef REGSTATE_I686_HH
328117Sgblack@eecs.umich.edu#define REGSTATE_I686_HH
333115SN/A
348115SN/A#include <sys/user.h>
353115SN/A#include <sys/types.h>
363115SN/A#include <sys/ptrace.h>
376216SN/A#include <cassert>
383115SN/A#include <string>
393115SN/A
408113SN/A#include "base/tracechild.hh"
413115SN/A
428117Sgblack@eecs.umich.educlass I686TraceChild : public TraceChild
433115SN/A{
448108SN/A  public:
458108SN/A    enum RegNum
468108SN/A    {
478108SN/A        //GPRs
488108SN/A        EAX, EBX, ECX, EDX,
498108SN/A        //Index registers
508108SN/A        ESI, EDI,
518108SN/A        //Base pointer and stack pointer
528108SN/A        EBP, ESP,
538108SN/A        //Segmentation registers
548108SN/A        CS, DS, ES, FS, GS, SS,
558108SN/A        //PC
568108SN/A        EIP,
578108SN/A        numregs
588108SN/A    };
598108SN/A  private:
608108SN/A    int64_t getRegs(user_regs_struct & myregs, int num);
618108SN/A    user_regs_struct regs;
628108SN/A    user_regs_struct oldregs;
638108SN/A    bool regDiffSinceUpdate[numregs];
643115SN/A
658108SN/A  protected:
668108SN/A    bool update(int pid);
673115SN/A
688108SN/A  public:
693115SN/A
708117Sgblack@eecs.umich.edu    I686TraceChild();
713115SN/A
728108SN/A    int64_t getRegVal(int num);
738108SN/A    int64_t getOldRegVal(int num);
748108SN/A    uint64_t getPC() {return getRegVal(EIP);}
758108SN/A    uint64_t getSP() {return getRegVal(ESP);}
768118Sgblack@eecs.umich.edu    bool sendState(int socket);
778108SN/A    std::ostream &
788108SN/A    outputStartState(std::ostream & output)
798108SN/A    {
808117Sgblack@eecs.umich.edu        output << "Printing i686 initial state not yet implemented"
818108SN/A               << std::endl;
828108SN/A        return output;
838108SN/A    }
843115SN/A};
853115SN/A
863115SN/A#endif
87