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 348229Snate@binkert.org#include <sys/ptrace.h> 358229Snate@binkert.org#include <sys/types.h> 368115SN/A#include <sys/user.h> 378229Snate@binkert.org 386216SN/A#include <cassert> 393115SN/A#include <string> 403115SN/A 418113SN/A#include "base/tracechild.hh" 423115SN/A 438117Sgblack@eecs.umich.educlass I686TraceChild : public TraceChild 443115SN/A{ 458108SN/A public: 468108SN/A enum RegNum 478108SN/A { 488108SN/A //GPRs 498108SN/A EAX, EBX, ECX, EDX, 508108SN/A //Index registers 518108SN/A ESI, EDI, 528108SN/A //Base pointer and stack pointer 538108SN/A EBP, ESP, 548108SN/A //Segmentation registers 558108SN/A CS, DS, ES, FS, GS, SS, 568108SN/A //PC 578108SN/A EIP, 588108SN/A numregs 598108SN/A }; 608108SN/A private: 618108SN/A int64_t getRegs(user_regs_struct & myregs, int num); 628108SN/A user_regs_struct regs; 638108SN/A user_regs_struct oldregs; 648108SN/A bool regDiffSinceUpdate[numregs]; 653115SN/A 668108SN/A protected: 678108SN/A bool update(int pid); 683115SN/A 698108SN/A public: 703115SN/A 718117Sgblack@eecs.umich.edu I686TraceChild(); 723115SN/A 738108SN/A int64_t getRegVal(int num); 748108SN/A int64_t getOldRegVal(int num); 758108SN/A uint64_t getPC() {return getRegVal(EIP);} 768108SN/A uint64_t getSP() {return getRegVal(ESP);} 778118Sgblack@eecs.umich.edu bool sendState(int socket); 788108SN/A std::ostream & 798108SN/A outputStartState(std::ostream & output) 808108SN/A { 818117Sgblack@eecs.umich.edu output << "Printing i686 initial state not yet implemented" 828108SN/A << std::endl; 838108SN/A return output; 848108SN/A } 853115SN/A}; 863115SN/A 873115SN/A#endif 88