aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2013-07-31 02:19:15 +0000
committerJim Ingham <jingham@apple.com>2013-07-31 02:19:15 +0000
commitbc16b9273326b81dc4aae022389a9f8c3bdca66d (patch)
treecd760bb1c10abea342bdd54207f7c58ffc8d3dba
parent1475fc76a3b64fd81b710d3a719d6fcc9f6996e2 (diff)
downloadlldb-bc16b9273326b81dc4aae022389a9f8c3bdca66d.tar.gz
The DisassemblerLLVMC has a retain cycle - the InstructionLLVMC's contained in its instruction
list have a shared pointer back to their DisassemblerLLVMC. This checkin force clears the InstructionList in all the places we use the DisassemblerSP to stop the leaking for now. I'll go back and fix this for real when I have time to do so. <rdar://problem/14581918> git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187473 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--source/Core/DataExtractor.cpp4
-rw-r--r--source/Core/Disassembler.cpp42
-rw-r--r--source/Expression/IRExecutionUnit.cpp12
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp3
-rw-r--r--source/Target/ThreadPlanStepRange.cpp13
5 files changed, 53 insertions, 21 deletions
diff --git a/source/Core/DataExtractor.cpp b/source/Core/DataExtractor.cpp
index f9ffc902d..73b17ed8f 100644
--- a/source/Core/DataExtractor.cpp
+++ b/source/Core/DataExtractor.cpp
@@ -1412,6 +1412,10 @@ DataExtractor::Dump (Stream *s,
ExecutionContext exe_ctx;
exe_scope->CalculateExecutionContext(exe_ctx);
disassembler_sp->GetInstructionList().Dump (s, show_address, show_bytes, &exe_ctx);
+
+ // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
+ // I'll fix that but for now, just clear the list and it will go away nicely.
+ disassembler_sp->GetInstructionList().Clear();
}
}
}
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index fd0cae6a1..e80e92c91 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -316,14 +316,19 @@ Disassembler::Disassemble
if (bytes_disassembled == 0)
return false;
- return PrintInstructions (disasm_sp.get(),
- debugger,
- arch,
- exe_ctx,
- num_instructions,
- num_mixed_context_lines,
- options,
- strm);
+ bool result = PrintInstructions (disasm_sp.get(),
+ debugger,
+ arch,
+ exe_ctx,
+ num_instructions,
+ num_mixed_context_lines,
+ options,
+ strm);
+
+ // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
+ // I'll fix that but for now, just clear the list and it will go away nicely.
+ disasm_sp->GetInstructionList().Clear();
+ return result;
}
}
return false;
@@ -361,14 +366,19 @@ Disassembler::Disassemble
prefer_file_cache);
if (bytes_disassembled == 0)
return false;
- return PrintInstructions (disasm_sp.get(),
- debugger,
- arch,
- exe_ctx,
- num_instructions,
- num_mixed_context_lines,
- options,
- strm);
+ bool result = PrintInstructions (disasm_sp.get(),
+ debugger,
+ arch,
+ exe_ctx,
+ num_instructions,
+ num_mixed_context_lines,
+ options,
+ strm);
+
+ // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
+ // I'll fix that but for now, just clear the list and it will go away nicely.
+ disasm_sp->GetInstructionList().Clear();
+ return result;
}
}
return false;
diff --git a/source/Expression/IRExecutionUnit.cpp b/source/Expression/IRExecutionUnit.cpp
index ef8c8da0e..4b66b867d 100644
--- a/source/Expression/IRExecutionUnit.cpp
+++ b/source/Expression/IRExecutionUnit.cpp
@@ -171,9 +171,9 @@ IRExecutionUnit::DisassembleFunction (Stream &stream,
const char *plugin_name = NULL;
const char *flavor_string = NULL;
- lldb::DisassemblerSP disassembler = Disassembler::FindPlugin(arch, flavor_string, plugin_name);
+ lldb::DisassemblerSP disassembler_sp = Disassembler::FindPlugin(arch, flavor_string, plugin_name);
- if (!disassembler)
+ if (!disassembler_sp)
{
ret.SetErrorToGenericError();
ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.GetArchitectureName());
@@ -202,9 +202,9 @@ IRExecutionUnit::DisassembleFunction (Stream &stream,
DataExtractor::TypeUInt8);
}
- disassembler->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false, false);
+ disassembler_sp->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false, false);
- InstructionList &instruction_list = disassembler->GetInstructionList();
+ InstructionList &instruction_list = disassembler_sp->GetInstructionList();
const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
for (size_t instruction_index = 0, num_instructions = instruction_list.GetSize();
@@ -219,7 +219,9 @@ IRExecutionUnit::DisassembleFunction (Stream &stream,
&exe_ctx);
stream.PutChar('\n');
}
-
+ // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
+ // I'll fix that but for now, just clear the list and it will go away nicely.
+ disassembler_sp->GetInstructionList().Clear();
return ret;
}
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index b20f73213..c93dea9b5 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -264,6 +264,9 @@ UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly (AddressRange&
}
}
}
+ // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
+ // I'll fix that but for now, just clear the list and it will go away nicely.
+ disasm_sp->GetInstructionList().Clear();
}
if (log && log->GetVerbose ())
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index e2820790e..da25348c2 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -66,6 +66,16 @@ ThreadPlanStepRange::ThreadPlanStepRange (ThreadPlanKind kind,
ThreadPlanStepRange::~ThreadPlanStepRange ()
{
ClearNextBranchBreakpoint();
+
+ size_t num_instruction_ranges = m_instruction_ranges.size();
+
+ // FIXME: The DisassemblerLLVMC has a reference cycle and won't go away if it has any active instructions.
+ // I'll fix that but for now, just clear the list and it will go away nicely.
+ for (size_t i = 0; i < num_instruction_ranges; i++)
+ {
+ if (m_instruction_ranges[i])
+ m_instruction_ranges[i]->GetInstructionList().Clear();
+ }
}
void
@@ -99,6 +109,9 @@ ThreadPlanStepRange::AddRange(const AddressRange &new_range)
// condense the ranges if they overlap, though I don't think it is likely
// to be very important.
m_address_ranges.push_back (new_range);
+
+ // Fill the slot for this address range with an empty DisassemblerSP in the instruction ranges. I want the
+ // indices to match, but I don't want to do the work to disassemble this range if I don't step into it.
m_instruction_ranges.push_back (DisassemblerSP());
}