-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Revert "[lldb] Fallback to expression eval when Dump of variable fails in dwim-print" #153824
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
kastiglione
merged 1 commit into
main
from
revert-151374-lldb-Fallback-to-expression-eval-when-Dump-of-variable-fails-in-dwim-print
Aug 15, 2025
Merged
Revert "[lldb] Fallback to expression eval when Dump of variable fails in dwim-print" #153824
kastiglione
merged 1 commit into
main
from
revert-151374-lldb-Fallback-to-expression-eval-when-Dump-of-variable-fails-in-dwim-print
Aug 15, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s in dwi…" This reverts commit f23c10f.
Member
|
@llvm/pr-subscribers-lldb Author: Dave Lee (kastiglione) ChangesReverts llvm/llvm-project#151374 Superseded by #152417 Full diff: https://github.com/llvm/llvm-project/pull/153824.diff 1 Files Affected:
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 5e864a4cc52c2..0d9eb45732161 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -18,14 +18,11 @@
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/LLDBLog.h"
-#include "lldb/Utility/Log.h"
#include "lldb/ValueObject/ValueObject.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
#include <regex>
@@ -135,22 +132,27 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
};
// Dump `valobj` according to whether `po` was requested or not.
- auto dump_val_object = [&](ValueObject &valobj) -> Error {
+ auto dump_val_object = [&](ValueObject &valobj) {
if (is_po) {
StreamString temp_result_stream;
- if (Error err = valobj.Dump(temp_result_stream, dump_options))
- return err;
+ if (llvm::Error error = valobj.Dump(temp_result_stream, dump_options)) {
+ result.AppendError(toString(std::move(error)));
+ return;
+ }
llvm::StringRef output = temp_result_stream.GetString();
maybe_add_hint(output);
result.GetOutputStream() << output;
} else {
- if (Error err = valobj.Dump(result.GetOutputStream(), dump_options))
- return err;
+ llvm::Error error =
+ valobj.Dump(result.GetOutputStream(), dump_options);
+ if (error) {
+ result.AppendError(toString(std::move(error)));
+ return;
+ }
}
m_interpreter.PrintWarningsIfNecessary(result.GetOutputStream(),
m_cmd_name);
result.SetStatus(eReturnStatusSuccessFinishResult);
- return Error::success();
};
// First, try `expr` as a _limited_ frame variable expression path: only the
@@ -184,13 +186,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
expr);
}
- Error err = dump_val_object(*valobj_sp);
- if (!err)
- return;
-
- // Dump failed, continue on to expression evaluation.
- LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), std::move(err),
- "could not print frame variable '{1}': {0}", expr);
+ dump_val_object(*valobj_sp);
+ return;
}
}
@@ -199,14 +196,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
if (auto *state = target.GetPersistentExpressionStateForLanguage(language))
if (auto var_sp = state->GetVariable(expr))
if (auto valobj_sp = var_sp->GetValueObject()) {
- Error err = dump_val_object(*valobj_sp);
- if (!err)
- return;
-
- // Dump failed, continue on to expression evaluation.
- LLDB_LOG_ERROR(GetLog(LLDBLog::Expressions), std::move(err),
- "could not print persistent variable '{1}': {0}",
- expr);
+ dump_val_object(*valobj_sp);
+ return;
}
// Third, and lastly, try `expr` as a source expression to evaluate.
@@ -257,12 +248,10 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
result.AppendNoteWithFormatv("ran `expression {0}{1}`", flags, expr);
}
- if (valobj_sp->GetError().GetError() != UserExpression::kNoResult) {
- if (Error err = dump_val_object(*valobj_sp))
- result.SetError(std::move(err));
- } else {
+ if (valobj_sp->GetError().GetError() != UserExpression::kNoResult)
+ dump_val_object(*valobj_sp);
+ else
result.SetStatus(eReturnStatusSuccessFinishNoResult);
- }
if (suppress_result)
if (auto result_var_sp =
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp -- lldb/source/Commands/CommandObjectDWIMPrint.cppView the diff from clang-format here.diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 0d9eb4573..628d4d8ea 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -143,8 +143,7 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
maybe_add_hint(output);
result.GetOutputStream() << output;
} else {
- llvm::Error error =
- valobj.Dump(result.GetOutputStream(), dump_options);
+ llvm::Error error = valobj.Dump(result.GetOutputStream(), dump_options);
if (error) {
result.AppendError(toString(std::move(error)));
return;
|
Contributor
Author
|
the formatting check is complaining about the code as it originally was. To keep a clean revert, I am disregarding it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts #151374
Superseded by #152417