Skip to content
Merged
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions lldb/source/Core/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
else
data.SetAddressByteSize(sizeof(void *));

if (!type_size)
return Status::FromErrorString("type does not have a size");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is a regression from (#151350):

Author: Ilia Kuklin <[email protected]>
Date:   Wed Aug 6 14:32:19 2025 +0500

    [lldb] Add `ValueObject::CreateValueObjectFromScalar` and fix `Scalar::GetData` (#151350)
    
    Add `ValueObject::CreateValueObjectFromScalar` function and adjust
    `Scalar::GetData` to be able to both extend and truncate the data bytes
    in Scalar to the specified size.

Previously we would return an error if type_size was unset.

So this pretty much brings us back to previous behaviour.

Any way we can test this in lldb/unittests/Utility/ScalarTest.cpp? I guess the tricky bit will be creating a type with invalid byte_size. Maybe with an incomplete AST type? Haven't looked at what's available in that test though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about the rest, but testing something about the ValueObject class inside ScalarTest.cpp sounds very wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be missing something but I was thinking just testing Value::GetValueAsData. Which we could accomplish by creating a Scalar.

The PR I linked was fixing something for ValueObject, but did so by adjusting something in Value. Maybe that's where the confusion came from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need an incomplete type here. A value without a compiler type should suffice. So something like

Value v(Scalar(42));
DataExtractor extractor;
Status status = v.GetValueAsData(nullptr, extractor, nullptr);
ASSERT_TRUE(status.Fail());

I could add a file in unittests/ValueObject. There are no unittests that call GetValueAsData yet.


uint32_t result_byte_size = *type_size;
if (m_value.GetData(data, result_byte_size))
return error; // Success;
Expand Down
Loading