diff --git a/src/arch/arm/fastmodel/SConscript b/src/arch/arm/fastmodel/SConscript index 35c0da1361..9d9d183516 100644 --- a/src/arch/arm/fastmodel/SConscript +++ b/src/arch/arm/fastmodel/SConscript @@ -437,3 +437,4 @@ SimObject('FastModel.py', sim_objects=[ 'AmbaToTlmBridge64', 'AmbaFromTlmBridge64'], tags='arm fastmodel') Source('amba_to_tlm_bridge.cc', tags='arm fastmodel') Source('amba_from_tlm_bridge.cc', tags='arm fastmodel') +Source('remote_gdb.cc', tags='arm fastmodel') diff --git a/src/arch/arm/fastmodel/iris/thread_context.cc b/src/arch/arm/fastmodel/iris/thread_context.cc index 8061d07e75..89ad8b5fe9 100644 --- a/src/arch/arm/fastmodel/iris/thread_context.cc +++ b/src/arch/arm/fastmodel/iris/thread_context.cc @@ -533,6 +533,19 @@ ThreadContext::sendFunctional(PacketPtr pkt) writeMem(id, addr, data, size); } +void +ThreadContext::readMemWithCurrentMsn(Addr vaddr, size_t size, char *data) +{ + readMem(getMemorySpaceId(Iris::CurrentMsn), vaddr, data, size); +} + +void +ThreadContext::writeMemWithCurrentMsn(Addr vaddr, size_t size, + const char *data) +{ + writeMem(getMemorySpaceId(Iris::CurrentMsn), vaddr, data, size); +} + ThreadContext::Status ThreadContext::status() const { diff --git a/src/arch/arm/fastmodel/iris/thread_context.hh b/src/arch/arm/fastmodel/iris/thread_context.hh index 2feb25e405..0f47f43ae6 100644 --- a/src/arch/arm/fastmodel/iris/thread_context.hh +++ b/src/arch/arm/fastmodel/iris/thread_context.hh @@ -461,6 +461,8 @@ class ThreadContext : public gem5::ThreadContext { panic("%s not implemented.", __FUNCTION__); } + void readMemWithCurrentMsn(Addr vaddr, size_t size, char *data); + void writeMemWithCurrentMsn(Addr vaddr, size_t size, const char *data); }; } // namespace Iris diff --git a/src/arch/arm/fastmodel/remote_gdb.cc b/src/arch/arm/fastmodel/remote_gdb.cc new file mode 100644 index 0000000000..e13fee8d70 --- /dev/null +++ b/src/arch/arm/fastmodel/remote_gdb.cc @@ -0,0 +1,61 @@ +/* * Copyright 2022 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "arch/arm/fastmodel/remote_gdb.hh" + +#include "arch/arm/fastmodel/iris/thread_context.hh" + +namespace gem5 { + +namespace fastmodel { + +FastmodelRemoteGDB::FastmodelRemoteGDB(System *_system, int port) + : gem5::ArmISA::RemoteGDB(_system, port) +{ +} + +bool +FastmodelRemoteGDB::readBlob(Addr vaddr, size_t size, char *data) +{ + auto tc = dynamic_cast(context()); + panic_if(!tc, + "FastmodelRemoteGdb can only work on Iris::ThreadContext"); + tc->readMemWithCurrentMsn(vaddr, size, data); + return true; +} + +bool +FastmodelRemoteGDB::writeBlob(Addr vaddr, size_t size, const char *data) +{ + auto tc = dynamic_cast(context()); + panic_if(!tc, + "FastmodelRemoteGdb can only work on Iris::ThreadContext"); + tc->writeMemWithCurrentMsn(vaddr, size, data); + return true; +} + +} // namespace fastmodel +} // namespace gem5 diff --git a/src/arch/arm/fastmodel/remote_gdb.hh b/src/arch/arm/fastmodel/remote_gdb.hh new file mode 100644 index 0000000000..93cf882e21 --- /dev/null +++ b/src/arch/arm/fastmodel/remote_gdb.hh @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __ARCH_ARM_FASTMODEL_REMOTE_GDB_HH__ +#define __ARCH_ARM_FASTMODEL_REMOTE_GDB_HH__ + +#include "arch/arm/remote_gdb.hh" + +namespace gem5 +{ + +namespace fastmodel +{ + +class FastmodelRemoteGDB : public gem5::ArmISA::RemoteGDB +{ + public: + FastmodelRemoteGDB(System *_system, int port); + + private: + bool readBlob(Addr vaddr, size_t size, char *data) override; + bool writeBlob(Addr vaddr, size_t size, const char *data) override; +}; + +} // namespace fastmodel +} // namespace gem5 + +#endif // __ARCH_ARM_FASTMODEL_FASTMODEL_REMOTE_GDB_HH__ diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index 798d09f535..2ca3e61b95 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -720,14 +720,32 @@ BaseRemoteGDB::processCommands(int signum) } } +bool +BaseRemoteGDB::readBlob(Addr vaddr, size_t size, char *data) +{ + (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)) + .readBlob(vaddr, data, size); + return true; +} + +bool +BaseRemoteGDB::writeBlob(Addr vaddr, size_t size, const char *data) +{ + (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)) + .writeBlob(vaddr, data, size); + return true; +} + // Read bytes from kernel address space for debugger. bool BaseRemoteGDB::read(Addr vaddr, size_t size, char *data) { DPRINTF(GDBRead, "read: addr=%#x, size=%d", vaddr, size); - (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)). - readBlob(vaddr, data, size); + bool res = readBlob(vaddr, size, data); + + if (!res) + return false; #if TRACING_ON if (debug::GDBRead) { @@ -756,10 +774,7 @@ BaseRemoteGDB::write(Addr vaddr, size_t size, const char *data) } else DPRINTFNR("\n"); } - (FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)). - writeBlob(vaddr, data, size); - - return true; + return writeBlob(vaddr, size, data); } void diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh index b297e0877f..2c3f6c1303 100644 --- a/src/base/remote_gdb.hh +++ b/src/base/remote_gdb.hh @@ -293,9 +293,10 @@ class BaseRemoteGDB /* * The interface to the simulated system. */ - // Machine memory. - bool read(Addr addr, size_t size, char *data); - bool write(Addr addr, size_t size, const char *data); + virtual bool readBlob(Addr vaddr, size_t size, char *data); + virtual bool writeBlob(Addr vaddr, size_t size, const char *data); + bool read(Addr vaddr, size_t size, char *data); + bool write(Addr vaddr, size_t size, const char *data); template T read(Addr addr); template void write(Addr addr, T data);