-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb-dap] Don't emit a removed module event for unseen modules #139324
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 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
018bb06
[lldb-dap] Don't emit a removed module event for unseen modules
JDevlieghere 4b79440
Fix discrepancy between black and darker
JDevlieghere c01964e
Hold the lock while iterating the modules
JDevlieghere a4a2a78
Merge branch 'main' into lldb-dap-module-events
JDevlieghere 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
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,12 @@ | ||
| CXX_SOURCES := main.cpp | ||
| LD_EXTRAS := -Wl,-rpath "-Wl,$(shell pwd)" | ||
| USE_LIBDL :=1 | ||
|
|
||
| a.out: libother | ||
|
|
||
| include Makefile.rules | ||
|
|
||
| # The following shared library will be used to test breakpoints under dynamic loading | ||
| libother: other.c | ||
| "$(MAKE)" -f $(MAKEFILE_RULES) \ | ||
| DYLIB_ONLY=YES DYLIB_C_SOURCES=other.c DYLIB_NAME=other |
54 changes: 54 additions & 0 deletions
54
lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.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,54 @@ | ||
| import dap_server | ||
| from lldbsuite.test.decorators import * | ||
| from lldbsuite.test.lldbtest import * | ||
| from lldbsuite.test import lldbutil | ||
| import lldbdap_testcase | ||
| import re | ||
|
|
||
|
|
||
| class TestDAP_module_event(lldbdap_testcase.DAPTestCaseBase): | ||
| def test_module_event(self): | ||
| program = self.getBuildArtifact("a.out") | ||
| self.build_and_launch(program, stopOnEntry=True) | ||
|
|
||
| source = "main.cpp" | ||
| breakpoint1_line = line_number(source, "// breakpoint 1") | ||
| breakpoint2_line = line_number(source, "// breakpoint 2") | ||
| breakpoint3_line = line_number(source, "// breakpoint 3") | ||
|
|
||
| breakpoint_ids = self.set_source_breakpoints( | ||
| source, [breakpoint1_line, breakpoint2_line, breakpoint3_line] | ||
| ) | ||
| self.continue_to_breakpoints(breakpoint_ids) | ||
|
|
||
| # We're now stopped at breakpoint 1 before the dlopen. Flush all the module events. | ||
| event = self.dap_server.wait_for_event("module", 0.25) | ||
| while event is not None: | ||
| event = self.dap_server.wait_for_event("module", 0.25) | ||
|
|
||
| # Continue to the second breakpoint, before the dlclose. | ||
| self.continue_to_breakpoints(breakpoint_ids) | ||
|
|
||
| # Make sure we got a module event for libother. | ||
| event = self.dap_server.wait_for_event("module", 5) | ||
| self.assertTrue(event, "didn't get a module event") | ||
| module_name = event["body"]["module"]["name"] | ||
| module_id = event["body"]["module"]["id"] | ||
| self.assertEqual(event["body"]["reason"], "new") | ||
| self.assertIn("libother", module_name) | ||
|
|
||
| # Continue to the third breakpoint, after the dlclose. | ||
| self.continue_to_breakpoints(breakpoint_ids) | ||
|
|
||
| # Make sure we got a module event for libother. | ||
| event = self.dap_server.wait_for_event("module", 5) | ||
| self.assertTrue(event, "didn't get a module event") | ||
| reason = event["body"]["reason"] | ||
| self.assertEqual(event["body"]["reason"], "removed") | ||
| self.assertEqual(event["body"]["module"]["id"], module_id) | ||
|
|
||
| # The removed module event should omit everything but the module id. | ||
| # Check that there's no module name in the event. | ||
| self.assertNotIn("name", event["body"]["module"]) | ||
|
|
||
| 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,22 @@ | ||
| #include <dlfcn.h> | ||
| #include <stdio.h> | ||
|
|
||
| int main(int argc, char const *argv[]) { | ||
|
|
||
| #if defined(__APPLE__) | ||
| const char *libother_name = "libother.dylib"; | ||
| #else | ||
| const char *libother_name = "libother.so"; | ||
| #endif | ||
|
|
||
| printf("before dlopen\n"); // breakpoint 1 | ||
| void *handle = dlopen(libother_name, RTLD_NOW); | ||
| int (*foo)(int) = (int (*)(int))dlsym(handle, "foo"); | ||
| foo(12); | ||
|
|
||
| printf("before dlclose\n"); // breakpoint 2 | ||
| dlclose(handle); | ||
| printf("after dlclose\n"); // breakpoint 3 | ||
|
|
||
| return 0; // breakpoint 1 | ||
| } |
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,5 @@ | ||
| extern int foo(int x) { | ||
| int y = x + 42; // break other | ||
| int z = y + 42; | ||
| return z; | ||
| } |
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.
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 we grab this lock while we iterate the entire list of modules from the event?
I think we could we get a modules request in the middle of processing this list, which might be a bit inconsistent when we get back to handling the events.