[Lldb-commits] [lldb] r161123 - in /lldb/trunk: include/lldb/Core/Disassembler.h include/lldb/Target/ThreadPlanTracer.h source/Commands/CommandObjectDisassemble.cpp source/Core/Disassembler.cpp source/Expression/ClangExpressionParser.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp source/Target/ThreadPlanTracer.cpp
Sean Callanan
scallanan at apple.com
Wed Aug 1 11:51:00 PDT 2012
Author: spyffe
Date: Wed Aug 1 13:50:59 2012
New Revision: 161123
URL: http://llvm.org/viewvc/llvm-project?rev=161123&view=rev
Log:
Instructions generated by a disassembler can now
keep a shared pointer to their disassembler. This
is important for the LLVM-C disassembler because
it needs to lock its parent in order to disassemble
itself.
This means that every interface that returned a
Disassembler* needs to return a DisassemblerSP, so
that the instructions and any external owners share
the same reference count on the object. I changed
all clients to use this shared pointer, which also
plugged a few leaks.
<rdar://problem/12002822>
Modified:
lldb/trunk/include/lldb/Core/Disassembler.h
lldb/trunk/include/lldb/Target/ThreadPlanTracer.h
lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
lldb/trunk/source/Core/Disassembler.cpp
lldb/trunk/source/Expression/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
lldb/trunk/source/Target/ThreadPlanTracer.cpp
Modified: lldb/trunk/include/lldb/Core/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Disassembler.h (original)
+++ lldb/trunk/include/lldb/Core/Disassembler.h Wed Aug 1 13:50:59 2012
@@ -233,6 +233,7 @@
};
class Disassembler :
+ public STD_ENABLE_SHARED_FROM_THIS(Disassembler),
public PluginInterface
{
public:
@@ -246,7 +247,7 @@
eOptionMarkPCAddress = (1u << 3) // Mark the disassembly line the contains the PC
};
- static Disassembler*
+ static lldb::DisassemblerSP
FindPlugin (const ArchSpec &arch, const char *plugin_name);
static lldb::DisassemblerSP
Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTracer.h?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Wed Aug 1 13:50:59 2012
@@ -120,7 +120,7 @@
TypeFromUser
GetIntPointerType();
- std::auto_ptr<Disassembler> m_disassembler_ap;
+ lldb::DisassemblerSP m_disassembler_sp;
TypeFromUser m_intptr_type;
std::vector<RegisterValue> m_register_values;
lldb::DataBufferSP m_buffer_sp;
Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Wed Aug 1 13:50:59 2012
@@ -243,7 +243,7 @@
}
const char *plugin_name = m_options.GetPluginName ();
- Disassembler *disassembler = Disassembler::FindPlugin(m_options.arch, plugin_name);
+ DisassemblerSP disassembler = Disassembler::FindPlugin(m_options.arch, plugin_name);
if (disassembler == NULL)
{
Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Wed Aug 1 13:50:59 2012
@@ -37,7 +37,7 @@
using namespace lldb_private;
-Disassembler*
+DisassemblerSP
Disassembler::FindPlugin (const ArchSpec &arch, const char *plugin_name)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
@@ -45,7 +45,6 @@
arch.GetArchitectureName(),
plugin_name);
- std::auto_ptr<Disassembler> disassembler_ap;
DisassemblerCreateInstance create_callback = NULL;
if (plugin_name)
@@ -53,23 +52,23 @@
create_callback = PluginManager::GetDisassemblerCreateCallbackForPluginName (plugin_name);
if (create_callback)
{
- disassembler_ap.reset (create_callback(arch));
+ DisassemblerSP disassembler_sp(create_callback(arch));
- if (disassembler_ap.get())
- return disassembler_ap.release();
+ if (disassembler_sp.get())
+ return disassembler_sp;
}
}
else
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetDisassemblerCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- disassembler_ap.reset (create_callback(arch));
+ DisassemblerSP disassembler_sp(create_callback(arch));
- if (disassembler_ap.get())
- return disassembler_ap.release();
+ if (disassembler_sp.get())
+ return disassembler_sp;
}
}
- return NULL;
+ return DisassemblerSP();
}
@@ -221,7 +220,7 @@
lldb::DisassemblerSP disasm_sp;
if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid())
{
- disasm_sp.reset (Disassembler::FindPlugin(arch, plugin_name));
+ disasm_sp = Disassembler::FindPlugin(arch, plugin_name);
if (disasm_sp)
{
@@ -248,7 +247,7 @@
if (bytes)
{
- disasm_sp.reset(Disassembler::FindPlugin(arch, plugin_name));
+ disasm_sp = Disassembler::FindPlugin(arch, plugin_name);
if (disasm_sp)
{
@@ -282,19 +281,19 @@
{
if (disasm_range.GetByteSize())
{
- std::auto_ptr<Disassembler> disasm_ap (Disassembler::FindPlugin(arch, plugin_name));
+ lldb::DisassemblerSP disasm_sp (Disassembler::FindPlugin(arch, plugin_name));
- if (disasm_ap.get())
+ if (disasm_sp.get())
{
AddressRange range;
ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
range.SetByteSize (disasm_range.GetByteSize());
- size_t bytes_disassembled = disasm_ap->ParseInstructions (&exe_ctx, range, &strm);
+ size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, &strm);
if (bytes_disassembled == 0)
return false;
- return PrintInstructions (disasm_ap.get(),
+ return PrintInstructions (disasm_sp.get(),
debugger,
arch,
exe_ctx,
@@ -323,16 +322,16 @@
{
if (num_instructions > 0)
{
- std::auto_ptr<Disassembler> disasm_ap (Disassembler::FindPlugin(arch, plugin_name));
- if (disasm_ap.get())
+ lldb::DisassemblerSP disasm_sp (Disassembler::FindPlugin(arch, plugin_name));
+ if (disasm_sp.get())
{
Address addr;
ResolveAddress (exe_ctx, start_address, addr);
- size_t bytes_disassembled = disasm_ap->ParseInstructions (&exe_ctx, addr, num_instructions);
+ size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, addr, num_instructions);
if (bytes_disassembled == 0)
return false;
- return PrintInstructions (disasm_ap.get(),
+ return PrintInstructions (disasm_sp.get(),
debugger,
arch,
exe_ctx,
Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Aug 1 13:50:59 2012
@@ -754,7 +754,7 @@
ArchSpec arch(target->GetArchitecture());
- Disassembler *disassembler = Disassembler::FindPlugin(arch, NULL);
+ lldb::DisassemblerSP disassembler = Disassembler::FindPlugin(arch, NULL);
if (disassembler == NULL)
{
Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp Wed Aug 1 13:50:59 2012
@@ -36,6 +36,7 @@
Instruction(address, addr_class),
m_is_valid(false),
m_disasm(disasm),
+ m_disasm_sp(disasm.shared_from_this()),
m_does_branch(eLazyBoolCalculate)
{
}
@@ -415,6 +416,7 @@
bool m_is_valid;
DisassemblerLLVMC &m_disasm;
+ DisassemblerSP m_disasm_sp; // for ownership
LazyBool m_does_branch;
static bool s_regex_compiled;
Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=161123&r1=161122&r2=161123&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Wed Aug 1 13:50:59 2012
@@ -96,7 +96,7 @@
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp) :
ThreadPlanTracer (thread, stream_sp),
- m_disassembler_ap (),
+ m_disassembler_sp (),
m_intptr_type (),
m_register_values ()
{
@@ -104,7 +104,7 @@
ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread) :
ThreadPlanTracer (thread),
- m_disassembler_ap (),
+ m_disassembler_sp (),
m_intptr_type (),
m_register_values ()
{
@@ -113,9 +113,9 @@
Disassembler *
ThreadPlanAssemblyTracer::GetDisassembler ()
{
- if (m_disassembler_ap.get() == NULL)
- m_disassembler_ap.reset(Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), NULL));
- return m_disassembler_ap.get();
+ if (m_disassembler_sp.get() == NULL)
+ m_disassembler_sp = Disassembler::FindPlugin(m_thread.GetProcess()->GetTarget().GetArchitecture(), NULL);
+ return m_disassembler_sp.get();
}
TypeFromUser
More information about the lldb-commits
mailing list