Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lldb/include/lldb/DataFormatters/FormatManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class FormatManager : public IFormatChangeListener {
GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) {
FormattersMatchVector matches;
GetPossibleMatches(valobj, valobj.GetCompilerType(), use_dynamic, matches,
FormattersMatchCandidate::Flags(), true);
FormattersMatchCandidate::Flags(), true, true);
return matches;
}

Expand All @@ -180,6 +180,7 @@ class FormatManager : public IFormatChangeListener {
lldb::DynamicValueType use_dynamic,
FormattersMatchVector &entries,
FormattersMatchCandidate::Flags current_flags,
bool dereference_ptr = true,
bool root_level = false);

std::atomic<uint32_t> m_last_revision;
Expand Down
10 changes: 6 additions & 4 deletions lldb/source/DataFormatters/FormatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ void FormatManager::DisableAllCategories() {
void FormatManager::GetPossibleMatches(
ValueObject &valobj, CompilerType compiler_type,
lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries,
FormattersMatchCandidate::Flags current_flags, bool root_level) {
FormattersMatchCandidate::Flags current_flags, bool dereference_ptr,
bool root_level) {
compiler_type = compiler_type.GetTypeForFormatters();
ConstString type_name(compiler_type.GetTypeName());
// A ValueObject that couldn't be made correctly won't necessarily have a
Expand Down Expand Up @@ -222,14 +223,15 @@ void FormatManager::GetPossibleMatches(

if (compiler_type.IsPointerType()) {
CompilerType non_ptr_type = compiler_type.GetPointeeType();
GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries,
current_flags.WithStrippedPointer());
if (dereference_ptr)
GetPossibleMatches(valobj, non_ptr_type, use_dynamic, entries,
current_flags.WithStrippedPointer(), false);
if (non_ptr_type.IsTypedefType()) {
CompilerType deffed_pointed_type =
non_ptr_type.GetTypedefedType().GetPointerType();
// this is not exactly the usual meaning of stripping typedefs
GetPossibleMatches(valobj, deffed_pointed_type, use_dynamic, entries,
current_flags.WithStrippedTypedef());
current_flags.WithStrippedTypedef(), dereference_ptr);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@ def cleanup():
# the match.
self.expect("frame variable y", substrs=["(Foo &", ") y = 0x", "IntLRef"])
self.expect("frame variable z", substrs=["(Foo &&", ") z = 0x", "IntRRef"])

# Test lldb doesn't dereference pointer more than once.
# xp has type Foo**, so it can only uses summary for Foo* or int*, not
# summary for Foo or int.
self.expect("frame variable xp", substrs=["(Foo **) xp = 0x", "IntPointer"])

self.runCmd('type summary delete "int *"')
self.runCmd('type summary add --cascade true -s "MyInt" "int"')
self.expect("frame variable xp", substrs=["(Foo **) xp = 0x"])

self.runCmd('type summary add --cascade true -s "FooPointer" "Foo *"')
self.expect("frame variable xp", substrs=["(Foo **) xp = 0x", "FooPointer"])
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ int main() {
Foo* x = &lval;
Foo& y = lval;
Foo&& z = 1;

// Test lldb doesn't dereference pointer more than once.
Foo** xp = &x;
return 0; // Set breakpoint here
}

Loading