-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Initial step in targets DAP support #86623
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
10 commits
Select commit
Hold shift + click to select a range
6cccde2
Fix strcmp build error on buildbot
2918dcf
Merge branch 'llvm:main' into main
jeffreytan81 42c2d34
Merge branch 'llvm:main' into main
jeffreytan81 dc9f5db
Merge branch 'llvm:main' into main
jeffreytan81 06ec5e2
Initial support for stepInTargets feature
b2dfdb5
Remove unnecessary changes
f7f8a69
Fix formatter
55a9f70
Remove empty space
d51bf46
Address review feedback
13ffb1c
Address review comments
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,21 @@ SBAddress SBLineEntry::GetEndAddress() const { | |
return sb_address; | ||
} | ||
|
||
SBAddress SBLineEntry::GetSameLineContiguousAddressRangeEnd( | ||
bool include_inlined_functions) const { | ||
LLDB_INSTRUMENT_VA(this); | ||
|
||
SBAddress sb_address; | ||
if (m_opaque_up) { | ||
AddressRange line_range = m_opaque_up->GetSameLineContiguousAddressRange( | ||
include_inlined_functions); | ||
|
||
sb_address.SetAddress(line_range.GetBaseAddress()); | ||
sb_address.OffsetAddress(line_range.GetByteSize()); | ||
} | ||
return sb_address; | ||
} | ||
|
||
Comment on lines
+70
to
+84
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. remove this API and use existing ones I spoke about in the inline comment in the header file? |
||
bool SBLineEntry::IsValid() const { | ||
LLDB_INSTRUMENT_VA(this); | ||
return this->operator bool(); | ||
|
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,6 @@ | ||
|
||
ENABLE_THREADS := YES | ||
|
||
CXX_SOURCES := main.cpp | ||
|
||
include Makefile.rules |
68 changes: 68 additions & 0 deletions
68
lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.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,68 @@ | ||
""" | ||
Test lldb-dap stepInTargets request | ||
""" | ||
|
||
import dap_server | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
import lldbdap_testcase | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestDAP_stepInTargets(lldbdap_testcase.DAPTestCaseBase): | ||
@skipIf( | ||
archs=no_match(["x86_64"]) | ||
) # InstructionControlFlowKind for ARM is not supported yet. | ||
def test_basic(self): | ||
""" | ||
Tests the basic stepping in targets with directly calls. | ||
""" | ||
program = self.getBuildArtifact("a.out") | ||
self.build_and_launch(program) | ||
source = "main.cpp" | ||
|
||
breakpoint_line = line_number(source, "// set breakpoint here") | ||
lines = [breakpoint_line] | ||
# Set breakpoint in the thread function so we can step the threads | ||
breakpoint_ids = self.set_source_breakpoints(source, lines) | ||
self.assertEqual( | ||
len(breakpoint_ids), len(lines), "expect correct number of breakpoints" | ||
) | ||
self.continue_to_breakpoints(breakpoint_ids) | ||
|
||
threads = self.dap_server.get_threads() | ||
self.assertEqual(len(threads), 1, "expect one thread") | ||
tid = threads[0]["id"] | ||
|
||
leaf_frame = self.dap_server.get_stackFrame() | ||
self.assertIsNotNone(leaf_frame, "expect a leaf frame") | ||
|
||
# Request all step in targets list and verify the response. | ||
step_in_targets_response = self.dap_server.request_stepInTargets( | ||
leaf_frame["id"] | ||
) | ||
self.assertEqual(step_in_targets_response["success"], True, "expect success") | ||
self.assertIn( | ||
"body", step_in_targets_response, "expect body field in response body" | ||
) | ||
self.assertIn( | ||
"targets", | ||
step_in_targets_response["body"], | ||
"expect targets field in response body", | ||
) | ||
|
||
step_in_targets = step_in_targets_response["body"]["targets"] | ||
self.assertEqual(len(step_in_targets), 3, "expect 3 step in targets") | ||
|
||
# Verify the target names are correct. | ||
self.assertEqual(step_in_targets[0]["label"], "bar()", "expect bar()") | ||
self.assertEqual(step_in_targets[1]["label"], "bar2()", "expect bar2()") | ||
self.assertEqual( | ||
step_in_targets[2]["label"], "foo(int, int)", "expect foo(int, int)" | ||
) | ||
|
||
# Choose to step into second target and verify that we are in bar2() | ||
self.stepIn(threadId=tid, targetId=step_in_targets[1]["id"], waitForStop=True) | ||
leaf_frame = self.dap_server.get_stackFrame() | ||
self.assertIsNotNone(leaf_frame, "expect a leaf frame") | ||
self.assertEqual(leaf_frame["name"], "bar2()") |
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,11 @@ | ||
|
||
int foo(int val, int extra) { return val + extra; } | ||
|
||
int bar() { return 22; } | ||
|
||
int bar2() { return 54; } | ||
|
||
int main(int argc, char const *argv[]) { | ||
foo(bar(), bar2()); // set breakpoint here | ||
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
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.
We don't need this API right? We spoke about using existing APIs for this. I believe we can find the index the SBLineEntry in the line table using:
And then you can use:
With the next index until the line doesn't match.
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.
@clayborg, right, I know I can do that but I did not use it for two reasons:
GetSameLineContiguousAddressRangeEnd
API is doing internally so I prefer to reuse the API than implement myself.GetSameLineContiguousAddressRangeEnd
makes the code more resilient?Anyway, if you still prefer us calling "GetLineEntryAtIndex" repeat, I will change it.
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.
I take a second look at
GetSameLineContiguousAddressRangeEnd
implementation, it seems to take care of compiler generate code and inline functions which I find it is tedious to duplicate the implementation in lldb-dap:llvm-project/lldb/source/Symbol/LineEntry.cpp
Lines 202 to 233 in a6d932b
So I think it makes more sense to reuse it. Please take a further review. Thanks.