
This PR adds type summaries for `std::{string,wstring,u8string,u16string,u32string}` from the MSVC STL. See https://github.com/llvm/llvm-project/issues/24834 for the MSVC STL issue. The following changes were made: - `dotest.py` now detects if the MSVC STL is available. It does so by looking at the target triple, which is an additional argument passed from Lit. It specifically checks for `windows-msvc` to not match on `windows-gnu` (i.e. MinGW/Cygwin). - (The main part): Added support for summarizing `std::(w)string` from MSVC's STL. Because the type names from the libstdc++ (pre C++ 11) string types are the same as on MSVC's STL, `CXXCompositeSummaryFormat` is used with two entries, one for MSVC's STL and one for libstdc++. With MSVC's STL, `std::u{8,16,32}string` is also handled. These aren't handled for libstdc++, so I put them in `LoadMsvcStlFormatters`.
72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
"""Test SBValue::Persist"""
|
|
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class SBValuePersistTestCase(TestBase):
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
def test(self):
|
|
"""Test SBValue::Persist"""
|
|
self.build()
|
|
self.setTearDownCleanup()
|
|
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
|
|
|
|
lldbutil.run_break_set_by_source_regexp(self, "break here")
|
|
|
|
self.runCmd("run", RUN_SUCCEEDED)
|
|
|
|
# The stop reason of the thread should be breakpoint.
|
|
self.expect(
|
|
"thread list",
|
|
STOPPED_DUE_TO_BREAKPOINT,
|
|
substrs=["stopped", "stop reason = breakpoint"],
|
|
)
|
|
|
|
# This is the function to remove the custom formats in order to have a
|
|
# clean slate for the next test case.
|
|
def cleanup():
|
|
self.runCmd("type format clear", check=False)
|
|
self.runCmd("type summary clear", check=False)
|
|
self.runCmd("type filter clear", check=False)
|
|
self.runCmd("type synthetic clear", check=False)
|
|
|
|
# Execute the cleanup function during test case tear down.
|
|
self.addTearDownHook(cleanup)
|
|
|
|
foo = self.frame().FindVariable("foo")
|
|
bar = self.frame().FindVariable("bar")
|
|
baz = self.frame().FindVariable("baz")
|
|
|
|
self.assertTrue(foo.IsValid(), "foo is not valid")
|
|
self.assertTrue(bar.IsValid(), "bar is not valid")
|
|
self.assertTrue(baz.IsValid(), "baz is not valid")
|
|
|
|
fooPersist = foo.Persist()
|
|
barPersist = bar.Persist()
|
|
bazPersist = baz.Persist()
|
|
|
|
self.assertTrue(fooPersist.IsValid(), "fooPersist is not valid")
|
|
self.assertTrue(barPersist.IsValid(), "barPersist is not valid")
|
|
self.assertTrue(bazPersist.IsValid(), "bazPersist is not valid")
|
|
|
|
self.assertEqual(fooPersist.GetValueAsUnsigned(0), 10, "fooPersist != 10")
|
|
self.assertEqual(barPersist.GetPointeeData().sint32[0], 4, "barPersist != 4")
|
|
self.assertEqual(bazPersist.GetSummary(), '"85"', "bazPersist != 85")
|
|
|
|
self.runCmd("continue")
|
|
|
|
self.assertTrue(fooPersist.IsValid(), "fooPersist is not valid")
|
|
self.assertTrue(barPersist.IsValid(), "barPersist is not valid")
|
|
self.assertTrue(bazPersist.IsValid(), "bazPersist is not valid")
|
|
|
|
self.assertEqual(fooPersist.GetValueAsUnsigned(0), 10, "fooPersist != 10")
|
|
self.assertEqual(barPersist.GetPointeeData().sint32[0], 4, "barPersist != 4")
|
|
self.assertEqual(bazPersist.GetSummary(), '"85"', "bazPersist != 85")
|
|
|
|
self.expect("expr *(%s)" % (barPersist.GetName()), substrs=["= 4"])
|