Skip to content

Commit dee589f

Browse files
Merge pull request #8464 from augusto2112/split-test
[lldb] Split TestSwiftEmbeddedFrameVariable into two tests
2 parents 3312447 + 0f5f917 commit dee589f

File tree

6 files changed

+90
-52
lines changed

6 files changed

+90
-52
lines changed

lldb/include/lldb/Core/ModuleList.h

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class ModuleListProperties : public Properties {
9595

9696
AutoBool GetSwiftEnableCxxInterop() const;
9797
AutoBool GetSwiftEnableFullDwarfDebugging() const;
98+
bool GetSwiftEnableASTContext() const;
9899
// END SWIFT
99100

100101
FileSpec GetClangModulesCachePath() const;

lldb/source/Core/CoreProperties.td

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ let Definition = "modulelist" in {
6464
DefaultEnumValue<"llvm::to_underlying(AutoBool::Auto)">,
6565
EnumValues<"OptionEnumValues(g_enable_full_dwarf_debugging)">,
6666
Desc<"Read full debug information from DWARF for Swift debugging. By default LLDB will use DWARF debug information if it cannot use reflection metadata.">;
67+
def SwiftEnableASTContext: Property<"swift-enable-ast-context", "Boolean">,
68+
Global,
69+
DefaultTrue,
70+
Desc<"Enable instantiating Swift AST contexts.">;
6771
// END SWIFT
6872
def SymLinkPaths: Property<"debug-info-symlink-paths", "FileSpecList">,
6973
Global,

lldb/source/Core/ModuleList.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ AutoBool ModuleListProperties::GetSwiftEnableFullDwarfDebugging() const {
274274
idx, static_cast<AutoBool>(
275275
g_modulelist_properties[idx].default_uint_value));
276276
}
277+
278+
bool ModuleListProperties::GetSwiftEnableASTContext() const {
279+
const uint32_t idx = ePropertySwiftEnableASTContext;
280+
return GetPropertyAtIndexAs<bool>(
281+
idx, g_modulelist_properties[idx].default_uint_value != 0);
282+
}
277283
// END SWIFT
278284

279285
FileSpec ModuleListProperties::GetLLDBIndexCachePath() const {

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwiftDescriptorFinder.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ DWARFASTParserSwift::getBuiltinTypeDescriptor(
357357
if (byte_size == LLDB_INVALID_ADDRESS)
358358
return {};
359359

360-
auto alignment = die.GetAttributeValueAsUnsigned(DW_AT_alignment, 8);
360+
auto alignment = die.GetAttributeValueAsUnsigned(DW_AT_alignment,
361+
byte_size ? byte_size : 8);
361362

362363
// TODO: this seems simple to calculate but maybe we should encode the stride
363364
// in DWARF? That's what reflection metadata does.

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,10 @@ SwiftASTContext::SwiftASTContext(std::string description,
976976
: TypeSystemSwift(), m_typeref_typesystem(&typeref_typesystem),
977977
m_compiler_invocation_ap(new swift::CompilerInvocation()),
978978
m_diagnostic_consumer_ap(new StoringDiagnosticConsumer(*this)) {
979+
assert(
980+
ModuleList::GetGlobalModuleListProperties().GetSwiftEnableASTContext() &&
981+
"Swift AST context instantiation is disabled!");
982+
979983
m_description = description;
980984

981985
// Set the clang modules cache path.
@@ -1884,6 +1888,10 @@ SwiftASTContext::CreateInstance(lldb::LanguageType language, Module &module,
18841888
if (!SwiftASTContextSupportsLanguage(language))
18851889
return lldb::TypeSystemSP();
18861890

1891+
if (!ModuleList::GetGlobalModuleListProperties()
1892+
.GetSwiftEnableASTContext())
1893+
return lldb::TypeSystemSP();
1894+
18871895
std::string m_description;
18881896
{
18891897
llvm::raw_string_ostream ss(m_description);
@@ -2359,6 +2367,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
23592367
if (!SwiftASTContextSupportsLanguage(language))
23602368
return lldb::TypeSystemSP();
23612369

2370+
if (!ModuleList::GetGlobalModuleListProperties()
2371+
.GetSwiftEnableASTContext())
2372+
return lldb::TypeSystemSP();
2373+
23622374
LLDB_SCOPED_TIMER();
23632375
std::string m_description = "SwiftASTContextForExpressions";
23642376
std::vector<swift::PluginSearchOption> plugin_search_options;
@@ -2650,6 +2662,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
26502662
TypeSystemSwiftTypeRefForExpressions &typeref_typesystem) {
26512663
LLDB_SCOPED_TIMER();
26522664

2665+
if (!ModuleList::GetGlobalModuleListProperties()
2666+
.GetSwiftEnableASTContext())
2667+
return lldb::TypeSystemSP();
2668+
26532669
CompileUnit *cu = sc.comp_unit;
26542670
StringRef swift_module_name = TypeSystemSwiftTypeRef::GetSwiftModuleFor(&sc);
26552671
std::string m_description;

lldb/test/API/lang/swift/embedded/frame_variable/TestSwiftEmbeddedFrameVariable.py

+61-51
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ class TestSwiftEmbeddedFrameVariable(TestBase):
1010
@swiftTest
1111
def test(self):
1212
self.build()
13+
self.implementation()
14+
15+
@skipUnlessDarwin
16+
@swiftTest
17+
def test_without_ast(self):
18+
"""Run the test turning off instantion of Swift AST contexts in order to ensure that all type information comes from DWARF"""
19+
self.build()
20+
self.runCmd("setting set symbols.swift-enable-ast-context false")
21+
self.implementation()
22+
23+
def implementation(self):
24+
self.runCmd("setting set symbols.swift-enable-full-dwarf-debugging true")
1325

1426
target, process, thread, _ = lldbutil.run_to_source_breakpoint(
1527
self, "break here", lldb.SBFileSpec("main.swift")
@@ -19,153 +31,151 @@ def test(self):
1931

2032
varB = frame.FindVariable("varB")
2133
field = varB.GetChildMemberWithName("a").GetChildMemberWithName("field")
22-
lldbutil.check_variable(self, field, False, value='4.5')
34+
lldbutil.check_variable(self, field, False, value="4.5")
2335
b = varB.GetChildMemberWithName("b")
24-
lldbutil.check_variable(self, b, False, value='123456')
36+
lldbutil.check_variable(self, b, False, value="123456")
2537

2638
tuple = frame.FindVariable("tuple")
2739
first = tuple.GetChildAtIndex(0)
2840
field = first.GetChildMemberWithName("field")
29-
lldbutil.check_variable(self, field, False, value='4.5')
41+
lldbutil.check_variable(self, field, False, value="4.5")
3042
second = tuple.GetChildAtIndex(1)
3143
a = second.GetChildMemberWithName("a")
3244
field = a.GetChildMemberWithName("field")
33-
lldbutil.check_variable(self, field, False, value='4.5')
45+
lldbutil.check_variable(self, field, False, value="4.5")
3446
b = second.GetChildMemberWithName("b")
35-
lldbutil.check_variable(self, b, False, value='123456')
47+
lldbutil.check_variable(self, b, False, value="123456")
3648

3749
nonPayload1 = frame.FindVariable("nonPayload1")
38-
lldbutil.check_variable(self, nonPayload1, False, value='one')
50+
lldbutil.check_variable(self, nonPayload1, False, value="one")
3951

4052
nonPayload2 = frame.FindVariable("nonPayload2")
41-
lldbutil.check_variable(self, nonPayload2, False, value='two')
53+
lldbutil.check_variable(self, nonPayload2, False, value="two")
4254

4355
singlePayload = frame.FindVariable("singlePayload")
44-
payload = singlePayload.GetChildMemberWithName('payload')
45-
field = payload.GetChildMemberWithName('a').GetChildMemberWithName('field')
46-
lldbutil.check_variable(self, field, False, value='4.5')
47-
b = payload.GetChildMemberWithName('b')
48-
lldbutil.check_variable(self, b, False, value='123456')
56+
payload = singlePayload.GetChildMemberWithName("payload")
57+
field = payload.GetChildMemberWithName("a").GetChildMemberWithName("field")
58+
lldbutil.check_variable(self, field, False, value="4.5")
59+
b = payload.GetChildMemberWithName("b")
60+
lldbutil.check_variable(self, b, False, value="123456")
4961

5062
emptySinglePayload = frame.FindVariable("emptySinglePayload")
51-
lldbutil.check_variable(self, emptySinglePayload, False, value='nonPayloadTwo')
63+
lldbutil.check_variable(self, emptySinglePayload, False, value="nonPayloadTwo")
5264

5365
smallMultipayloadEnum1 = frame.FindVariable("smallMultipayloadEnum1")
5466
one = smallMultipayloadEnum1.GetChildMemberWithName("one")
55-
lldbutil.check_variable(self, one, False, value='two')
67+
lldbutil.check_variable(self, one, False, value="two")
5668

5769
smallMultipayloadEnum2 = frame.FindVariable("smallMultipayloadEnum2")
5870
two = smallMultipayloadEnum2.GetChildMemberWithName("two")
59-
lldbutil.check_variable(self, two, False, value='one')
60-
71+
lldbutil.check_variable(self, two, False, value="one")
6172

6273
bigMultipayloadEnum1 = frame.FindVariable("bigMultipayloadEnum1")
6374
one = bigMultipayloadEnum1.GetChildMemberWithName("one")
6475
first = one.GetChildAtIndex(0).GetChildMemberWithName("supField")
6576
second = one.GetChildAtIndex(1).GetChildMemberWithName("supField")
6677
third = one.GetChildAtIndex(2).GetChildMemberWithName("supField")
67-
lldbutil.check_variable(self, first, False, value='42')
68-
lldbutil.check_variable(self, second, False, value='43')
69-
lldbutil.check_variable(self, third, False, value='44')
70-
78+
lldbutil.check_variable(self, first, False, value="42")
79+
lldbutil.check_variable(self, second, False, value="43")
80+
lldbutil.check_variable(self, third, False, value="44")
7181

7282
fullMultipayloadEnum1 = frame.FindVariable("fullMultipayloadEnum1")
7383
one = fullMultipayloadEnum1.GetChildMemberWithName("one")
74-
lldbutil.check_variable(self, one, False, value='120')
84+
lldbutil.check_variable(self, one, False, value="120")
7585

7686
fullMultipayloadEnum2 = frame.FindVariable("fullMultipayloadEnum2")
7787
two = fullMultipayloadEnum2.GetChildMemberWithName("two")
78-
lldbutil.check_variable(self, two, False, value='9.5')
88+
lldbutil.check_variable(self, two, False, value="9.5")
7989

8090
bigFullMultipayloadEnum1 = frame.FindVariable("bigFullMultipayloadEnum1")
8191
one = bigFullMultipayloadEnum1.GetChildMemberWithName("one")
8292
first = one.GetChildAtIndex(0)
8393
second = one.GetChildAtIndex(1)
84-
lldbutil.check_variable(self, first, False, value='209')
85-
lldbutil.check_variable(self, second, False, value='315')
94+
lldbutil.check_variable(self, first, False, value="209")
95+
lldbutil.check_variable(self, second, False, value="315")
8696

8797
bigFullMultipayloadEnum2 = frame.FindVariable("bigFullMultipayloadEnum2")
8898
two = bigFullMultipayloadEnum2.GetChildMemberWithName("two")
8999
first = two.GetChildAtIndex(0)
90100
second = two.GetChildAtIndex(1)
91-
lldbutil.check_variable(self, first, False, value='452.5')
92-
lldbutil.check_variable(self, second, False, value='753.5')
93-
101+
lldbutil.check_variable(self, first, False, value="452.5")
102+
lldbutil.check_variable(self, second, False, value="753.5")
94103

95104
sup = frame.FindVariable("sup")
96105
supField = sup.GetChildMemberWithName("supField")
97-
lldbutil.check_variable(self, supField, False, value='42')
106+
lldbutil.check_variable(self, supField, False, value="42")
98107

99108
sub = frame.FindVariable("sub")
100109
supField = sub.GetChildMemberWithName("supField")
101-
lldbutil.check_variable(self, supField, False, value='42')
110+
lldbutil.check_variable(self, supField, False, value="42")
102111
subField = sub.GetChildMemberWithName("subField")
103112
a = subField.GetChildMemberWithName("a")
104113
field = a.GetChildMemberWithName("field")
105-
lldbutil.check_variable(self, field, False, value='4.5')
114+
lldbutil.check_variable(self, field, False, value="4.5")
106115
b = subField.GetChildMemberWithName("b")
107-
lldbutil.check_variable(self, b, False, value='123456')
116+
lldbutil.check_variable(self, b, False, value="123456")
108117

109118
subSub = frame.FindVariable("subSub")
110119
supField = subSub.GetChildMemberWithName("supField")
111-
lldbutil.check_variable(self, supField, False, value='42')
120+
lldbutil.check_variable(self, supField, False, value="42")
112121
subField = subSub.GetChildMemberWithName("subField")
113122
a = subField.GetChildMemberWithName("a")
114123
field = a.GetChildMemberWithName("field")
115-
lldbutil.check_variable(self, field, False, value='4.5')
124+
lldbutil.check_variable(self, field, False, value="4.5")
116125
b = subField.GetChildMemberWithName("b")
117-
lldbutil.check_variable(self, b, False, value='123456')
126+
lldbutil.check_variable(self, b, False, value="123456")
118127

119-
subSubField = subSub.GetChildMemberWithName("subSubField").GetChildMemberWithName("field")
120-
lldbutil.check_variable(self, subSubField, False, value='4.5')
128+
subSubField = subSub.GetChildMemberWithName(
129+
"subSubField"
130+
).GetChildMemberWithName("field")
131+
lldbutil.check_variable(self, subSubField, False, value="4.5")
121132

122133
gsp = frame.FindVariable("gsp")
123134
t = gsp.GetChildMemberWithName("t")
124-
lldbutil.check_variable(self, t, False, value='42')
135+
lldbutil.check_variable(self, t, False, value="42")
125136
u = gsp.GetChildMemberWithName("u")
126-
lldbutil.check_variable(self, u, False, value='94.5')
137+
lldbutil.check_variable(self, u, False, value="94.5")
127138

128139
gsp2 = frame.FindVariable("gsp2")
129140
t = gsp2.GetChildMemberWithName("t")
130141
supField = t.GetChildMemberWithName("supField")
131-
lldbutil.check_variable(self, supField, False, value='42')
142+
lldbutil.check_variable(self, supField, False, value="42")
132143
u = gsp2.GetChildMemberWithName("u")
133144
a = u.GetChildMemberWithName("a")
134145
field = a.GetChildMemberWithName("field")
135-
lldbutil.check_variable(self, field, False, value='4.5')
146+
lldbutil.check_variable(self, field, False, value="4.5")
136147
b = u.GetChildMemberWithName("b")
137-
lldbutil.check_variable(self, b, False, value='123456')
148+
lldbutil.check_variable(self, b, False, value="123456")
138149

139150
gsp3 = frame.FindVariable("gsp3")
140151
t = gsp3.GetChildMemberWithName("t")
141152
one = t.GetChildMemberWithName("one")
142153
first = one.GetChildAtIndex(0)
143154
second = one.GetChildAtIndex(1)
144-
lldbutil.check_variable(self, first, False, value='209')
145-
lldbutil.check_variable(self, second, False, value='315')
155+
lldbutil.check_variable(self, first, False, value="209")
156+
lldbutil.check_variable(self, second, False, value="315")
146157
u = gsp3.GetChildMemberWithName("u")
147158
two = u.GetChildMemberWithName("two")
148-
lldbutil.check_variable(self, two, False, value='one')
159+
lldbutil.check_variable(self, two, False, value="one")
149160

150161
gcp = frame.FindVariable("gcp")
151162
t = gcp.GetChildMemberWithName("t")
152-
lldbutil.check_variable(self, t, False, value='55.5')
163+
lldbutil.check_variable(self, t, False, value="55.5")
153164
u = gcp.GetChildMemberWithName("u")
154-
lldbutil.check_variable(self, u, False, value='9348')
155-
165+
lldbutil.check_variable(self, u, False, value="9348")
156166

157167
either = frame.FindVariable("either")
158168
left = either.GetChildMemberWithName("left")
159-
lldbutil.check_variable(self, left, False, value='1234')
169+
lldbutil.check_variable(self, left, False, value="1234")
160170

161171
either2 = frame.FindVariable("either2")
162172
right = either2.GetChildMemberWithName("right")
163173
t = right.GetChildMemberWithName("t")
164174
one = t.GetChildMemberWithName("one")
165175
first = one.GetChildAtIndex(0)
166176
second = one.GetChildAtIndex(1)
167-
lldbutil.check_variable(self, first, False, value='209')
168-
lldbutil.check_variable(self, second, False, value='315')
177+
lldbutil.check_variable(self, first, False, value="209")
178+
lldbutil.check_variable(self, second, False, value="315")
169179
u = right.GetChildMemberWithName("u")
170180
two = u.GetChildMemberWithName("two")
171-
lldbutil.check_variable(self, two, False, value='one')
181+
lldbutil.check_variable(self, two, False, value="one")

0 commit comments

Comments
 (0)