Skip to content

[lldb] Return an llvm::Error from GetFrameBaseValue #111882

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
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 3 additions & 7 deletions lldb/include/lldb/Target/StackFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,10 @@ class StackFrame : public ExecutionContextScope,
/// \param [out] value
/// The address of the CFA for this frame, if available.
///
/// \param [out] error_ptr
/// If there is an error determining the CFA address, this may contain a
/// string explaining the failure.
///
/// \return
/// Returns true if the CFA value was successfully set in value. Some
/// frames may be unable to provide this value; they will return false.
bool GetFrameBaseValue(Scalar &value, Status *error_ptr);
/// If there is an error determining the CFA address, return an error
/// explaining the failure. Success otherwise.
llvm::Error GetFrameBaseValue(Scalar &value);

/// Get the DWARFExpressionList corresponding to the Canonical Frame Address.
///
Expand Down
14 changes: 6 additions & 8 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1780,14 +1780,12 @@ llvm::Expected<Value> DWARFExpression::Evaluate(
if (exe_ctx) {
if (frame) {
Scalar value;
Status fb_err;
if (frame->GetFrameBaseValue(value, &fb_err)) {
int64_t fbreg_offset = opcodes.GetSLEB128(&offset);
value += fbreg_offset;
stack.push_back(value);
stack.back().SetValueType(Value::ValueType::LoadAddress);
} else
return fb_err.ToError();
if (llvm::Error err = frame->GetFrameBaseValue(value))
return err;
int64_t fbreg_offset = opcodes.GetSLEB128(&offset);
value += fbreg_offset;
stack.push_back(value);
stack.back().SetValueType(Value::ValueType::LoadAddress);
} else {
return llvm::createStringError(
"invalid stack frame in context for DW_OP_fbreg opcode");
Expand Down
13 changes: 6 additions & 7 deletions lldb/source/Target/StackFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,12 +1079,12 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
return valobj_sp;
}

bool StackFrame::GetFrameBaseValue(Scalar &frame_base, Status *error_ptr) {
llvm::Error StackFrame::GetFrameBaseValue(Scalar &frame_base) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_cfa_is_valid) {
m_frame_base_error = Status::FromErrorString(
"No frame base available for this historical stack frame.");
return false;
return m_frame_base_error.ToError();
}

if (m_flags.IsClear(GOT_FRAME_BASE)) {
Expand Down Expand Up @@ -1113,12 +1113,11 @@ bool StackFrame::GetFrameBaseValue(Scalar &frame_base, Status *error_ptr) {
}
}

if (m_frame_base_error.Success())
frame_base = m_frame_base;
if (m_frame_base_error.Fail())
return m_frame_base_error.ToError();

if (error_ptr)
*error_ptr = m_frame_base_error.Clone();
return m_frame_base_error.Success();
frame_base = m_frame_base;
return llvm::Error::success();
}

DWARFExpressionList *StackFrame::GetFrameBaseExpression(Status *error_ptr) {
Expand Down
Loading