remote_gdb.hh revision 8544
13963Sgblack@eecs.umich.edu/*
25254Sksewell@umich.edu * Copyright (c) 2007 The Regents of The University of Michigan
35254Sksewell@umich.edu * All rights reserved.
43963Sgblack@eecs.umich.edu *
55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are
75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
145254Sksewell@umich.edu * this software without specific prior written permission.
153963Sgblack@eecs.umich.edu *
165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273963Sgblack@eecs.umich.edu *
285254Sksewell@umich.edu * Authors: Nathan Binkert
293963Sgblack@eecs.umich.edu */
303963Sgblack@eecs.umich.edu
313963Sgblack@eecs.umich.edu#ifndef __ARCH_MIPS_REMOTE_GDB_HH__
323963Sgblack@eecs.umich.edu#define __ARCH_MIPS_REMOTE_GDB_HH__
333963Sgblack@eecs.umich.edu
348544Sguodeyuan@tsinghua.org.cn#include "arch/mips/registers.hh"
358544Sguodeyuan@tsinghua.org.cn#include "base/bitfield.hh"
363963Sgblack@eecs.umich.edu#include "base/remote_gdb.hh"
373963Sgblack@eecs.umich.edu
388544Sguodeyuan@tsinghua.org.cnclass System;
398544Sguodeyuan@tsinghua.org.cnclass ThreadContext;
408544Sguodeyuan@tsinghua.org.cnclass PhysicalMemory;
418544Sguodeyuan@tsinghua.org.cn
423963Sgblack@eecs.umich.edunamespace MipsISA
433963Sgblack@eecs.umich.edu{
448544Sguodeyuan@tsinghua.org.cn
458544Sguodeyuan@tsinghua.org.cn    // The number of special regs depends on gdb.
468544Sguodeyuan@tsinghua.org.cn    // Two 32-bit regs are packed into one 64-bit reg.
478544Sguodeyuan@tsinghua.org.cn    const int GdbIntArchRegs = NumIntArchRegs / 2;
488544Sguodeyuan@tsinghua.org.cn    const int GdbIntSpecialRegs = 6 / 2;
498544Sguodeyuan@tsinghua.org.cn    const int GdbFloatArchRegs = NumFloatArchRegs / 2;
508544Sguodeyuan@tsinghua.org.cn    const int GdbFloatSpecialRegs = 2 / 2;
518544Sguodeyuan@tsinghua.org.cn
528544Sguodeyuan@tsinghua.org.cn    const int GdbIntRegs = GdbIntArchRegs + GdbIntSpecialRegs;
538544Sguodeyuan@tsinghua.org.cn    const int GdbFloatRegs = GdbFloatArchRegs + GdbFloatSpecialRegs;
548544Sguodeyuan@tsinghua.org.cn    const int GdbNumRegs = GdbIntRegs + GdbFloatRegs;
558544Sguodeyuan@tsinghua.org.cn
563963Sgblack@eecs.umich.edu    class RemoteGDB : public BaseRemoteGDB
573963Sgblack@eecs.umich.edu    {
588544Sguodeyuan@tsinghua.org.cn      protected:
598544Sguodeyuan@tsinghua.org.cn        Addr notTakenBkpt;
608544Sguodeyuan@tsinghua.org.cn        Addr takenBkpt;
618544Sguodeyuan@tsinghua.org.cn
623963Sgblack@eecs.umich.edu      public:
638544Sguodeyuan@tsinghua.org.cn        RemoteGDB(System *_system, ThreadContext *tc);
643963Sgblack@eecs.umich.edu
658544Sguodeyuan@tsinghua.org.cn      protected:
668544Sguodeyuan@tsinghua.org.cn        bool acc(Addr addr, size_t len);
673963Sgblack@eecs.umich.edu
688544Sguodeyuan@tsinghua.org.cn        void getregs();
698544Sguodeyuan@tsinghua.org.cn        void setregs();
703963Sgblack@eecs.umich.edu
718544Sguodeyuan@tsinghua.org.cn        void clearSingleStep();
728544Sguodeyuan@tsinghua.org.cn        void setSingleStep();
733963Sgblack@eecs.umich.edu
748544Sguodeyuan@tsinghua.org.cn      private:
758544Sguodeyuan@tsinghua.org.cn        uint64_t
768544Sguodeyuan@tsinghua.org.cn        pack(uint32_t lo, uint32_t hi)
778544Sguodeyuan@tsinghua.org.cn        {
788544Sguodeyuan@tsinghua.org.cn            return static_cast<uint64_t>(hi) << 32 | lo;
798544Sguodeyuan@tsinghua.org.cn        }
808544Sguodeyuan@tsinghua.org.cn        uint32_t
818544Sguodeyuan@tsinghua.org.cn        unpackLo(uint64_t val)
828544Sguodeyuan@tsinghua.org.cn        {
838544Sguodeyuan@tsinghua.org.cn            return bits(val, 31, 0);
848544Sguodeyuan@tsinghua.org.cn        }
858544Sguodeyuan@tsinghua.org.cn        uint32_t
868544Sguodeyuan@tsinghua.org.cn        unpackHi(uint64_t val)
878544Sguodeyuan@tsinghua.org.cn        {
888544Sguodeyuan@tsinghua.org.cn            return bits(val, 63, 32);
898544Sguodeyuan@tsinghua.org.cn        }
903963Sgblack@eecs.umich.edu    };
913963Sgblack@eecs.umich.edu}
923963Sgblack@eecs.umich.edu
938544Sguodeyuan@tsinghua.org.cn#endif /* __ARCH_MIPS_REMOTE_GDB_H__ */
94