Skip to content

Commit f2ea125

Browse files
committed
[lldb] Change CreateMemoryInstance to take a WritableDataBuffer
Change the CreateMemoryInstance interface to take a WritableDataBuffer. Differential revision: https://reviews.llvm.org/D123073
1 parent fc54427 commit f2ea125

20 files changed

+51
-51
lines changed

lldb/include/lldb/Symbol/ObjectFile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
116116
/// more than one architecture or object.
117117
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr,
118118
lldb::offset_t file_offset, lldb::offset_t length,
119-
const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset);
119+
lldb::DataBufferSP data_sp, lldb::offset_t data_offset);
120120

121121
ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp,
122-
lldb::addr_t header_addr, lldb::DataBufferSP &data_sp);
122+
lldb::addr_t header_addr, lldb::DataBufferSP data_sp);
123123

124124
/// Destructor.
125125
///
@@ -183,7 +183,7 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
183183
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp,
184184
const lldb::ProcessSP &process_sp,
185185
lldb::addr_t header_addr,
186-
lldb::DataBufferSP &file_data_sp);
186+
lldb::WritableDataBufferSP file_data_sp);
187187

188188
static size_t
189189
GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset,

lldb/include/lldb/lldb-private-interfaces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef ObjectFile *(*ObjectFileCreateInstance)(const lldb::ModuleSP &module_sp,
5151
lldb::offset_t file_offset,
5252
lldb::offset_t length);
5353
typedef ObjectFile *(*ObjectFileCreateMemoryInstance)(
54-
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
54+
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
5555
const lldb::ProcessSP &process_sp, lldb::addr_t offset);
5656
typedef bool (*ObjectFileSaveCore)(const lldb::ProcessSP &process_sp,
5757
const FileSpec &outfile,

lldb/source/Core/Module.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,15 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
304304
std::lock_guard<std::recursive_mutex> guard(m_mutex);
305305
if (process_sp) {
306306
m_did_load_objfile = true;
307-
auto data_up = std::make_unique<DataBufferHeap>(size_to_read, 0);
307+
std::shared_ptr<DataBufferHeap> data_sp =
308+
std::make_shared<DataBufferHeap>(size_to_read, 0);
308309
Status readmem_error;
309310
const size_t bytes_read =
310-
process_sp->ReadMemory(header_addr, data_up->GetBytes(),
311-
data_up->GetByteSize(), readmem_error);
311+
process_sp->ReadMemory(header_addr, data_sp->GetBytes(),
312+
data_sp->GetByteSize(), readmem_error);
312313
if (bytes_read < size_to_read)
313-
data_up->SetByteSize(bytes_read);
314-
if (data_up->GetByteSize() > 0) {
315-
DataBufferSP data_sp(data_up.release());
314+
data_sp->SetByteSize(bytes_read);
315+
if (data_sp->GetByteSize() > 0) {
316316
m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp,
317317
header_addr, data_sp);
318318
if (m_objfile_sp) {

lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ObjectFile *ObjectFileBreakpad::CreateInstance(
8484
}
8585

8686
ObjectFile *ObjectFileBreakpad::CreateMemoryInstance(
87-
const ModuleSP &module_sp, DataBufferSP data_sp,
87+
const ModuleSP &module_sp, WritableDataBufferSP data_sp,
8888
const ProcessSP &process_sp, addr_t header_addr) {
8989
return nullptr;
9090
}

lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ObjectFileBreakpad : public ObjectFile {
3232
lldb::offset_t file_offset, lldb::offset_t length);
3333

3434
static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
35-
lldb::DataBufferSP data_sp,
35+
lldb::WritableDataBufferSP data_sp,
3636
const lldb::ProcessSP &process_sp,
3737
lldb::addr_t header_addr);
3838

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp,
390390
}
391391

392392
ObjectFile *ObjectFileELF::CreateMemoryInstance(
393-
const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
393+
const lldb::ModuleSP &module_sp, WritableDataBufferSP data_sp,
394394
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
395395
if (data_sp && data_sp->GetByteSize() > (llvm::ELF::EI_NIDENT)) {
396396
const uint8_t *magic = data_sp->GetBytes();
@@ -639,7 +639,7 @@ size_t ObjectFileELF::GetModuleSpecifications(
639639
// ObjectFile protocol
640640

641641
ObjectFileELF::ObjectFileELF(const lldb::ModuleSP &module_sp,
642-
DataBufferSP &data_sp, lldb::offset_t data_offset,
642+
DataBufferSP data_sp, lldb::offset_t data_offset,
643643
const FileSpec *file, lldb::offset_t file_offset,
644644
lldb::offset_t length)
645645
: ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset) {
@@ -648,7 +648,7 @@ ObjectFileELF::ObjectFileELF(const lldb::ModuleSP &module_sp,
648648
}
649649

650650
ObjectFileELF::ObjectFileELF(const lldb::ModuleSP &module_sp,
651-
DataBufferSP &header_data_sp,
651+
DataBufferSP header_data_sp,
652652
const lldb::ProcessSP &process_sp,
653653
addr_t header_addr)
654654
: ObjectFile(module_sp, process_sp, header_addr, header_data_sp) {}

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ObjectFileELF : public lldb_private::ObjectFile {
7373
lldb::offset_t file_offset, lldb::offset_t length);
7474

7575
static lldb_private::ObjectFile *CreateMemoryInstance(
76-
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
76+
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
7777
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
7878

7979
static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
@@ -164,12 +164,12 @@ class ObjectFileELF : public lldb_private::ObjectFile {
164164
uint64_t Offset);
165165

166166
private:
167-
ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
167+
ObjectFileELF(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
168168
lldb::offset_t data_offset, const lldb_private::FileSpec *file,
169169
lldb::offset_t offset, lldb::offset_t length);
170170

171171
ObjectFileELF(const lldb::ModuleSP &module_sp,
172-
lldb::DataBufferSP &header_data_sp,
172+
lldb::DataBufferSP header_data_sp,
173173
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
174174

175175
typedef std::vector<elf::ELFProgramHeader> ProgramHeaderColl;

lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ObjectFile *ObjectFileJIT::CreateInstance(const lldb::ModuleSP &module_sp,
6565
}
6666

6767
ObjectFile *ObjectFileJIT::CreateMemoryInstance(const lldb::ModuleSP &module_sp,
68-
DataBufferSP data_sp,
68+
WritableDataBufferSP data_sp,
6969
const ProcessSP &process_sp,
7070
lldb::addr_t header_addr) {
7171
// JIT'ed object file is backed by the ObjectFileJITDelegate, never read from

lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ObjectFileJIT : public lldb_private::ObjectFile {
3838
lldb::offset_t file_offset, lldb::offset_t length);
3939

4040
static lldb_private::ObjectFile *CreateMemoryInstance(
41-
const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
41+
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
4242
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
4343

4444
static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ ObjectFile *ObjectFileMachO::CreateInstance(const lldb::ModuleSP &module_sp,
848848
}
849849

850850
ObjectFile *ObjectFileMachO::CreateMemoryInstance(
851-
const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
851+
const lldb::ModuleSP &module_sp, WritableDataBufferSP data_sp,
852852
const ProcessSP &process_sp, lldb::addr_t header_addr) {
853853
if (ObjectFileMachO::MagicBytesMatch(data_sp, 0, data_sp->GetByteSize())) {
854854
std::unique_ptr<ObjectFile> objfile_up(
@@ -929,7 +929,7 @@ ConstString ObjectFileMachO::GetSectionNameEHFrame() {
929929
return g_section_name_eh_frame;
930930
}
931931

932-
bool ObjectFileMachO::MagicBytesMatch(DataBufferSP &data_sp,
932+
bool ObjectFileMachO::MagicBytesMatch(DataBufferSP data_sp,
933933
lldb::addr_t data_offset,
934934
lldb::addr_t data_length) {
935935
DataExtractor data;
@@ -940,7 +940,7 @@ bool ObjectFileMachO::MagicBytesMatch(DataBufferSP &data_sp,
940940
}
941941

942942
ObjectFileMachO::ObjectFileMachO(const lldb::ModuleSP &module_sp,
943-
DataBufferSP &data_sp,
943+
DataBufferSP data_sp,
944944
lldb::offset_t data_offset,
945945
const FileSpec *file,
946946
lldb::offset_t file_offset,
@@ -954,7 +954,7 @@ ObjectFileMachO::ObjectFileMachO(const lldb::ModuleSP &module_sp,
954954
}
955955

956956
ObjectFileMachO::ObjectFileMachO(const lldb::ModuleSP &module_sp,
957-
lldb::DataBufferSP &header_data_sp,
957+
lldb::WritableDataBufferSP header_data_sp,
958958
const lldb::ProcessSP &process_sp,
959959
lldb::addr_t header_addr)
960960
: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),

0 commit comments

Comments
 (0)