-
Notifications
You must be signed in to change notification settings - Fork 15.2k
draft: [lldb] Upgrade ValueObject::GetData to return llvm::Expected #130516
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
Draft
wizardengineer
wants to merge
22
commits into
llvm:main
Choose a base branch
from
wizardengineer:Upgrade_ValueObject_GetData_to_return_llvm_Expected
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
161bdb3
Change ValueObject::GetData to return llvm::Expected
wizardengineer 7d886e2
clang format
wizardengineer c6d271b
more changes
wizardengineer ac8dacc
format
wizardengineer dc92635
third wave of refactoring
wizardengineer 69da662
third wave: clean up
wizardengineer 2a3d589
third wave: more clean up
wizardengineer c3ba85d
third wave: fixed the readablility
wizardengineer 613dc2a
third wave: fixed format
wizardengineer ae2276f
forth wave: ABI related code refactoring
wizardengineer 058a503
forth wave: fix format
wizardengineer 83dcfb0
forth wave: fix more formats
wizardengineer ea4f3c3
fix error message
wizardengineer 48e9535
error message fix
wizardengineer 437917b
s390x ABI error message fix
wizardengineer 9980b08
more fix error messaging and format
wizardengineer c075196
fixed logic in TypeFormat.cpp
wizardengineer 8fcb205
fixed more logic
wizardengineer 5f58a8b
fixed more logic
wizardengineer eda2415
made changes to type system and apple obj imp
wizardengineer 7a1c4be
simple fix RT impl
wizardengineer 02ecd56
fixed error
wizardengineer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -483,19 +483,18 @@ class EntityVariableBase : public Materializer::Entity { | |||||||||
| } | ||||||||||
|
|
||||||||||
| if (m_is_reference) { | ||||||||||
| DataExtractor valobj_extractor; | ||||||||||
| Status extract_error; | ||||||||||
| valobj_sp->GetData(valobj_extractor, extract_error); | ||||||||||
| auto valobj_extractor_or_err = valobj_sp->GetData(); | ||||||||||
|
|
||||||||||
| if (!extract_error.Success()) { | ||||||||||
| if (auto error = valobj_extractor_or_err.takeError()) { | ||||||||||
| err = Status::FromErrorStringWithFormat( | ||||||||||
| "couldn't read contents of reference variable %s: %s", | ||||||||||
| GetName().AsCString(), extract_error.AsCString()); | ||||||||||
| GetName().AsCString(), llvm::toString(std::move(error)).c_str()); | ||||||||||
| return; | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we just do this from now on?
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually, yes. You just have to draw the line somewhere for each commit. |
||||||||||
| } | ||||||||||
|
|
||||||||||
| lldb::offset_t offset = 0; | ||||||||||
| lldb::addr_t reference_addr = valobj_extractor.GetAddress(&offset); | ||||||||||
| lldb::addr_t reference_addr = | ||||||||||
| valobj_extractor_or_err->GetAddress(&offset); | ||||||||||
|
|
||||||||||
| Status write_error; | ||||||||||
| map.WritePointerToMemory(load_addr, reference_addr, write_error); | ||||||||||
|
|
@@ -523,13 +522,11 @@ class EntityVariableBase : public Materializer::Entity { | |||||||||
| return; | ||||||||||
| } | ||||||||||
| } else { | ||||||||||
| DataExtractor data; | ||||||||||
| Status extract_error; | ||||||||||
| valobj_sp->GetData(data, extract_error); | ||||||||||
| if (!extract_error.Success()) { | ||||||||||
| auto data_or_err = valobj_sp->GetData(); | ||||||||||
| if (auto error = data_or_err.takeError()) { | ||||||||||
| err = Status::FromErrorStringWithFormat( | ||||||||||
| "couldn't get the value of %s: %s", GetName().AsCString(), | ||||||||||
| extract_error.AsCString()); | ||||||||||
| llvm::toString(std::move(error)).c_str()); | ||||||||||
wizardengineer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
@@ -540,9 +537,9 @@ class EntityVariableBase : public Materializer::Entity { | |||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (data.GetByteSize() < | ||||||||||
| if (data_or_err->GetByteSize() < | ||||||||||
wizardengineer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| llvm::expectedToOptional(GetByteSize(scope)).value_or(0)) { | ||||||||||
| if (data.GetByteSize() == 0 && !LocationExpressionIsValid()) { | ||||||||||
| if (data_or_err->GetByteSize() == 0 && !LocationExpressionIsValid()) { | ||||||||||
| err = Status::FromErrorStringWithFormat( | ||||||||||
| "the variable '%s' has no location, " | ||||||||||
| "it may have been optimized out", | ||||||||||
|
|
@@ -553,7 +550,7 @@ class EntityVariableBase : public Materializer::Entity { | |||||||||
| ") is larger than the ValueObject's size (%" PRIu64 ")", | ||||||||||
| GetName().AsCString(), | ||||||||||
| llvm::expectedToOptional(GetByteSize(scope)).value_or(0), | ||||||||||
| data.GetByteSize()); | ||||||||||
| data_or_err->GetByteSize()); | ||||||||||
| } | ||||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
@@ -571,14 +568,14 @@ class EntityVariableBase : public Materializer::Entity { | |||||||||
| const bool zero_memory = false; | ||||||||||
|
|
||||||||||
| m_temporary_allocation = map.Malloc( | ||||||||||
| data.GetByteSize(), byte_align, | ||||||||||
| data_or_err->GetByteSize(), byte_align, | ||||||||||
| lldb::ePermissionsReadable | lldb::ePermissionsWritable, | ||||||||||
| IRMemoryMap::eAllocationPolicyMirror, zero_memory, alloc_error); | ||||||||||
|
|
||||||||||
| m_temporary_allocation_size = data.GetByteSize(); | ||||||||||
| m_temporary_allocation_size = data_or_err->GetByteSize(); | ||||||||||
|
|
||||||||||
| m_original_data = std::make_shared<DataBufferHeap>(data.GetDataStart(), | ||||||||||
| data.GetByteSize()); | ||||||||||
| m_original_data = std::make_shared<DataBufferHeap>( | ||||||||||
| data_or_err->GetDataStart(), data_or_err->GetByteSize()); | ||||||||||
|
|
||||||||||
| if (!alloc_error.Success()) { | ||||||||||
| err = Status::FromErrorStringWithFormat( | ||||||||||
|
|
@@ -589,8 +586,8 @@ class EntityVariableBase : public Materializer::Entity { | |||||||||
|
|
||||||||||
| Status write_error; | ||||||||||
|
|
||||||||||
| map.WriteMemory(m_temporary_allocation, data.GetDataStart(), | ||||||||||
| data.GetByteSize(), write_error); | ||||||||||
| map.WriteMemory(m_temporary_allocation, data_or_err->GetDataStart(), | ||||||||||
| data_or_err->GetByteSize(), write_error); | ||||||||||
|
|
||||||||||
| if (!write_error.Success()) { | ||||||||||
| err = Status::FromErrorStringWithFormat( | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a practical approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it seems to be fine. I don't think there should be any side-effects from this refactor.