-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb-dap] Implement declaration locations
This commit implements support for the "declaration location" recently added by microsoft/debug-adapter-protocol#494 to the debug adapter protocol. For the `declarationLocationReference` we need a variable ID similar to the the `variablesReference`. I decided to simply reuse the `variablesReference` here and renamed `Variables::expandable_variables` and friends accordingly. Given that almost all variables have a declaration location, we now assign those variable ids to all variables. While `declarationLocationReference` effectively supersedes `$__lldb_extensions.declaration`, I did not remove this extension, yet, since I assume that there are some closed-source extensions which rely on it. I tested this against VS-Code Insiders. However, VS-Code Insiders currently only supports `valueLoctionReference` and not `declarationLocationReference`, yet. Locally, I hence published the declaration locations as value locations, and VS Code Insiders navigated to the expected places. Looking forward to proper VS Code support for `declarationLocationReference`.
- Loading branch information
1 parent
b765fdd
commit 5bdcb82
Showing
9 changed files
with
286 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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 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 @@ | ||
C_SOURCES := main.c | ||
|
||
include Makefile.rules |
40 changes: 40 additions & 0 deletions
40
lldb/test/API/tools/lldb-dap/locations/TestDAP_locations.py
This file contains 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,40 @@ | ||
""" | ||
Test lldb-dap locations request | ||
""" | ||
|
||
|
||
import dap_server | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
import lldbdap_testcase | ||
import os | ||
|
||
|
||
class TestDAP_locations(lldbdap_testcase.DAPTestCaseBase): | ||
@skipIfWindows | ||
def test_locations(self): | ||
""" | ||
Tests the 'locations' request. | ||
""" | ||
program = self.getBuildArtifact("a.out") | ||
self.build_and_launch(program) | ||
source = "main.c" | ||
self.source_path = os.path.join(os.getcwd(), source) | ||
self.set_source_breakpoints( | ||
source, | ||
[line_number(source, "// BREAK HERE")], | ||
) | ||
self.continue_to_next_stop() | ||
|
||
locals = {l["name"]: l for l in self.dap_server.get_local_variables()} | ||
|
||
# var1 has a declarationLocation but no valueLocation | ||
self.assertIn("declarationLocationReference", locals["var1"].keys()) | ||
self.assertNotIn("valueLocationReference", locals["var1"].keys()) | ||
loc_var1 = self.dap_server.request_locations( | ||
locals["var1"]["declarationLocationReference"] | ||
) | ||
self.assertTrue(loc_var1["success"]) | ||
self.assertTrue(loc_var1["body"]["source"]["path"].endswith("main.c")) | ||
self.assertEqual(loc_var1["body"]["line"], 2) |
This file contains 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 @@ | ||
int main(void) { | ||
int var1 = 1; | ||
// BREAK HERE | ||
return 0; | ||
} |
This file contains 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 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 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 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.