Skip to content

[lldb] UpdateFormatsIfNeeded should respect the dynamic value type #93262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

augusto2112
Copy link
Contributor

UpdateFormatsIfNeeded has hardcoded the call to GetFormat with no dynamic values. GetFormat will try to find the synthetic children of the ValueObject, and passing the wrong one can fail, which can be bad for performance but should not be user visible. Fix the performace bug by passing the dynamic value type of the ValueObject.

rdar://122506593

UpdateFormatsIfNeeded has hardcoded the call to GetFormat with no
dynamic values. GetFormat will try to find the synthetic children of the
ValueObject, and passing the wrong one can fail, which can be bad for
performance but should not be user visible. Fix the performace bug by
passing the dynamic value type of the ValueObject.

rdar://122506593
@augusto2112 augusto2112 requested a review from jimingham May 24, 2024 01:14
@augusto2112 augusto2112 requested a review from JDevlieghere as a code owner May 24, 2024 01:14
@llvmbot llvmbot added the lldb label May 24, 2024
@llvmbot
Copy link
Member

llvmbot commented May 24, 2024

@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)

Changes

UpdateFormatsIfNeeded has hardcoded the call to GetFormat with no dynamic values. GetFormat will try to find the synthetic children of the ValueObject, and passing the wrong one can fail, which can be bad for performance but should not be user visible. Fix the performace bug by passing the dynamic value type of the ValueObject.

rdar://122506593


Full diff: https://github.com/llvm/llvm-project/pull/93262.diff

1 Files Affected:

  • (modified) lldb/source/Core/ValueObject.cpp (+1-1)
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 1443d9dfc3280..c5c434a941b34 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -216,7 +216,7 @@ bool ValueObject::UpdateFormatsIfNeeded() {
     m_last_format_mgr_revision = DataVisualization::GetCurrentRevision();
     any_change = true;
 
-    SetValueFormat(DataVisualization::GetFormat(*this, eNoDynamicValues));
+    SetValueFormat(DataVisualization::GetFormat(*this, GetDynamicValueType()));
     SetSummaryFormat(
         DataVisualization::GetSummaryFormat(*this, GetDynamicValueType()));
     SetSyntheticChildren(

Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I knew why the original code was ignoring GetDynamicValueType here, when it does use it on the very next line... The old code looks wrong to me. However, the places where dynamic values matter for the Format choice are uncommon - you generally set formats on scalars, and scalars don't have dynamic types... So maybe this was just an expression of "how could this matter"?

In any case, this does seem more correct on the face of it.

@augusto2112 augusto2112 merged commit 59e9160 into llvm:main Jun 5, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants