tracechild.hh revision 7414
17118Sgblack@eecs.umich.edu/*
27118Sgblack@eecs.umich.edu * Copyright (c) 2010 ARM Limited
37118Sgblack@eecs.umich.edu * All rights reserved
47118Sgblack@eecs.umich.edu *
57118Sgblack@eecs.umich.edu * The license below extends only to copyright in the software and shall
67118Sgblack@eecs.umich.edu * not be construed as granting a license to any other intellectual
77118Sgblack@eecs.umich.edu * property including but not limited to intellectual property relating
87118Sgblack@eecs.umich.edu * to a hardware implementation of the functionality of the software
97118Sgblack@eecs.umich.edu * licensed hereunder.  You may use the software subject to the license
107118Sgblack@eecs.umich.edu * terms below provided that you ensure that this notice is replicated
117118Sgblack@eecs.umich.edu * unmodified and in its entirety in all distributions of the software,
127118Sgblack@eecs.umich.edu * modified or unmodified, in source code or in binary form.
137118Sgblack@eecs.umich.edu *
147118Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan
156253Sgblack@eecs.umich.edu * All rights reserved.
166253Sgblack@eecs.umich.edu *
176253Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
186253Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
196253Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
206253Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
216253Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
226253Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
236253Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
246253Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
256253Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
266253Sgblack@eecs.umich.edu * this software without specific prior written permission.
276253Sgblack@eecs.umich.edu *
286253Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
296253Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
306253Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
316253Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
326253Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
336253Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
346253Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
356253Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
366253Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
376253Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
386253Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
396253Sgblack@eecs.umich.edu *
406253Sgblack@eecs.umich.edu * Authors: Ali Saidi
416253Sgblack@eecs.umich.edu *          Gabe Black
426253Sgblack@eecs.umich.edu */
436253Sgblack@eecs.umich.edu
446253Sgblack@eecs.umich.edu#ifndef TRACECHILD_ARM_HH
456253Sgblack@eecs.umich.edu#define TRACECHILD_ARM_HH
466253Sgblack@eecs.umich.edu
476253Sgblack@eecs.umich.edu#include <cassert>
486253Sgblack@eecs.umich.edu#include <string>
497118Sgblack@eecs.umich.edu#include <sys/user.h>
507205Sgblack@eecs.umich.edu#include <sys/ptrace.h>
517205Sgblack@eecs.umich.edu#include "tracechild.hh"
527205Sgblack@eecs.umich.edu
537205Sgblack@eecs.umich.edu
547205Sgblack@eecs.umich.educlass ARMTraceChild : public TraceChild
557205Sgblack@eecs.umich.edu{
567205Sgblack@eecs.umich.edu  public:
577205Sgblack@eecs.umich.edu    enum RegNum
587205Sgblack@eecs.umich.edu    {
597205Sgblack@eecs.umich.edu        // r0 - r3 argument, temp, caller save
607205Sgblack@eecs.umich.edu        // r4 - r10 callee save
617205Sgblack@eecs.umich.edu        // r11 - FP
627205Sgblack@eecs.umich.edu        // r12 - temp
637205Sgblack@eecs.umich.edu        // r13 - stack
647205Sgblack@eecs.umich.edu        // r14 - link
657205Sgblack@eecs.umich.edu        // r15 - pc
667720Sgblack@eecs.umich.edu        R0, R1, R2, R3, R4, R5, R6, R7,
677720Sgblack@eecs.umich.edu        R8, R9, R10, FP, R12, SP, LR, PC,
687720Sgblack@eecs.umich.edu        CPSR,
697720Sgblack@eecs.umich.edu        numregs
707720Sgblack@eecs.umich.edu    };
717720Sgblack@eecs.umich.edu  private:
727720Sgblack@eecs.umich.edu    char printBuffer[256];
737720Sgblack@eecs.umich.edu    static const char *regNames[numregs];
747720Sgblack@eecs.umich.edu    uint32_t getRegs(user_regs& myregs, int num);
757720Sgblack@eecs.umich.edu    user_regs regs;
767720Sgblack@eecs.umich.edu    user_regs oldregs;
777720Sgblack@eecs.umich.edu    bool regDiffSinceUpdate[numregs];
787720Sgblack@eecs.umich.edu    bool foundMvn;
797720Sgblack@eecs.umich.edu
807720Sgblack@eecs.umich.edu  protected:
817720Sgblack@eecs.umich.edu    bool update(int pid);
827720Sgblack@eecs.umich.edu
837720Sgblack@eecs.umich.edu  public:
847720Sgblack@eecs.umich.edu    ARMTraceChild();
857720Sgblack@eecs.umich.edu    bool sendState(int socket);
867291Sgblack@eecs.umich.edu
877720Sgblack@eecs.umich.edu    int getNumRegs()
887291Sgblack@eecs.umich.edu    {
897291Sgblack@eecs.umich.edu        return numregs;
907291Sgblack@eecs.umich.edu    }
917291Sgblack@eecs.umich.edu
927291Sgblack@eecs.umich.edu    bool diffSinceUpdate(int num)
937291Sgblack@eecs.umich.edu    {
947291Sgblack@eecs.umich.edu        assert(num < numregs && num >= 0);
957291Sgblack@eecs.umich.edu        return regDiffSinceUpdate[num];
967291Sgblack@eecs.umich.edu    }
977291Sgblack@eecs.umich.edu
987291Sgblack@eecs.umich.edu    std::string getRegName(int num)
997291Sgblack@eecs.umich.edu    {
1008140SMatt.Horsnell@arm.com        assert(num < numregs && num >= 0);
1018140SMatt.Horsnell@arm.com        return regNames[num];
1027646Sgene.wu@arm.com    }
1037646Sgene.wu@arm.com
1047291Sgblack@eecs.umich.edu    int64_t getRegVal(int num);
1057291Sgblack@eecs.umich.edu    int64_t getOldRegVal(int num);
1067291Sgblack@eecs.umich.edu
1077720Sgblack@eecs.umich.edu    bool step();
1088140SMatt.Horsnell@arm.com
1098140SMatt.Horsnell@arm.com    uint64_t getPC()
1108140SMatt.Horsnell@arm.com    {
1118140SMatt.Horsnell@arm.com            return getRegVal(PC);
1127291Sgblack@eecs.umich.edu    }
1137291Sgblack@eecs.umich.edu
1147646Sgene.wu@arm.com    uint64_t getSP()
1157646Sgene.wu@arm.com    {
1167646Sgene.wu@arm.com            return getRegVal(SP);
1177747SAli.Saidi@ARM.com    }
1187646Sgene.wu@arm.com
1197646Sgene.wu@arm.com    char * printReg(int num);
1207646Sgene.wu@arm.com
1217720Sgblack@eecs.umich.edu    std::ostream & outputStartState(std::ostream & os);
1227646Sgene.wu@arm.com
1237646Sgene.wu@arm.com};
1247646Sgene.wu@arm.com
1257646Sgene.wu@arm.com#endif
1267646Sgene.wu@arm.com
1277291Sgblack@eecs.umich.edu