-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb-dap] Add invalidated event #157530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb-dap] Add invalidated event #157530
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ | |
| #define LLDB_TOOLS_LLDB_DAP_EVENTHELPER_H | ||
|
|
||
| #include "DAPForward.h" | ||
| #include "Protocol/ProtocolEvents.h" | ||
| #include "llvm/ADT/ArrayRef.h" | ||
| #include "llvm/Support/Error.h" | ||
|
|
||
| namespace lldb_dap { | ||
|
|
@@ -32,6 +34,9 @@ void SendContinuedEvent(DAP &dap); | |
|
|
||
| void SendProcessExitedEvent(DAP &dap, lldb::SBProcess &process); | ||
|
|
||
| void SendInvalidatedEvent( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add documention and mention that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, fixed |
||
| DAP &dap, llvm::ArrayRef<protocol::InvalidatedEventBody::Area> areas); | ||
|
|
||
| } // namespace lldb_dap | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,21 +7,24 @@ | |
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "DAP.h" | ||
| #include "EventHelper.h" | ||
| #include "JSONUtils.h" | ||
| #include "Protocol/ProtocolEvents.h" | ||
| #include "RequestHandler.h" | ||
| #include "lldb/API/SBMemoryRegionInfo.h" | ||
| #include "llvm/ADT/StringExtras.h" | ||
| #include "llvm/Support/Base64.h" | ||
|
|
||
| using namespace lldb_dap::protocol; | ||
|
|
||
| namespace lldb_dap { | ||
|
|
||
| // Writes bytes to memory at the provided location. | ||
| // | ||
| // Clients should only call this request if the corresponding capability | ||
| // supportsWriteMemoryRequest is true. | ||
| llvm::Expected<protocol::WriteMemoryResponseBody> | ||
| WriteMemoryRequestHandler::Run( | ||
| const protocol::WriteMemoryArguments &args) const { | ||
| llvm::Expected<WriteMemoryResponseBody> | ||
| WriteMemoryRequestHandler::Run(const WriteMemoryArguments &args) const { | ||
| const lldb::addr_t address = args.memoryReference + args.offset; | ||
|
|
||
| lldb::SBProcess process = dap.target.GetProcess(); | ||
|
|
@@ -91,8 +94,13 @@ WriteMemoryRequestHandler::Run( | |
| if (bytes_written == 0) { | ||
| return llvm::make_error<DAPError>(write_error.GetCString()); | ||
| } | ||
| protocol::WriteMemoryResponseBody response; | ||
| WriteMemoryResponseBody response; | ||
| response.bytesWritten = bytes_written; | ||
|
|
||
| // Also send invalidated event to signal client that some things | ||
| // (e.g. variables) can be changed. | ||
| SendInvalidatedEvent(dap, {InvalidatedEventBody::eAreaAll}); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this change everything? Or just variables? I am not sure if writing into memory like this prevents changing the current stack or PC counter or not.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can change return address on stack using |
||
|
|
||
| return response; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,11 @@ | |
| #define LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_EVENTS_H | ||
|
|
||
| #include "Protocol/ProtocolTypes.h" | ||
| #include "lldb/lldb-types.h" | ||
| #include "llvm/Support/JSON.h" | ||
| #include <cstdint> | ||
| #include <optional> | ||
| #include <vector> | ||
|
|
||
| namespace lldb_dap::protocol { | ||
|
|
||
|
|
@@ -56,6 +60,34 @@ struct ModuleEventBody { | |
| llvm::json::Value toJSON(const ModuleEventBody::Reason &); | ||
| llvm::json::Value toJSON(const ModuleEventBody &); | ||
|
|
||
| /// This event signals that some state in the debug adapter has changed and | ||
| /// requires that the client needs to re-render the data snapshot previously | ||
| /// requested. | ||
| /// | ||
| /// Debug adapters do not have to emit this event for runtime changes like | ||
| /// stopped or thread events because in that case the client refetches the new | ||
| /// state anyway. But the event can be used for example to refresh the UI after | ||
| /// rendering formatting has changed in the debug adapter. | ||
| /// | ||
| /// This event should only be sent if the corresponding capability | ||
| /// supportsInvalidatedEvent is true. | ||
| struct InvalidatedEventBody { | ||
| enum Area : unsigned { eAreaAll, eAreaStacks, eAreaThreads, eAreaVariables }; | ||
|
|
||
| /// Set of logical areas that got invalidated. | ||
| std::vector<Area> areas; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have the fields for |
||
|
|
||
| /// If specified, the client only needs to refetch data related to this | ||
| /// thread. | ||
| std::optional<lldb::tid_t> threadId; | ||
|
|
||
| /// If specified, the client only needs to refetch data related to this stack | ||
| /// frame (and the `threadId` is ignored). | ||
| std::optional<uint64_t> frameId; | ||
| }; | ||
| llvm::json::Value toJSON(const InvalidatedEventBody::Area &); | ||
| llvm::json::Value toJSON(const InvalidatedEventBody &); | ||
|
|
||
| } // end namespace lldb_dap::protocol | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a list in case we get more invalidate events? Or when does this reset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We check invalidated event in
verify_invalidated_eventfunction and reset this field. This function is called inside wrappers aroundsetVariableandwriteMemoryrequests.