-
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 1 commit
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 |
|---|---|---|
|
|
@@ -215,6 +215,7 @@ def __init__( | |
| self.terminated: bool = False | ||
| self.events: List[Event] = [] | ||
| self.progress_events: List[Event] = [] | ||
| self.invalidated_event: Event = None | ||
| self.reverse_requests: List[Request] = [] | ||
| self.module_events: List[Dict] = [] | ||
| self.sequence: int = 1 | ||
|
|
@@ -440,6 +441,8 @@ def _handle_event(self, packet: Event) -> None: | |
| elif event == "capabilities" and body: | ||
| # Update the capabilities with new ones from the event. | ||
| self.capabilities.update(body["capabilities"]) | ||
| elif event == "invalidated": | ||
| self.invalidated_event = packet | ||
|
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 this be a list in case we get more invalidate events? Or when does this reset?
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. We check invalidated event in |
||
|
|
||
| def _handle_reverse_request(self, request: Request) -> None: | ||
| if request in self.reverse_requests: | ||
|
|
@@ -1014,6 +1017,7 @@ def request_initialize(self, sourceInitFile=False): | |
| "supportsVariableType": True, | ||
| "supportsStartDebuggingRequest": True, | ||
| "supportsProgressReporting": True, | ||
| "supportsInvalidatedEvent": True, | ||
| "$__lldb_sourceInitFile": sourceInitFile, | ||
| }, | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,9 @@ | |
| #define LLDB_TOOLS_LLDB_DAP_EVENTHELPER_H | ||
|
|
||
| #include "DAPForward.h" | ||
| #include "Protocol/ProtocolEvents.h" | ||
| #include "llvm/Support/Error.h" | ||
| #include <vector> | ||
|
|
||
| namespace lldb_dap { | ||
| struct 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, std::vector<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 |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
|
|
||
| #include "Protocol/ProtocolTypes.h" | ||
| #include "llvm/Support/JSON.h" | ||
| #include <vector> | ||
|
|
||
| namespace lldb_dap::protocol { | ||
|
|
||
|
|
@@ -56,6 +57,14 @@ struct ModuleEventBody { | |
| llvm::json::Value toJSON(const ModuleEventBody::Reason &); | ||
| llvm::json::Value toJSON(const ModuleEventBody &); | ||
|
|
||
| struct InvalidatedEventBody { | ||
| enum Area : unsigned { eAreaAll, eAreaStacks, eAreaThreads, eAreaVariables }; | ||
|
|
||
| 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 |
||
| }; | ||
| llvm::json::Value toJSON(const InvalidatedEventBody::Area &); | ||
| llvm::json::Value toJSON(const InvalidatedEventBody &); | ||
|
|
||
| } // end namespace lldb_dap::protocol | ||
|
|
||
| #endif | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -1073,3 +1073,17 @@ TEST(ProtocolTypesTest, CompletionsResponseBody) { | |||
| ASSERT_THAT_EXPECTED(expected, llvm::Succeeded()); | ||||
| EXPECT_EQ(pp(*expected), pp(response)); | ||||
| } | ||||
|
|
||||
| TEST(ProtocolTypesTest, InvalidatedEventBody) { | ||||
| InvalidatedEventBody body; | ||||
| body.areas = {InvalidatedEventBody::eAreaStacks, | ||||
| InvalidatedEventBody::eAreaThreads}; | ||||
| StringRef json = R"({ | ||||
| "areas": [ | ||||
| "stacks", | ||||
| "threads" | ||||
| ] | ||||
| })"; | ||||
| // Validate toJSON | ||||
|
||||
| // Validate toJSON |
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.