Skip to content

Commit cd805a7

Browse files
authored
[LLDB] Run MSVC STL (forward-)list test with PDB (#166953)
Since PDB doesn't have template information, we need to get the element type from somewhere else. I'm using the type of `_Myval` in a list node, which holds the element type.
1 parent c0eac77 commit cd805a7

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ class MsvcStlListFrontEnd : public AbstractListFrontEnd<StlType::MsvcStl> {
203203
ValueObject *m_tail = nullptr;
204204
};
205205

206+
/// Gets the (forward-)list element type from the head node instead of the
207+
/// template arguments. This is needed with PDB as it doesn't have info about
208+
/// the template arguments.
209+
CompilerType GetMsvcStlElementTypeFromHead(ValueObject &head) {
210+
auto val_sp = head.GetChildMemberWithName("_Myval");
211+
if (val_sp)
212+
return val_sp->GetCompilerType();
213+
return CompilerType();
214+
}
215+
206216
} // end anonymous namespace
207217

208218
template <StlType Stl>
@@ -530,6 +540,10 @@ lldb::ChildCacheState MsvcStlForwardListFrontEnd::Update() {
530540
m_backend.GetChildAtNamePath({"_Mypair", "_Myval2", "_Myhead"}))
531541
m_head = head_sp.get();
532542

543+
// With PDB, we can't get the element type from the template arguments
544+
if (!m_element_type && m_head)
545+
m_element_type = GetMsvcStlElementTypeFromHead(*m_head);
546+
533547
return ChildCacheState::eRefetch;
534548
}
535549

@@ -606,6 +620,10 @@ lldb::ChildCacheState MsvcStlListFrontEnd::Update() {
606620
m_head = first.get();
607621
m_tail = last.get();
608622

623+
// With PDB, we can't get the element type from the template arguments
624+
if (!m_element_type && m_head)
625+
m_element_type = GetMsvcStlElementTypeFromHead(*m_head);
626+
609627
return lldb::ChildCacheState::eRefetch;
610628
}
611629

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/forward_list/TestDataFormatterGenericForwardList.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010

1111
class TestDataFormatterGenericForwardList(TestBase):
12+
TEST_WITH_PDB_DEBUG_INFO = True
13+
1214
def setUp(self):
1315
TestBase.setUp(self)
1416
self.line = line_number("main.cpp", "// break here")

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/TestDataFormatterGenericList.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111

1212
class GenericListDataFormatterTestCase(TestBase):
13+
TEST_WITH_PDB_DEBUG_INFO = True
14+
1315
def setUp(self):
1416
# Call super's setUp().
1517
TestBase.setUp(self)

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/list/loop/TestDataFormatterGenericListLoop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
class GenericListDataFormatterTestCase(TestBase):
14+
TEST_WITH_PDB_DEBUG_INFO = True
1415
NO_DEBUG_INFO_TESTCASE = True
1516

1617
def do_test_with_run_command(self):

0 commit comments

Comments
 (0)