[formatters] Capping size limitation avoidance for the libcxx and libcpp bitset data formatters.

This diff is avoiding the size limitation introduced by the capping size for the libcxx and libcpp bitset data formatters.

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D114461
This commit is contained in:
Danil Stefaniuc 2021-11-23 14:02:05 -08:00 committed by Walter Erquinigo
parent a48501150b
commit 193bf2e820
3 changed files with 13 additions and 5 deletions

View File

@ -81,12 +81,11 @@ bool GenericBitsetFrontEnd::Update() {
TargetSP target_sp = m_backend.GetTargetSP(); TargetSP target_sp = m_backend.GetTargetSP();
if (!target_sp) if (!target_sp)
return false; return false;
size_t capping_size = target_sp->GetMaximumNumberOfChildrenToDisplay();
size_t size = 0; size_t size = 0;
if (auto arg = m_backend.GetCompilerType().GetIntegralTemplateArgument(0)) if (auto arg = m_backend.GetCompilerType().GetIntegralTemplateArgument(0))
size = arg->value.getLimitedValue(capping_size); size = arg->value.getLimitedValue();
m_elements.assign(size, ValueObjectSP()); m_elements.assign(size, ValueObjectSP());
m_first = m_backend.GetChildMemberWithName(GetDataContainerMemberName(), true) m_first = m_backend.GetChildMemberWithName(GetDataContainerMemberName(), true)

View File

@ -21,7 +21,7 @@ class GenericBitsetDataFormatterTestCase(TestBase):
def setUp(self): def setUp(self):
TestBase.setUp(self) TestBase.setUp(self)
primes = [1]*300 primes = [1]*1000
primes[0] = primes[1] = 0 primes[0] = primes[1] = 0
for i in range(2, len(primes)): for i in range(2, len(primes)):
for j in range(2*i, len(primes), i): for j in range(2*i, len(primes), i):
@ -58,7 +58,8 @@ class GenericBitsetDataFormatterTestCase(TestBase):
self.check("empty", 0, VALUE) self.check("empty", 0, VALUE)
self.check("small", 13, VALUE) self.check("small", 13, VALUE)
self.check("large", 70, VALUE) self.check("medium", 70, VALUE)
self.check("large", 1000, VALUE)
@add_test_categories(["libstdcxx"]) @add_test_categories(["libstdcxx"])
def test_value_libstdcpp(self): def test_value_libstdcpp(self):
@ -84,6 +85,11 @@ class GenericBitsetDataFormatterTestCase(TestBase):
self.check("ref", 70, REFERENCE) self.check("ref", 70, REFERENCE)
self.check("ptr", 70, POINTER) self.check("ptr", 70, POINTER)
lldbutil.continue_to_breakpoint(process, bkpt)
self.check("ref", 1000, REFERENCE)
self.check("ptr", 1000, POINTER)
@add_test_categories(["libstdcxx"]) @add_test_categories(["libstdcxx"])
def test_ptr_and_ref_libstdcpp(self): def test_ptr_and_ref_libstdcpp(self):
self.do_test_ptr_and_ref(USE_LIBSTDCPP) self.do_test_ptr_and_ref(USE_LIBSTDCPP)

View File

@ -20,9 +20,12 @@ int main() {
std::bitset<0> empty; std::bitset<0> empty;
std::bitset<13> small; std::bitset<13> small;
fill(small); fill(small);
std::bitset<70> large; std::bitset<70> medium;
fill(medium);
std::bitset<1000> large;
fill(large); fill(large);
by_ref_and_ptr(small, &small); // break here by_ref_and_ptr(small, &small); // break here
by_ref_and_ptr(medium, &medium);
by_ref_and_ptr(large, &large); by_ref_and_ptr(large, &large);
return 0; return 0;
} }