diff options
| author | Jorge Gorbe Moya <jgorbe@google.com> | 2023-01-26 14:23:41 -0800 |
|---|---|---|
| committer | Jorge Gorbe Moya <jgorbe@google.com> | 2023-01-27 10:15:35 -0800 |
| commit | 805600c7d573cf88cf035d01a2ea9389fc24d435 (patch) | |
| tree | c7725799d5dc8626320ac33e6816ddd0b5ca3bc6 /lldb/source/API/SBSection.cpp | |
| parent | 41e776386dd5930565b338b776816c48245f52f3 (diff) | |
[lldb] Make SBSection::GetSectionData call Section::GetSectionData.
`SBSection::GetSectionData` and `Section::GetSectionData` are
implemented differently, and the `SBSection` method doesn't handle
compressed sections correctly.
Differential Revision: https://reviews.llvm.org/D142672
Diffstat (limited to 'lldb/source/API/SBSection.cpp')
| -rw-r--r-- | lldb/source/API/SBSection.cpp | 33 |
1 files changed, 4 insertions, 29 deletions
diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp index 3a9cf20e484a..b7b94f3ece1a 100644 --- a/lldb/source/API/SBSection.cpp +++ b/lldb/source/API/SBSection.cpp @@ -182,35 +182,10 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { SBData sb_data; SectionSP section_sp(GetSP()); if (section_sp) { - const uint64_t sect_file_size = section_sp->GetFileSize(); - if (sect_file_size > 0) { - ModuleSP module_sp(section_sp->GetModule()); - if (module_sp) { - ObjectFile *objfile = module_sp->GetObjectFile(); - if (objfile) { - const uint64_t sect_file_offset = - objfile->GetFileOffset() + section_sp->GetFileOffset(); - const uint64_t file_offset = sect_file_offset + offset; - uint64_t file_size = size; - if (file_size == UINT64_MAX) { - file_size = section_sp->GetByteSize(); - if (file_size > offset) - file_size -= offset; - else - file_size = 0; - } - auto data_buffer_sp = FileSystem::Instance().CreateDataBuffer( - objfile->GetFileSpec().GetPath(), file_size, file_offset); - if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) { - DataExtractorSP data_extractor_sp( - new DataExtractor(data_buffer_sp, objfile->GetByteOrder(), - objfile->GetAddressByteSize())); - - sb_data.SetOpaque(data_extractor_sp); - } - } - } - } + DataExtractor section_data; + section_sp->GetSectionData(section_data); + sb_data.SetOpaque( + std::make_shared<DataExtractor>(section_data, offset, size)); } return sb_data; } |
