aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectDWIMPrint.cpp
diff options
context:
space:
mode:
authorbzcheeseman <aman.lachapelle@gmail.com>2026-01-28 22:20:00 -0800
committerbzcheeseman <aman.lachapelle@gmail.com>2026-01-28 22:20:00 -0800
commita9894b228cd93f98845fd1ded2c16ac90d135675 (patch)
treebdf8b2d4bda22f4678b7715674cda85ec18ec8f4 /lldb/source/Commands/CommandObjectDWIMPrint.cpp
parent10f2611c2173783efae8aebc32d1515013271b64 (diff)
downloadllvm-users/bzcheeseman/stack/7.zip
llvm-users/bzcheeseman/stack/7.tar.gz
llvm-users/bzcheeseman/stack/7.tar.bz2
[lldb] Make `print` delegate to synthetic frames.users/bzcheeseman/stack/7
This patch is more of a proposal in that it's a pretty dramatic change to the way that `print` works. It completely delegates getting values to the frame if the frame is synthetic, and does not redirect at all if the frame fails. For this patch, the main goal was to allow the synthetic frame to bubble up its own errors in expression evaluation, rather than having errors come back with an extra "could not find identifier <blah>" or worse, simply get swallowed. If there's a better way to handle this, I'm more than happy to change this as long as the core goals of 'delegate variable/value extraction to the synthetic frame', and 'allow the synthetic frame to give back errors that are displayed to the user' can be met. stack-info: PR: https://github.com/llvm/llvm-project/pull/178602, branch: users/bzcheeseman/stack/7
Diffstat (limited to 'lldb/source/Commands/CommandObjectDWIMPrint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectDWIMPrint.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 40f00c9..68bb872 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;
@@ -155,6 +154,28 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
result.SetStatus(eReturnStatusSuccessFinishResult);
};
+ // If the frame is synthetic, then we handle all printing through the
+ // GetValueForVariableExpressionPath. This is so that the synthetic frame has
+ // the ability to take over anything it needs to.
+ if (frame && frame->IsSynthetic()) {
+ VariableSP var_sp;
+ Status status;
+ auto valobj_sp = frame->GetValueForVariableExpressionPath(
+ expr, eval_options.GetUseDynamic(),
+ StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, var_sp,
+ status);
+
+ // Something failed, print the error and return immediately.
+ if (!status.Success()) {
+ result.AppendError(status.AsCString());
+ return;
+ }
+
+ // Otherwise, simply print the object.
+ dump_val_object(*valobj_sp);
+ return;
+ }
+
// First, try `expr` as a _limited_ frame variable expression path: only the
// dot operator (`.`) is permitted for this case.
//