[lldb] Fix a quirk in SBValue::GetDescription (#75793)

The function was using the default version of ValueObject::Dump, which
has a default of using the synthetic-ness of the top-level value for
determining whether to print _all_ values as synthetic. This resulted in
some unusual behavior, where e.g. a std::vector is stringified as
synthetic if its dumped as the top level object, but in its raw form if
it is a member of a struct without a pretty printer.

The SBValue class already has properties which determine whether one
should be looking at the synthetic view of the object (and also whether
to use dynamic types), so it seems more natural to use that.
This commit is contained in:
Pavel Labath
2023-12-18 21:23:03 +01:00
committed by GitHub
parent d23188d5c8
commit 927926b8af
4 changed files with 41 additions and 3 deletions

View File

@@ -0,0 +1,3 @@
CXX_SOURCES := main.cpp
include Makefile.rules

View File

@@ -0,0 +1,19 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestSBValueSynthetic(TestBase):
NO_DEBUG_INFO_TESTCASE = True
def test_str(self):
self.build()
lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.cpp")
)
vector = self.frame().FindVariable("vector")
has_vector = self.frame().FindVariable("has_vector")
self.expect(str(vector), exe=False, substrs=["42", "47"])
self.expect(str(has_vector), exe=False, substrs=["42", "47"])

View File

@@ -0,0 +1,11 @@
#include <vector>
struct HasVector {
std::vector<int> v;
};
int main() {
std::vector<int> vector = {42, 47};
HasVector has_vector = {vector};
return 0; // break here
}