remote_gdb.hh revision 14186
111723Sar4jc@virginia.edu/* 211963Sar4jc@virginia.edu * Copyright (c) 2017 The University of Virginia 311963Sar4jc@virginia.edu * Copyright 2015 LabWare 411963Sar4jc@virginia.edu * Copyright 2014 Google, Inc. 511963Sar4jc@virginia.edu * Copyright (c) 2007 The Regents of The University of Michigan 611723Sar4jc@virginia.edu * All rights reserved. 711723Sar4jc@virginia.edu * 811723Sar4jc@virginia.edu * Redistribution and use in source and binary forms, with or without 911723Sar4jc@virginia.edu * modification, are permitted provided that the following conditions are 1011723Sar4jc@virginia.edu * met: redistributions of source code must retain the above copyright 1111723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer; 1211723Sar4jc@virginia.edu * redistributions in binary form must reproduce the above copyright 1311723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer in the 1411723Sar4jc@virginia.edu * documentation and/or other materials provided with the distribution; 1511723Sar4jc@virginia.edu * neither the name of the copyright holders nor the names of its 1611723Sar4jc@virginia.edu * contributors may be used to endorse or promote products derived from 1711723Sar4jc@virginia.edu * this software without specific prior written permission. 1811723Sar4jc@virginia.edu * 1911723Sar4jc@virginia.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2011723Sar4jc@virginia.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2111723Sar4jc@virginia.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2211723Sar4jc@virginia.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2311723Sar4jc@virginia.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2411723Sar4jc@virginia.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2511723Sar4jc@virginia.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2611723Sar4jc@virginia.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2711723Sar4jc@virginia.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2811723Sar4jc@virginia.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2911723Sar4jc@virginia.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3011723Sar4jc@virginia.edu * 3111723Sar4jc@virginia.edu * Authors: Nathan Binkert 3211963Sar4jc@virginia.edu * Boris Shingarov 3311963Sar4jc@virginia.edu * Alec Roelke 3411723Sar4jc@virginia.edu */ 3511723Sar4jc@virginia.edu 3611723Sar4jc@virginia.edu#ifndef __ARCH_RISCV_REMOTE_GDB_HH__ 3711723Sar4jc@virginia.edu#define __ARCH_RISCV_REMOTE_GDB_HH__ 3811723Sar4jc@virginia.edu 3911963Sar4jc@virginia.edu#include <string> 4011963Sar4jc@virginia.edu 4111963Sar4jc@virginia.edu#include "arch/riscv/registers.hh" 4211723Sar4jc@virginia.edu#include "base/remote_gdb.hh" 4311723Sar4jc@virginia.edu 4411723Sar4jc@virginia.educlass System; 4511723Sar4jc@virginia.educlass ThreadContext; 4611723Sar4jc@virginia.edu 4711723Sar4jc@virginia.edunamespace RiscvISA 4811723Sar4jc@virginia.edu{ 4911723Sar4jc@virginia.edu 5011723Sar4jc@virginia.educlass RemoteGDB : public BaseRemoteGDB 5111723Sar4jc@virginia.edu{ 5211963Sar4jc@virginia.edu protected: 5314186Salec.roelke@gmail.com static const int NumGDBRegs = 4162; 5414186Salec.roelke@gmail.com static const int NumCSRs = 4096; 5511963Sar4jc@virginia.edu 5611963Sar4jc@virginia.edu bool acc(Addr addr, size_t len); 5714186Salec.roelke@gmail.com // A breakpoint will be 2 bytes if it is compressed and 4 if not 5814186Salec.roelke@gmail.com bool checkBpLen(size_t len) override { return len == 2 || len == 4; } 5911963Sar4jc@virginia.edu 6011963Sar4jc@virginia.edu class RiscvGdbRegCache : public BaseGdbRegCache 6111963Sar4jc@virginia.edu { 6211963Sar4jc@virginia.edu using BaseGdbRegCache::BaseGdbRegCache; 6311963Sar4jc@virginia.edu private: 6411963Sar4jc@virginia.edu struct { 6513612Sgabeblack@google.com uint64_t gpr[NumIntArchRegs]; 6613612Sgabeblack@google.com uint64_t pc; 6714186Salec.roelke@gmail.com } r; 6811963Sar4jc@virginia.edu public: 6911963Sar4jc@virginia.edu char *data() const { return (char *)&r; } 7011963Sar4jc@virginia.edu size_t size() const { return sizeof(r); } 7111963Sar4jc@virginia.edu void getRegs(ThreadContext*); 7211963Sar4jc@virginia.edu void setRegs(ThreadContext*) const; 7311963Sar4jc@virginia.edu 7411963Sar4jc@virginia.edu const std::string 7511963Sar4jc@virginia.edu name() const 7611963Sar4jc@virginia.edu { 7711963Sar4jc@virginia.edu return gdb->name() + ".RiscvGdbRegCache"; 7811963Sar4jc@virginia.edu } 7911963Sar4jc@virginia.edu }; 8011963Sar4jc@virginia.edu 8112031Sgabeblack@google.com RiscvGdbRegCache regCache; 8211963Sar4jc@virginia.edu 8311723Sar4jc@virginia.edu public: 8412449Sgabeblack@google.com RemoteGDB(System *_system, ThreadContext *tc, int _port); 8511963Sar4jc@virginia.edu BaseGdbRegCache *gdbRegs(); 8611723Sar4jc@virginia.edu}; 8711723Sar4jc@virginia.edu 8811723Sar4jc@virginia.edu} // namespace RiscvISA 8911723Sar4jc@virginia.edu 9011723Sar4jc@virginia.edu#endif /* __ARCH_RISCV_REMOTE_GDB_H__ */ 91