Skip to content

Commit 17210b1

Browse files
committed
fixup: Factor out the common code
1 parent ff536ae commit 17210b1

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

lldb/source/ValueObject/ValueObject.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -734,26 +734,22 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
734734
} break;
735735
case eAddressTypeLoad: {
736736
ExecutionContext exe_ctx(GetExecutionContextRef());
737-
Process *process = exe_ctx.GetProcessPtr();
738-
if (process && process->IsLiveDebugSession()) {
739-
heap_buf_ptr->SetByteSize(bytes);
740-
size_t bytes_read = process->ReadMemory(
737+
heap_buf_ptr->SetByteSize(bytes);
738+
size_t bytes_read = 0;
739+
if (Process *process = exe_ctx.GetProcessPtr();
740+
process && process->IsLiveDebugSession()) {
741+
bytes_read = process->ReadMemory(
741742
addr + offset, heap_buf_ptr->GetBytes(), bytes, error);
742-
if (error.Success() || bytes_read > 0) {
743-
data.SetData(data_sp);
744-
return bytes_read;
745-
}
746743
} else if (Target *target = exe_ctx.GetTargetPtr()) {
747744
Address target_addr;
748745
target_addr.SetLoadAddress(addr + offset, target);
749-
heap_buf_ptr->SetByteSize(bytes);
750-
size_t bytes_read =
746+
bytes_read =
751747
target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes,
752748
error, /*force_live_memory=*/true);
753-
if (error.Success() || bytes_read > 0) {
754-
data.SetData(data_sp);
755-
return bytes_read;
756-
}
749+
}
750+
if (error.Success() || bytes_read > 0) {
751+
data.SetData(data_sp);
752+
return bytes_read;
757753
}
758754
} break;
759755
case eAddressTypeHost: {

0 commit comments

Comments
 (0)