summaryrefslogtreecommitdiff
path: root/lldb/source/Expression/DWARFExpression.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression/DWARFExpression.cpp')
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index a10546c1deae..890d8b5d3107 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -460,22 +460,19 @@ bool DWARFExpression::Update_DW_OP_addr(lldb::addr_t file_addr) {
// first, then modify it, and if all goes well, we then replace the data
// for this expression
- // So first we copy the data into a heap buffer
- std::unique_ptr<DataBufferHeap> head_data_up(
- new DataBufferHeap(m_data.GetDataStart(), m_data.GetByteSize()));
-
- // Make en encoder so we can write the address into the buffer using the
- // correct byte order (endianness)
- DataEncoder encoder(head_data_up->GetBytes(), head_data_up->GetByteSize(),
+ // Make en encoder that contains a copy of the location expression data
+ // so we can write the address into the buffer using the correct byte
+ // order.
+ DataEncoder encoder(m_data.GetDataStart(), m_data.GetByteSize(),
m_data.GetByteOrder(), addr_byte_size);
// Replace the address in the new buffer
- if (encoder.PutUnsigned(offset, addr_byte_size, file_addr) == UINT32_MAX)
+ if (encoder.PutAddress(offset, file_addr) == UINT32_MAX)
return false;
// All went well, so now we can reset the data using a shared pointer to
// the heap data so "m_data" will now correctly manage the heap data.
- m_data.SetData(DataBufferSP(head_data_up.release()));
+ m_data.SetData(encoder.GetDataBuffer());
return true;
} else {
const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op);
@@ -521,15 +518,11 @@ bool DWARFExpression::LinkThreadLocalStorage(
// We have to make a copy of the data as we don't know if this data is from a
// read only memory mapped buffer, so we duplicate all of the data first,
// then modify it, and if all goes well, we then replace the data for this
- // expression
-
- // So first we copy the data into a heap buffer
- std::shared_ptr<DataBufferHeap> heap_data_sp(
- new DataBufferHeap(m_data.GetDataStart(), m_data.GetByteSize()));
+ // expression.
- // Make en encoder so we can write the address into the buffer using the
- // correct byte order (endianness)
- DataEncoder encoder(heap_data_sp->GetBytes(), heap_data_sp->GetByteSize(),
+ // Make en encoder that contains a copy of the location expression data so we
+ // can write the address into the buffer using the correct byte order.
+ DataEncoder encoder(m_data.GetDataStart(), m_data.GetByteSize(),
m_data.GetByteOrder(), addr_byte_size);
lldb::offset_t offset = 0;
@@ -603,7 +596,7 @@ bool DWARFExpression::LinkThreadLocalStorage(
// and read the
// TLS data
m_module_wp = new_module_sp;
- m_data.SetData(heap_data_sp);
+ m_data.SetData(encoder.GetDataBuffer());
return true;
}
@@ -2817,4 +2810,3 @@ bool DWARFExpression::MatchesOperand(StackFrame &frame,
return MatchRegOp(*reg)(operand);
}
}
-