Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
23 changes: 15 additions & 8 deletions lldb/source/ValueObject/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,15 +734,22 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
} break;
case eAddressTypeLoad: {
ExecutionContext exe_ctx(GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
if (process) {
heap_buf_ptr->SetByteSize(bytes);
size_t bytes_read = process->ReadMemory(
heap_buf_ptr->SetByteSize(bytes);
size_t bytes_read = 0;
if (Process *process = exe_ctx.GetProcessPtr();
process && process->IsLiveDebugSession()) {
bytes_read = process->ReadMemory(
addr + offset, heap_buf_ptr->GetBytes(), bytes, error);
if (error.Success() || bytes_read > 0) {
data.SetData(data_sp);
return bytes_read;
}
} else if (Target *target = exe_ctx.GetTargetPtr()) {
Address target_addr;
target_addr.SetLoadAddress(addr + offset, target);
bytes_read =
target->ReadMemory(target_addr, heap_buf_ptr->GetBytes(), bytes,
error, /*force_live_memory=*/true);
}
if (error.Success() || bytes_read > 0) {
data.SetData(data_sp);
return bytes_read;
}
} break;
case eAddressTypeHost: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,34 @@ def test_get_core_file_api(self):
self.assertEqual(process.GetCoreFile().GetFilename(), core_file_name)
self.dbg.DeleteTarget(target)

@skipIfLLVMTargetMissing("X86")
def test_read_only_cstring(self):
"""
Test that we can show the summary for a cstring variable that points
to a read-only memory page which is not dumped to a core file.
"""
target = self.dbg.CreateTarget("altmain2.out")
process = target.LoadCore("altmain2.core")
self.assertTrue(process, PROCESS_IS_VALID)

frame = process.GetSelectedThread().GetFrameAtIndex(0)
self.assertEqual(frame.GetFunctionName(), "_start")

var = frame.FindVariable("F")

# The variable points to a read-only segment that is not dumped to
# the core file and thus 'process.ReadCStringFromMemory()' cannot get
# the value.
error = lldb.SBError()
cstr = process.ReadCStringFromMemory(var.GetValueAsUnsigned(), 256, error)
self.assertFailure(error, error_str="core file does not contain 0x804a000")
self.assertEqual(cstr, "")

# Nevertheless, when getting the summary, the value can be read from the
# application binary.
cstr = var.GetSummary()
self.assertEqual(cstr, '"_start"')

def check_memory_regions(self, process, region_count):
region_list = process.GetMemoryRegions()
self.assertEqual(region_list.GetSize(), region_count)
Expand Down
Binary file not shown.
Binary file not shown.
Loading