<rdar://problem/11791234>
Fixed an issue that could cause references the shared data for an object file to stay around longer than intended and could cause memory bloat when debugging multiple times.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@161716 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index 1ff6e8e..f42cc71 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -261,6 +261,13 @@
}
void
+DWARFExpression::CopyOpcodeData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length)
+{
+ const uint8_t *bytes = data.PeekData(data_offset, data_length);
+ m_data.SetData(DataBufferSP(new DataBufferHeap(bytes, data_length)));
+}
+
+void
DWARFExpression::SetOpcodeData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length)
{
m_data.SetData(data, data_offset, data_length);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d0def95..559bb73 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1012,7 +1012,9 @@
// this address is resolved. If they are the same, then the
// function for this address didn't make it into the final
// executable.
- bool curr_in_final_executable = info->curr_section_sp->GetLinkedSection ();
+ bool curr_in_final_executable = false;
+ if (info->curr_section_sp->GetLinkedSection ())
+ curr_in_final_executable = true;
// If we are doing DWARF with debug map, then we need to carefully
// add each line table entry as there may be gaps as functions
@@ -6542,7 +6544,7 @@
uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- location.SetOpcodeData(get_debug_info_data(), block_offset, block_length);
+ location.CopyOpcodeData(get_debug_info_data(), block_offset, block_length);
}
else
{
@@ -6552,7 +6554,7 @@
size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset);
if (loc_list_length > 0)
{
- location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length);
+ location.CopyOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length);
assert (func_low_pc != LLDB_INVALID_ADDRESS);
location.SetLocationListSlide (func_low_pc - dwarf_cu->GetBaseAddress());
}