remote_gdb.hh revision 10600
14120Sgblack@eecs.umich.edu/* 210600Sgabeblack@google.com * Copyright 2014 Google, Inc. 34120Sgblack@eecs.umich.edu * Copyright (c) 2007 The Hewlett-Packard Development Company 44120Sgblack@eecs.umich.edu * All rights reserved. 54120Sgblack@eecs.umich.edu * 67087Snate@binkert.org * The license below extends only to copyright in the software and shall 77087Snate@binkert.org * not be construed as granting a license to any other intellectual 87087Snate@binkert.org * property including but not limited to intellectual property relating 97087Snate@binkert.org * to a hardware implementation of the functionality of the software 107087Snate@binkert.org * licensed hereunder. You may use the software subject to the license 117087Snate@binkert.org * terms below provided that you ensure that this notice is replicated 127087Snate@binkert.org * unmodified and in its entirety in all distributions of the software, 137087Snate@binkert.org * modified or unmodified, in source code or in binary form. 144120Sgblack@eecs.umich.edu * 157087Snate@binkert.org * Redistribution and use in source and binary forms, with or without 167087Snate@binkert.org * modification, are permitted provided that the following conditions are 177087Snate@binkert.org * met: redistributions of source code must retain the above copyright 187087Snate@binkert.org * notice, this list of conditions and the following disclaimer; 197087Snate@binkert.org * redistributions in binary form must reproduce the above copyright 207087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 217087Snate@binkert.org * documentation and/or other materials provided with the distribution; 227087Snate@binkert.org * neither the name of the copyright holders nor the names of its 234120Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 247087Snate@binkert.org * this software without specific prior written permission. 254120Sgblack@eecs.umich.edu * 264120Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 274120Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 284120Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 294120Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 304120Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 314120Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 324120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 334120Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 344120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 354120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 364120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 374120Sgblack@eecs.umich.edu * 384120Sgblack@eecs.umich.edu * Authors: Gabe Black 394120Sgblack@eecs.umich.edu */ 404120Sgblack@eecs.umich.edu 414120Sgblack@eecs.umich.edu#ifndef __ARCH_X86_REMOTEGDB_HH__ 424120Sgblack@eecs.umich.edu#define __ARCH_X86_REMOTEGDB_HH__ 434120Sgblack@eecs.umich.edu 4410600Sgabeblack@google.com#include <algorithm> 4510600Sgabeblack@google.com 464144Sgblack@eecs.umich.edu#include "arch/x86/types.hh" 474144Sgblack@eecs.umich.edu#include "base/remote_gdb.hh" 484144Sgblack@eecs.umich.edu 494144Sgblack@eecs.umich.educlass System; 504144Sgblack@eecs.umich.educlass ThreadContext; 514120Sgblack@eecs.umich.edu 524120Sgblack@eecs.umich.edunamespace X86ISA 534120Sgblack@eecs.umich.edu{ 5410600Sgabeblack@google.comclass RemoteGDB : public BaseRemoteGDB 5510600Sgabeblack@google.com{ 5610600Sgabeblack@google.com public: 5710600Sgabeblack@google.com enum 5810600Sgabeblack@google.com { 5910600Sgabeblack@google.com GDB32_EAX, 6010600Sgabeblack@google.com GDB32_ECX, 6110600Sgabeblack@google.com GDB32_EDX, 6210600Sgabeblack@google.com GDB32_EBX, 6310600Sgabeblack@google.com GDB32_ESP, 6410600Sgabeblack@google.com GDB32_EBP, 6510600Sgabeblack@google.com GDB32_ESI, 6610600Sgabeblack@google.com GDB32_EDI, 6710600Sgabeblack@google.com GDB32_EIP, 6810600Sgabeblack@google.com GDB32_EFLAGS, 6910600Sgabeblack@google.com GDB32_CS, 7010600Sgabeblack@google.com GDB32_SS, 7110600Sgabeblack@google.com GDB32_DS, 7210600Sgabeblack@google.com GDB32_ES, 7310600Sgabeblack@google.com GDB32_FS, 7410600Sgabeblack@google.com GDB32_GS, 7510600Sgabeblack@google.com 7610600Sgabeblack@google.com GDB32_NUMREGS 7710600Sgabeblack@google.com }; 7810600Sgabeblack@google.com 7910600Sgabeblack@google.com enum 8010600Sgabeblack@google.com { 8110600Sgabeblack@google.com GDB64_RAX, 8210600Sgabeblack@google.com GDB64_RBX, 8310600Sgabeblack@google.com GDB64_RCX, 8410600Sgabeblack@google.com GDB64_RDX, 8510600Sgabeblack@google.com GDB64_RSI, 8610600Sgabeblack@google.com GDB64_RDI, 8710600Sgabeblack@google.com GDB64_RBP, 8810600Sgabeblack@google.com GDB64_RSP, 8910600Sgabeblack@google.com GDB64_R8, 9010600Sgabeblack@google.com GDB64_R9, 9110600Sgabeblack@google.com GDB64_R10, 9210600Sgabeblack@google.com GDB64_R11, 9310600Sgabeblack@google.com GDB64_R12, 9410600Sgabeblack@google.com GDB64_R13, 9510600Sgabeblack@google.com GDB64_R14, 9610600Sgabeblack@google.com GDB64_R15, 9710600Sgabeblack@google.com GDB64_RIP, 9810600Sgabeblack@google.com // These indices index into the reg cache treated as an array of 32 9910600Sgabeblack@google.com // bit integers. The next index is one beyond the previous, and then 10010600Sgabeblack@google.com // scaled up from an index into an array of 64 bit integers. 10110600Sgabeblack@google.com GDB64_RFLAGS_32 = (GDB64_RIP + 1) * 2, 10210600Sgabeblack@google.com GDB64_CS_32, 10310600Sgabeblack@google.com GDB64_SS_32, 10410600Sgabeblack@google.com GDB64_DS_32, 10510600Sgabeblack@google.com GDB64_ES_32, 10610600Sgabeblack@google.com GDB64_FS_32, 10710600Sgabeblack@google.com GDB64_GS_32, 10810600Sgabeblack@google.com 10910600Sgabeblack@google.com // Scale the end index count back down (rounded up) to be for an 11010600Sgabeblack@google.com // array of 64 bit integers. 11110600Sgabeblack@google.com GDB64_NUMREGS = (GDB64_GS_32 + 1) / 2 + 1 11210600Sgabeblack@google.com }; 11310600Sgabeblack@google.com 11410600Sgabeblack@google.com RemoteGDB(System *system, ThreadContext *context); 11510600Sgabeblack@google.com 11610600Sgabeblack@google.com bool acc(Addr addr, size_t len); 11710600Sgabeblack@google.com 11810600Sgabeblack@google.com protected: 11910600Sgabeblack@google.com class SingleStepEvent : public Event 1204144Sgblack@eecs.umich.edu { 1214144Sgblack@eecs.umich.edu protected: 12210600Sgabeblack@google.com RemoteGDB *gdb; 1234144Sgblack@eecs.umich.edu 1244144Sgblack@eecs.umich.edu public: 12510600Sgabeblack@google.com SingleStepEvent(RemoteGDB *g) : gdb(g) 12610600Sgabeblack@google.com {} 1274144Sgblack@eecs.umich.edu 12810600Sgabeblack@google.com void process(); 12910600Sgabeblack@google.com }; 1304144Sgblack@eecs.umich.edu 13110600Sgabeblack@google.com SingleStepEvent singleStepEvent; 1324144Sgblack@eecs.umich.edu 13310600Sgabeblack@google.com void getregs(); 13410600Sgabeblack@google.com void setregs(); 1354144Sgblack@eecs.umich.edu 13610600Sgabeblack@google.com void clearSingleStep(); 13710600Sgabeblack@google.com void setSingleStep(); 13810600Sgabeblack@google.com 13910600Sgabeblack@google.com bool checkBpLen(size_t len) { return len == 1; } 14010600Sgabeblack@google.com}; 14110600Sgabeblack@google.com 14210600Sgabeblack@google.comconst int GDB_REG_BYTES = 14310600Sgabeblack@google.com std::max(RemoteGDB::GDB32_NUMREGS * sizeof(uint32_t), 14410600Sgabeblack@google.com RemoteGDB::GDB64_NUMREGS * sizeof(uint64_t)); 14510600Sgabeblack@google.com 1464144Sgblack@eecs.umich.edu} 1474120Sgblack@eecs.umich.edu 1484120Sgblack@eecs.umich.edu#endif // __ARCH_X86_REMOTEGDB_HH__ 149