From 9e4d0fd483ff312734c1c56a52a8acb1aa624d28 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 31 Jul 2016 20:24:58 -0400 Subject: [PATCH] libdebugger: Implement remaining remote request/response pairs. --- .../remote/RemoteDebugRequest.cpp | 171 ++++++++++++++++++ .../remote/RemoteDebugRequest.h | 79 ++++++++ 2 files changed, 250 insertions(+) diff --git a/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.cpp b/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.cpp index 8fb62c86af..72a76a97dd 100644 --- a/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.cpp +++ b/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.cpp @@ -608,6 +608,177 @@ RemoteDebugSetCpuStateRequest::SaveSpecificInfoToMessage( } +// #pragma mark - RemoteDebugAddressActionRequest + + +RemoteDebugAddressActionRequest::RemoteDebugAddressActionRequest() + : + RemoteDebugRequest(), + fAddress(0) +{ +} + + +RemoteDebugAddressActionRequest::~RemoteDebugAddressActionRequest() +{ +} + + +void +RemoteDebugAddressActionRequest::SetTo(target_addr_t address) +{ + fAddress = address; +} + + +status_t +RemoteDebugAddressActionRequest::LoadSpecificInfoFromMessage( + const BMessage& data) +{ + return data.FindUInt64("address", &fAddress); +} + + +status_t +RemoteDebugAddressActionRequest::SaveSpecificInfoToMessage( + BMessage& _output) const +{ + return _output.AddUInt64("address", fAddress); +} + + +// #pragma mark - RemoteDebugInstallBreakpointRequest + + +RemoteDebugInstallBreakpointRequest::RemoteDebugInstallBreakpointRequest() + : + RemoteDebugAddressActionRequest() +{ +} + + +RemoteDebugInstallBreakpointRequest::~RemoteDebugInstallBreakpointRequest() +{ +} + + +remote_request_type +RemoteDebugInstallBreakpointRequest::Type() const +{ + return REMOTE_REQUEST_TYPE_INSTALL_BREAKPOINT; +} + + +// #pragma mark - RemoteDebugUninstallBreakpointRequest + + +RemoteDebugUninstallBreakpointRequest::RemoteDebugUninstallBreakpointRequest() + : + RemoteDebugAddressActionRequest() +{ +} + + +RemoteDebugUninstallBreakpointRequest::~RemoteDebugUninstallBreakpointRequest() +{ +} + +remote_request_type +RemoteDebugUninstallBreakpointRequest::Type() const +{ + return REMOTE_REQUEST_TYPE_UNINSTALL_BREAKPOINT; +} + + +// #pragma mark - RemoteDebugInstallWatchpointRequest + + +RemoteDebugInstallWatchpointRequest::RemoteDebugInstallWatchpointRequest() + : + RemoteDebugRequest(), + fAddress(0), + fWatchType(B_DATA_READ_WATCHPOINT), + fLength(0) +{ +} + + +RemoteDebugInstallWatchpointRequest::~RemoteDebugInstallWatchpointRequest() +{ +} + + +void +RemoteDebugInstallWatchpointRequest::SetTo(target_addr_t address, uint32 type, + int32 length) +{ + fAddress = address; + fWatchType = type; + fLength = length; +} + + +remote_request_type +RemoteDebugInstallWatchpointRequest::Type() const +{ + return REMOTE_REQUEST_TYPE_INSTALL_WATCHPOINT; +} + + +status_t +RemoteDebugInstallWatchpointRequest::LoadSpecificInfoFromMessage( + const BMessage& data) +{ + status_t error = data.FindUInt64("address", &fAddress); + if (error != B_OK) + return error; + + error = data.FindUInt32("watchtype", &fWatchType); + if (error != B_OK) + return error; + + return data.FindInt32("length", &fLength); +} + + +status_t +RemoteDebugInstallWatchpointRequest::SaveSpecificInfoToMessage( + BMessage& _output) const +{ + status_t error = _output.AddUInt64("address", fAddress); + if (error != B_OK) + return error; + + error = _output.AddUInt32("watchtype", fWatchType); + if (error != B_OK) + return error; + + return _output.AddInt32("length", fLength); +} + + +// #pragma mark - RemoteDebugUninstallWatchpointRequest + + +RemoteDebugUninstallWatchpointRequest::RemoteDebugUninstallWatchpointRequest() + : + RemoteDebugAddressActionRequest() +{ +} + + +RemoteDebugUninstallWatchpointRequest::~RemoteDebugUninstallWatchpointRequest() +{ +} + + +remote_request_type +RemoteDebugUninstallWatchpointRequest::Type() const +{ + return REMOTE_REQUEST_TYPE_UNINSTALL_WATCHPOINT; +} + + // #pragma mark - RemoteDebugReadMemoryResponse diff --git a/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.h b/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.h index 71f819d535..3c1de365e5 100644 --- a/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.h +++ b/src/kits/debugger/debugger_interface/remote/RemoteDebugRequest.h @@ -296,6 +296,85 @@ private: }; +// abstract base for the various actions that influence how the CPU +// reacts to a particular memory address, ergo break/watchpoints. +class RemoteDebugAddressActionRequest : public RemoteDebugRequest { +public: + RemoteDebugAddressActionRequest(); + virtual ~RemoteDebugAddressActionRequest(); + + void SetTo(target_addr_t address); + + target_addr_t Address() const { return fAddress; } + +protected: + virtual status_t LoadSpecificInfoFromMessage( + const BMessage& data); + virtual status_t SaveSpecificInfoToMessage( + BMessage& _output) const; + +private: + target_addr_t fAddress; +}; + + +class RemoteDebugInstallBreakpointRequest + : public RemoteDebugAddressActionRequest { +public: + RemoteDebugInstallBreakpointRequest(); + virtual ~RemoteDebugInstallBreakpointRequest(); + + virtual remote_request_type Type() const; +}; + + +class RemoteDebugUninstallBreakpointRequest + : public RemoteDebugAddressActionRequest { +public: + RemoteDebugUninstallBreakpointRequest(); + virtual ~RemoteDebugUninstallBreakpointRequest(); + + virtual remote_request_type Type() const; +}; + + +class RemoteDebugInstallWatchpointRequest : public RemoteDebugRequest { +public: + RemoteDebugInstallWatchpointRequest(); + virtual ~RemoteDebugInstallWatchpointRequest(); + + void SetTo(target_addr_t address, uint32 type, + int32 length); + + target_addr_t Address() const { return fAddress; } + uint32 WatchType() const { return fWatchType; } + int32 Length() const { return fLength; } + + virtual remote_request_type Type() const; + +protected: + virtual status_t LoadSpecificInfoFromMessage( + const BMessage& data); + virtual status_t SaveSpecificInfoToMessage( + BMessage& _output) const; + +private: + target_addr_t fAddress; + uint32 fWatchType; + int32 fLength; +}; + + +class RemoteDebugUninstallWatchpointRequest + : public RemoteDebugAddressActionRequest { +public: + RemoteDebugUninstallWatchpointRequest(); + virtual ~RemoteDebugUninstallWatchpointRequest(); + + virtual remote_request_type Type() const; +}; + + // #pragma mark - Responses