tracechild.hh revision 8113
16019SN/A/*
26019SN/A * Copyright (c) 2010 ARM Limited
36019SN/A * All rights reserved
46019SN/A *
56019SN/A * The license below extends only to copyright in the software and shall
66019SN/A * not be construed as granting a license to any other intellectual
76019SN/A * property including but not limited to intellectual property relating
86019SN/A * to a hardware implementation of the functionality of the software
96019SN/A * licensed hereunder.  You may use the software subject to the license
106019SN/A * terms below provided that you ensure that this notice is replicated
116019SN/A * unmodified and in its entirety in all distributions of the software,
126019SN/A * modified or unmodified, in source code or in binary form.
136019SN/A *
146019SN/A * Copyright (c) 2009 The Regents of The University of Michigan
156019SN/A * All rights reserved.
166019SN/A *
176019SN/A * Redistribution and use in source and binary forms, with or without
186019SN/A * modification, are permitted provided that the following conditions are
196019SN/A * met: redistributions of source code must retain the above copyright
206019SN/A * notice, this list of conditions and the following disclaimer;
216019SN/A * redistributions in binary form must reproduce the above copyright
226019SN/A * notice, this list of conditions and the following disclaimer in the
236019SN/A * documentation and/or other materials provided with the distribution;
246019SN/A * neither the name of the copyright holders nor the names of its
256019SN/A * contributors may be used to endorse or promote products derived from
266019SN/A * this software without specific prior written permission.
276019SN/A *
286019SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
296019SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
306019SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
316329Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
326329Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
336019SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
346329Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
356717Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
366329Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
376328SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
386329Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
396328SN/A *
406329Sgblack@eecs.umich.edu * Authors: Ali Saidi
416329Sgblack@eecs.umich.edu *          Gabe Black
426328SN/A */
437310Sgblack@eecs.umich.edu
446328SN/A#ifndef TRACECHILD_ARM_HH
456329Sgblack@eecs.umich.edu#define TRACECHILD_ARM_HH
466328SN/A
476329Sgblack@eecs.umich.edu#include <cassert>
486329Sgblack@eecs.umich.edu#include <string>
496329Sgblack@eecs.umich.edu#include <sys/user.h>
506328SN/A#include <sys/ptrace.h>
516329Sgblack@eecs.umich.edu#include "base/tracechild.hh"
526329Sgblack@eecs.umich.edu
536328SN/A
546329Sgblack@eecs.umich.educlass ARMTraceChild : public TraceChild
556717Sgblack@eecs.umich.edu{
567177Sgblack@eecs.umich.edu  public:
577177Sgblack@eecs.umich.edu    enum RegNum
587592SAli.Saidi@ARM.com    {
596328SN/A        // r0 - r3 argument, temp, caller save
606717Sgblack@eecs.umich.edu        // r4 - r10 callee save
616329Sgblack@eecs.umich.edu        // r11 - FP
626328SN/A        // r12 - temp
636329Sgblack@eecs.umich.edu        // r13 - stack
646328SN/A        // r14 - link
656328SN/A        // r15 - pc
666329Sgblack@eecs.umich.edu        R0, R1, R2, R3, R4, R5, R6, R7,
676329Sgblack@eecs.umich.edu        R8, R9, R10, FP, R12, SP, LR, PC,
686329Sgblack@eecs.umich.edu        CPSR,
696329Sgblack@eecs.umich.edu        numregs
706329Sgblack@eecs.umich.edu    };
716329Sgblack@eecs.umich.edu  private:
726329Sgblack@eecs.umich.edu    uint32_t getRegs(user_regs& myregs, int num);
736329Sgblack@eecs.umich.edu    user_regs regs;
746329Sgblack@eecs.umich.edu    user_regs oldregs;
756717Sgblack@eecs.umich.edu    bool regDiffSinceUpdate[numregs];
766717Sgblack@eecs.umich.edu    bool foundMvn;
776717Sgblack@eecs.umich.edu
786328SN/A  protected:
796717Sgblack@eecs.umich.edu    bool update(int pid);
806328SN/A
816329Sgblack@eecs.umich.edu  public:
826329Sgblack@eecs.umich.edu    ARMTraceChild();
836329Sgblack@eecs.umich.edu    bool sendState(int socket);
846328SN/A
856329Sgblack@eecs.umich.edu    int64_t getRegVal(int num);
867498Sgblack@eecs.umich.edu    int64_t getOldRegVal(int num);
876329Sgblack@eecs.umich.edu
886329Sgblack@eecs.umich.edu    bool step();
896329Sgblack@eecs.umich.edu
906329Sgblack@eecs.umich.edu    uint64_t
916329Sgblack@eecs.umich.edu    getPC()
926329Sgblack@eecs.umich.edu    {
936329Sgblack@eecs.umich.edu        return getRegVal(PC);
946329Sgblack@eecs.umich.edu    }
956329Sgblack@eecs.umich.edu
966329Sgblack@eecs.umich.edu    uint64_t
976329Sgblack@eecs.umich.edu    getSP()
986329Sgblack@eecs.umich.edu    {
996329Sgblack@eecs.umich.edu        return getRegVal(SP);
1006329Sgblack@eecs.umich.edu    }
1016329Sgblack@eecs.umich.edu
1026329Sgblack@eecs.umich.edu    std::ostream & outputStartState(std::ostream & os);
1036329Sgblack@eecs.umich.edu
1046329Sgblack@eecs.umich.edu};
1056329Sgblack@eecs.umich.edu
1066329Sgblack@eecs.umich.edu#endif
1076329Sgblack@eecs.umich.edu
1086329Sgblack@eecs.umich.edu