-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][test] Add test for chained PCH debugging #83582
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
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,10 @@ | ||
include Makefile.rules | ||
|
||
OBJECTS += main.o | ||
|
||
$(EXE): $(BUILDDIR)/main.o | ||
|
||
$(BUILDDIR)/main.o: main.cpp | ||
$(CC) -cc1 -emit-pch -x c++-header -fmodule-format=obj -fmodules -O0 -dwarf-ext-refs -debug-info-kind=standalone $(SRCDIR)/base-pch.h -o base-pch.h.gch | ||
$(CC) -cc1 -emit-pch -x c++-header -fmodule-format=obj -fmodules -O0 -dwarf-ext-refs -debug-info-kind=standalone -include-pch base-pch.h.gch $(SRCDIR)/pch.h -o pch.h.gch | ||
$(CC) -cc1 -emit-obj -x c++ -fmodules -O0 -dwarf-ext-refs -debug-info-kind=standalone -include-pch pch.h.gch $(SRCDIR)/main.cpp -o $(BUILDDIR)/main.o | ||
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,73 @@ | ||
""" | ||
Tests that we correctly track AST layout info | ||
(specifically alignment) when moving AST nodes | ||
between several ClangASTImporter instances | ||
(in this case, from a pch chain to executable | ||
to expression AST). | ||
""" | ||
|
||
import lldb | ||
import os | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestPchChain(TestBase): | ||
@add_test_categories(["gmodules"]) | ||
@expectedFailureAll("Chained pch debugging currently not fully supported") | ||
def test_expr(self): | ||
self.build() | ||
exe = self.getBuildArtifact("a.out") | ||
self.target = self.dbg.CreateTarget(exe) | ||
self.assertTrue(self.target, VALID_TARGET) | ||
lldbutil.run_break_set_by_file_and_line( | ||
self, "main.cpp", 9, num_expected_locations=1 | ||
) | ||
|
||
self.runCmd("run", RUN_SUCCEEDED) | ||
|
||
self.expect( | ||
"frame variable data", | ||
substrs=["row = 1", "col = 2", "row = 3", "col = 4", "stride = 5"], | ||
) | ||
|
||
@add_test_categories(["gmodules"]) | ||
@expectedFailureAll("Chained pch debugging currently not fully supported") | ||
def test_frame_var(self): | ||
self.build() | ||
exe = self.getBuildArtifact("a.out") | ||
self.target = self.dbg.CreateTarget(exe) | ||
self.assertTrue(self.target, VALID_TARGET) | ||
lldbutil.run_break_set_by_file_and_line( | ||
self, "main.cpp", 9, num_expected_locations=1 | ||
) | ||
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. For some reason regex breakpoint didn't resolve...probably related to the Makefile shenanigans |
||
|
||
self.runCmd("run", RUN_SUCCEEDED) | ||
|
||
self.expect_expr( | ||
"data", | ||
result_type="MatrixData", | ||
result_children=[ | ||
ValueCheck( | ||
name="section", | ||
children=[ | ||
ValueCheck( | ||
name="origin", | ||
children=[ | ||
ValueCheck(name="row", value="1"), | ||
ValueCheck(name="col", value="2"), | ||
], | ||
), | ||
ValueCheck( | ||
name="size", | ||
children=[ | ||
ValueCheck(name="row", value="3"), | ||
ValueCheck(name="col", value="4"), | ||
], | ||
), | ||
], | ||
), | ||
ValueCheck(name="stride", value="5"), | ||
], | ||
) |
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 @@ | ||
#ifndef BASE_PCH_H_IN | ||
#define BASE_PCH_H_IN | ||
|
||
struct [[gnu::aligned(128)]] RowCol { | ||
unsigned row; | ||
unsigned col; | ||
}; | ||
|
||
#endif // _H_IN |
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 @@ | ||
int main(int argc, const char *argv[]) { | ||
struct MatrixData data = {0}; | ||
data.section.origin.row = 1; | ||
data.section.origin.col = 2; | ||
data.section.size.row = 3; | ||
data.section.size.col = 4; | ||
data.stride = 5; | ||
|
||
return data.section.size.row; | ||
} |
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,16 @@ | ||
#ifndef PCH_H_IN | ||
#define PCH_H_IN | ||
|
||
static const int kAlignment = 64; | ||
|
||
struct [[gnu::aligned(kAlignment)]] Submatrix { | ||
struct RowCol origin; | ||
struct RowCol size; | ||
}; | ||
|
||
struct [[gnu::aligned(kAlignment)]] MatrixData { | ||
struct Submatrix section; | ||
unsigned stride; | ||
}; | ||
|
||
#endif // _H_IN |
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.
I would love to find a better way of doing this
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 think this is not too bad as it is.