diff options
| author | bzcheeseman <aman.lachapelle@gmail.com> | 2026-01-28 22:20:00 -0800 |
|---|---|---|
| committer | bzcheeseman <aman.lachapelle@gmail.com> | 2026-01-29 08:32:50 -0800 |
| commit | ea2ba05d0cecd8418c0916d35e17ed7692973d38 (patch) | |
| tree | 3142c32ef578203feb2138f6c6a42ab1795da88d | |
| parent | c3d0c3735f726086a9b60e18629e74d9a855323c (diff) | |
| download | llvm-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
| -rw-r--r-- | lldb/source/Commands/CommandObjectDWIMPrint.cpp | 25 |
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. // |
