-
Notifications
You must be signed in to change notification settings - Fork 15k
[lldb-dap] Send an Invalidated event on thread stack change. #163976
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| CXX_SOURCES := main.cpp | ||
|
|
||
| include Makefile.rules |
55 changes: 55 additions & 0 deletions
55
lldb/test/API/tools/lldb-dap/invalidated-event/TestDAP_invalidatedEvent.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """ | ||
| Test lldb-dap recieves invalidated-events when the area such as | ||
| stack, variables, threads has changes but the client does not | ||
| know about it. | ||
| """ | ||
|
|
||
| import lldbdap_testcase | ||
| from lldbsuite.test.lldbtest import line_number | ||
| from dap_server import Event | ||
|
|
||
|
|
||
| class TestDAP_invalidatedEvent(lldbdap_testcase.DAPTestCaseBase): | ||
| def verify_top_frame_name(self, frame_name: str): | ||
| all_frames = self.get_stackFrames() | ||
| self.assertGreaterEqual(len(all_frames), 1, "Expected at least one frame.") | ||
| top_frame_name = all_frames[0]["name"] | ||
| self.assertRegex(top_frame_name, f"{frame_name}.*") | ||
|
|
||
| def test_invalidated_stack_area_event(self): | ||
| """ | ||
| Test an invalidated event for the stack area. | ||
| The event is sent when the command `thread return <expr>` is sent by the user. | ||
| """ | ||
| other_source = "other.h" | ||
| return_bp_line = line_number(other_source, "// thread return breakpoint") | ||
|
|
||
| program = self.getBuildArtifact("a.out") | ||
| self.build_and_launch(program) | ||
| self.set_source_breakpoints(other_source, [return_bp_line]) | ||
| self.continue_to_next_stop() | ||
|
|
||
| self.verify_top_frame_name("add") | ||
| thread_id = self.dap_server.get_thread_id() | ||
| self.assertIsNotNone(thread_id, "Exepected a thread id.") | ||
|
|
||
| # run thread return | ||
| thread_command = "thread return 20" | ||
| eval_resp = self.dap_server.request_evaluate(thread_command, context="repl") | ||
| self.assertTrue(eval_resp["success"], f"Failed to evaluate `{thread_command}`.") | ||
|
|
||
| # wait for the invalidated stack event. | ||
| stack_event = self.dap_server.wait_for_event(["invalidated"]) | ||
| self.assertIsNotNone(stack_event, "Expected an invalidated event.") | ||
| event_body: Event = stack_event["body"] | ||
| self.assertIn("stacks", event_body["areas"]) | ||
| self.assertIn("threadId", event_body.keys()) | ||
| self.assertEqual( | ||
| thread_id, | ||
| event_body["threadId"], | ||
| f"Expected the event from thread {thread_id}.", | ||
| ) | ||
|
|
||
| # confirm we are back at the main frame. | ||
| self.verify_top_frame_name("main") | ||
| self.continue_to_exit() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #include "other.h" | ||
|
|
||
| int main() { | ||
| int first = 5; | ||
| int second = 10; | ||
| const int result = add(first, second); | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #ifndef OTHER_H | ||
| #define OTHER_H | ||
|
|
||
| int add(int a, int b) { | ||
| int first = a; | ||
| int second = b; // thread return breakpoint | ||
| int result = first + second; | ||
| return result; | ||
| } | ||
| #endif // OTHER_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.