Skip to content

[lldb][Commands] Fix memory find for Swift expressions #143860

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 2 commits into from
Jun 12, 2025
Merged
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
13 changes: 10 additions & 3 deletions lldb/source/Commands/CommandObjectMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,10 @@ class CommandObjectMemoryRead : public CommandObjectParsed {
#include "CommandOptions.inc"

static llvm::Error CopyExpressionResult(ValueObject &result,
DataBufferHeap &buffer) {
DataBufferHeap &buffer,
ExecutionContextScope *scope) {
uint64_t value = result.GetValueAsUnsigned(0);
auto size_or_err = result.GetCompilerType().GetByteSize(nullptr);
auto size_or_err = result.GetCompilerType().GetByteSize(scope);
if (!size_or_err)
return size_or_err.takeError();

Expand Down Expand Up @@ -928,6 +929,11 @@ EvaluateExpression(llvm::StringRef expression, StackFrame &frame,
return llvm::createStringError(
"expression evaluation failed. pass a string instead");

result_sp = result_sp->GetQualifiedRepresentationIfAvailable(
result_sp->GetDynamicValueType(), /*synthValue=*/true);
if (!result_sp)
return llvm::createStringError("failed to get dynamic result type");

return result_sp;
}

Expand Down Expand Up @@ -1082,7 +1088,8 @@ class CommandObjectMemoryFind : public CommandObjectParsed {

ValueObjectSP result_sp = *result_or_err;

if (auto err = CopyExpressionResult(*result_sp, buffer)) {
if (auto err = CopyExpressionResult(*result_sp, buffer,
m_exe_ctx.GetFramePtr())) {
result.AppendError(llvm::toString(std::move(err)));
return;
}
Expand Down
Loading