2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-05 08:20:57 +08:00
|
|
|
#include "lldb/lldb-python.h"
|
|
|
|
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
#include "lldb/lldb-private.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBListener.h"
|
|
|
|
#include "lldb/API/SBBroadcaster.h"
|
|
|
|
#include "lldb/API/SBCommandInterpreter.h"
|
|
|
|
#include "lldb/API/SBCommandReturnObject.h"
|
2011-04-30 09:09:13 +08:00
|
|
|
#include "lldb/API/SBError.h"
|
2010-06-09 15:37:52 +08:00
|
|
|
#include "lldb/API/SBEvent.h"
|
|
|
|
#include "lldb/API/SBFrame.h"
|
|
|
|
#include "lldb/API/SBProcess.h"
|
|
|
|
#include "lldb/API/SBSourceManager.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-09-04 08:03:46 +08:00
|
|
|
#include "lldb/API/SBStringList.h"
|
|
|
|
#include "lldb/API/SBTarget.h"
|
|
|
|
#include "lldb/API/SBThread.h"
|
2012-02-15 10:34:21 +08:00
|
|
|
#include "lldb/API/SBTypeCategory.h"
|
|
|
|
#include "lldb/API/SBTypeFormat.h"
|
|
|
|
#include "lldb/API/SBTypeFilter.h"
|
|
|
|
#include "lldb/API/SBTypeNameSpecifier.h"
|
|
|
|
#include "lldb/API/SBTypeSummary.h"
|
|
|
|
#include "lldb/API/SBTypeSynthetic.h"
|
|
|
|
|
|
|
|
|
2010-10-11 09:05:37 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
#include "lldb/Core/State.h"
|
2014-01-28 07:43:24 +08:00
|
|
|
#include "lldb/Core/StreamFile.h"
|
2013-01-29 07:47:25 +08:00
|
|
|
#include "lldb/DataFormatters/DataVisualization.h"
|
2010-10-11 09:05:37 +08:00
|
|
|
#include "lldb/Interpreter/Args.h"
|
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
2011-09-24 08:52:29 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupPlatform.h"
|
2010-10-11 09:05:37 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/TargetList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2014-08-28 04:15:09 +08:00
|
|
|
#include "llvm/Support/DynamicLibrary.h"
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2013-12-03 03:35:49 +08:00
|
|
|
|
2014-01-28 07:43:24 +08:00
|
|
|
SBInputReader::SBInputReader()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
SBInputReader::~SBInputReader()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBInputReader::Initialize(lldb::SBDebugger& sb_debugger, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool)
|
|
|
|
{
|
|
|
|
return SBError();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBInputReader::SetIsDone(bool)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
bool
|
|
|
|
SBInputReader::IsActive() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-28 04:15:09 +08:00
|
|
|
static llvm::sys::DynamicLibrary
|
2013-12-03 03:35:49 +08:00
|
|
|
LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error)
|
|
|
|
{
|
2014-08-28 04:15:09 +08:00
|
|
|
llvm::sys::DynamicLibrary dynlib = llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str());
|
|
|
|
if (dynlib.isValid())
|
2013-12-03 03:35:49 +08:00
|
|
|
{
|
|
|
|
typedef bool (*LLDBCommandPluginInit) (lldb::SBDebugger& debugger);
|
|
|
|
|
|
|
|
lldb::SBDebugger debugger_sb(debugger_sp);
|
|
|
|
// This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) function.
|
|
|
|
// TODO: mangle this differently for your system - on OSX, the first underscore needs to be removed and the second one stays
|
2014-08-28 04:15:09 +08:00
|
|
|
LLDBCommandPluginInit init_func = (LLDBCommandPluginInit)dynlib.getAddressOfSymbol("_ZN4lldb16PluginInitializeENS_10SBDebuggerE");
|
2013-12-03 03:35:49 +08:00
|
|
|
if (init_func)
|
|
|
|
{
|
|
|
|
if (init_func(debugger_sb))
|
2014-08-28 04:15:09 +08:00
|
|
|
return dynlib;
|
2013-12-03 03:35:49 +08:00
|
|
|
else
|
|
|
|
error.SetErrorString("plug-in refused to load (lldb::PluginInitialize(lldb::SBDebugger) returned false)");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString("plug-in is missing the required initialization: lldb::PluginInitialize(lldb::SBDebugger)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (spec.Exists())
|
|
|
|
error.SetErrorString("this file does not represent a loadable dylib");
|
|
|
|
else
|
|
|
|
error.SetErrorString("no such file");
|
|
|
|
}
|
2014-08-28 04:15:09 +08:00
|
|
|
return llvm::sys::DynamicLibrary();
|
2013-12-03 03:35:49 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
SBDebugger::Initialize ()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf ("SBDebugger::Initialize ()");
|
|
|
|
|
2011-03-22 09:14:58 +08:00
|
|
|
SBCommandInterpreter::InitializeSWIG ();
|
|
|
|
|
2013-12-03 03:35:49 +08:00
|
|
|
Debugger::Initialize(LoadPlugin);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::Terminate ()
|
|
|
|
{
|
|
|
|
Debugger::Terminate();
|
|
|
|
}
|
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
void
|
|
|
|
SBDebugger::Clear ()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::Clear ()",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()));
|
|
|
|
|
2010-12-21 02:35:50 +08:00
|
|
|
if (m_opaque_sp)
|
2014-01-28 07:43:24 +08:00
|
|
|
m_opaque_sp->ClearIOHandlers ();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
m_opaque_sp.reset();
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger
|
|
|
|
SBDebugger::Create()
|
2011-08-13 08:22:20 +08:00
|
|
|
{
|
2012-02-21 10:23:08 +08:00
|
|
|
return SBDebugger::Create(false, NULL, NULL);
|
2011-08-13 08:22:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBDebugger
|
|
|
|
SBDebugger::Create(bool source_init_files)
|
2012-02-21 10:23:08 +08:00
|
|
|
{
|
|
|
|
return SBDebugger::Create (source_init_files, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
SBDebugger
|
|
|
|
SBDebugger::Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton)
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger debugger;
|
2014-05-20 04:42:14 +08:00
|
|
|
|
|
|
|
// Currently we have issues if this function is called simultaneously on two different
|
|
|
|
// threads. The issues mainly revolve around the fact that the lldb_private::FormatManager
|
|
|
|
// uses global collections and having two threads parsing the .lldbinit files can cause
|
|
|
|
// mayhem. So to get around this for now we need to use a mutex to prevent bad things
|
|
|
|
// from happening.
|
|
|
|
static Mutex g_mutex(Mutex::eMutexTypeRecursive);
|
|
|
|
Mutex::Locker locker(g_mutex);
|
|
|
|
|
2012-02-21 10:23:08 +08:00
|
|
|
debugger.reset(Debugger::CreateInstance(callback, baton));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
debugger.GetDescription (sstr);
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s",
|
|
|
|
static_cast<void*>(debugger.m_opaque_sp.get()),
|
|
|
|
sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2011-08-13 08:22:20 +08:00
|
|
|
SBCommandInterpreter interp = debugger.GetCommandInterpreter();
|
|
|
|
if (source_init_files)
|
|
|
|
{
|
|
|
|
interp.get()->SkipLLDBInitFiles(false);
|
|
|
|
interp.get()->SkipAppInitFiles (false);
|
|
|
|
SBCommandReturnObject result;
|
|
|
|
interp.SourceInitFileInHomeDirectory(result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interp.get()->SkipLLDBInitFiles(true);
|
|
|
|
interp.get()->SkipAppInitFiles (true);
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return debugger;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-01-22 09:02:07 +08:00
|
|
|
void
|
|
|
|
SBDebugger::Destroy (SBDebugger &debugger)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-01-22 09:02:07 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
debugger.GetDescription (sstr);
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger::Destroy () => SBDebugger(%p): %s",
|
|
|
|
static_cast<void*>(debugger.m_opaque_sp.get()),
|
|
|
|
sstr.GetData());
|
2011-01-22 09:02:07 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-01-22 09:02:07 +08:00
|
|
|
Debugger::Destroy (debugger.m_opaque_sp);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-01-22 09:02:07 +08:00
|
|
|
if (debugger.m_opaque_sp.get() != NULL)
|
|
|
|
debugger.m_opaque_sp.reset();
|
|
|
|
}
|
|
|
|
|
2011-12-15 12:38:41 +08:00
|
|
|
void
|
|
|
|
SBDebugger::MemoryPressureDetected ()
|
|
|
|
{
|
2012-04-10 04:22:01 +08:00
|
|
|
// Since this function can be call asynchronously, we allow it to be
|
|
|
|
// non-mandatory. We have seen deadlocks with this function when called
|
|
|
|
// so we need to safeguard against this until we can determine what is
|
|
|
|
// causing the deadlocks.
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2012-06-08 03:08:07 +08:00
|
|
|
|
2012-04-10 04:22:01 +08:00
|
|
|
const bool mandatory = false;
|
2012-06-08 03:08:07 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf ("SBDebugger::MemoryPressureDetected (), mandatory = %d", mandatory);
|
|
|
|
}
|
|
|
|
|
2012-04-10 04:22:01 +08:00
|
|
|
ModuleList::RemoveOrphanSharedModules(mandatory);
|
2011-12-15 12:38:41 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger::SBDebugger () :
|
|
|
|
m_opaque_sp ()
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-08-20 07:56:34 +08:00
|
|
|
SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) :
|
|
|
|
m_opaque_sp(debugger_sp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBDebugger::SBDebugger(const SBDebugger &rhs) :
|
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBDebugger &
|
|
|
|
SBDebugger::operator = (const SBDebugger &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
{
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger::~SBDebugger ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::IsValid() const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger::SetAsync (bool b)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetAsyncExecution(b);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-14 07:25:31 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::GetAsync ()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetAsyncExecution();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-11 09:05:37 +08:00
|
|
|
void
|
|
|
|
SBDebugger::SkipLLDBInitFiles (bool b)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b);
|
|
|
|
}
|
|
|
|
|
2011-08-13 07:34:31 +08:00
|
|
|
void
|
|
|
|
SBDebugger::SkipAppInitFiles (bool b)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles (b);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
// Shouldn't really be settable after initialization as this could cause lots of problems; don't want users
|
|
|
|
// trying to switch modes in the middle of a debugging session.
|
|
|
|
void
|
|
|
|
SBDebugger::SetInputFileHandle (FILE *fh, bool transfer_ownership)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership=%i)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(fh), transfer_ownership);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetInputFileHandle (fh, transfer_ownership);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetOutputFileHandle (FILE *fh, bool transfer_ownership)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership=%i)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(fh), transfer_ownership);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetOutputFileHandle (fh, transfer_ownership);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetErrorFileHandle (FILE *fh, bool transfer_ownership)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership=%i)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(fh), transfer_ownership);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetErrorFileHandle (fh, transfer_ownership);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
FILE *
|
|
|
|
SBDebugger::GetInputFileHandle ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2014-01-28 07:43:24 +08:00
|
|
|
{
|
|
|
|
StreamFileSP stream_file_sp (m_opaque_sp->GetInputFile());
|
|
|
|
if (stream_file_sp)
|
|
|
|
return stream_file_sp->GetFile().GetStream();
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
FILE *
|
|
|
|
SBDebugger::GetOutputFileHandle ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2014-01-28 07:43:24 +08:00
|
|
|
{
|
|
|
|
StreamFileSP stream_file_sp (m_opaque_sp->GetOutputFile());
|
|
|
|
if (stream_file_sp)
|
|
|
|
return stream_file_sp->GetFile().GetStream();
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
FILE *
|
|
|
|
SBDebugger::GetErrorFileHandle ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2014-01-28 07:43:24 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
StreamFileSP stream_file_sp (m_opaque_sp->GetErrorFile());
|
|
|
|
if (stream_file_sp)
|
|
|
|
return stream_file_sp->GetFile().GetStream();
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-12-01 04:23:19 +08:00
|
|
|
void
|
|
|
|
SBDebugger::SaveInputTerminalState()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SaveInputTerminalState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::RestoreInputTerminalState()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->RestoreInputTerminalState();
|
|
|
|
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
SBCommandInterpreter
|
|
|
|
SBDebugger::GetCommandInterpreter ()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBCommandInterpreter sb_interpreter;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_interpreter.reset (&m_opaque_sp->GetCommandInterpreter());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::GetCommandInterpreter () => SBCommandInterpreter(%p)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(sb_interpreter.get()));
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_interpreter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::HandleCommand (const char *command)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
TargetSP target_sp (m_opaque_sp->GetSelectedTarget());
|
|
|
|
Mutex::Locker api_locker;
|
|
|
|
if (target_sp)
|
2012-05-05 07:02:50 +08:00
|
|
|
api_locker.Lock(target_sp->GetAPIMutex());
|
2010-12-21 04:49:23 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBCommandInterpreter sb_interpreter(GetCommandInterpreter ());
|
|
|
|
SBCommandReturnObject result;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_interpreter.HandleCommand (command, result, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (GetErrorFileHandle() != NULL)
|
|
|
|
result.PutError (GetErrorFileHandle());
|
|
|
|
if (GetOutputFileHandle() != NULL)
|
|
|
|
result.PutOutput (GetOutputFileHandle());
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp->GetAsyncExecution() == false)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBProcess process(GetCommandInterpreter().GetProcess ());
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp (process.GetSP());
|
|
|
|
if (process_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
EventSP event_sp;
|
|
|
|
Listener &lldb_listener = m_opaque_sp->GetListener();
|
2012-01-30 15:41:31 +08:00
|
|
|
while (lldb_listener.GetNextEventForBroadcaster (process_sp.get(), event_sp))
|
2010-06-23 09:19:29 +08:00
|
|
|
{
|
|
|
|
SBEvent event(event_sp);
|
|
|
|
HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle());
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SBListener
|
|
|
|
SBDebugger::GetListener ()
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBListener sb_listener;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
sb_listener.reset(&m_opaque_sp->GetListener(), false);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::GetListener () => SBListener(%p)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(sb_listener.get()));
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, FILE *out, FILE *err)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
if (!process.IsValid())
|
|
|
|
return;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp (process.GetTarget().GetSP());
|
|
|
|
if (!target_sp)
|
|
|
|
return;
|
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
const uint32_t event_type = event.GetType();
|
|
|
|
char stdio_buffer[1024];
|
|
|
|
size_t len;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-12-21 04:49:23 +08:00
|
|
|
|
|
|
|
if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged))
|
|
|
|
{
|
|
|
|
// Drain stdout when we stop just in case we have any bytes
|
|
|
|
while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0)
|
|
|
|
if (out != NULL)
|
|
|
|
::fwrite (stdio_buffer, 1, len, out);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event_type & (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged))
|
|
|
|
{
|
|
|
|
// Drain stderr when we stop just in case we have any bytes
|
|
|
|
while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0)
|
|
|
|
if (err != NULL)
|
|
|
|
::fwrite (stdio_buffer, 1, len, err);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event_type & Process::eBroadcastBitStateChanged)
|
|
|
|
{
|
|
|
|
StateType event_state = SBProcess::GetStateFromEvent (event);
|
|
|
|
|
|
|
|
if (event_state == eStateInvalid)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool is_stopped = StateIsStoppedState (event_state);
|
|
|
|
if (!is_stopped)
|
|
|
|
process.ReportEventState (event, out);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager
|
2010-06-09 00:52:24 +08:00
|
|
|
SBDebugger::GetSourceManager ()
|
|
|
|
{
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager sb_source_manager (*this);
|
|
|
|
return sb_source_manager;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len)
|
|
|
|
{
|
|
|
|
if (arch_name && arch_name_len)
|
|
|
|
{
|
2011-04-19 07:15:17 +08:00
|
|
|
ArchSpec default_arch = Target::GetDefaultArchitecture ();
|
2010-09-21 04:44:43 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
if (default_arch.IsValid())
|
|
|
|
{
|
2011-04-19 07:15:17 +08:00
|
|
|
const std::string &triple_str = default_arch.GetTriple().str();
|
|
|
|
if (!triple_str.empty())
|
|
|
|
::snprintf (arch_name, arch_name_len, "%s", triple_str.c_str());
|
|
|
|
else
|
|
|
|
::snprintf (arch_name, arch_name_len, "%s", default_arch.GetArchitectureName());
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (arch_name && arch_name_len)
|
|
|
|
arch_name[0] = '\0';
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBDebugger::SetDefaultArchitecture (const char *arch_name)
|
|
|
|
{
|
|
|
|
if (arch_name)
|
|
|
|
{
|
2012-05-08 09:45:38 +08:00
|
|
|
ArchSpec arch (arch_name);
|
2010-06-09 00:52:24 +08:00
|
|
|
if (arch.IsValid())
|
|
|
|
{
|
2011-04-19 07:15:17 +08:00
|
|
|
Target::SetDefaultArchitecture (arch);
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScriptLanguage
|
|
|
|
SBDebugger::GetScriptingLanguage (const char *script_language_name)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return Args::StringToScriptLanguage (script_language_name,
|
|
|
|
eScriptLanguageDefault,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBDebugger::GetVersionString ()
|
|
|
|
{
|
2013-08-23 20:44:05 +08:00
|
|
|
return lldb_private::GetVersion();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::StateAsCString (StateType state)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-26 06:05:51 +08:00
|
|
|
return lldb_private::StateAsCString (state);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::StateIsRunningState (StateType state)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2011-04-26 06:05:51 +08:00
|
|
|
const bool result = lldb_private::StateIsRunningState (state);
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf ("SBDebugger::StateIsRunningState (state=%s) => %i",
|
2011-04-19 07:15:17 +08:00
|
|
|
StateAsCString (state), result);
|
2010-10-30 12:51:46 +08:00
|
|
|
|
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::StateIsStoppedState (StateType state)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2011-11-17 09:23:07 +08:00
|
|
|
const bool result = lldb_private::StateIsStoppedState (state, false);
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBDebugger::StateIsStoppedState (state=%s) => %i",
|
2011-04-19 07:15:17 +08:00
|
|
|
StateAsCString (state), result);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
lldb::SBTarget
|
|
|
|
SBDebugger::CreateTarget (const char *filename,
|
|
|
|
const char *target_triple,
|
|
|
|
const char *platform_name,
|
|
|
|
bool add_dependent_modules,
|
|
|
|
lldb::SBError& sb_error)
|
|
|
|
{
|
|
|
|
SBTarget sb_target;
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp;
|
2011-09-24 08:52:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
sb_error.Clear();
|
|
|
|
OptionGroupPlatform platform_options (false);
|
|
|
|
platform_options.SetPlatformName (platform_name);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
|
2012-10-19 00:33:33 +08:00
|
|
|
filename,
|
2011-09-24 08:52:29 +08:00
|
|
|
target_triple,
|
|
|
|
add_dependent_modules,
|
|
|
|
&platform_options,
|
|
|
|
target_sp);
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
if (sb_error.Success())
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (target_sp);
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorString("invalid target");
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-24 08:52:29 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, platform_name=%s, add_dependent_modules=%u, error=%s) => SBTarget(%p)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()), filename,
|
|
|
|
target_triple, platform_name, add_dependent_modules,
|
|
|
|
sb_error.GetCString(), static_cast<void*>(target_sp.get()));
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
return sb_target;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBTarget
|
|
|
|
SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename,
|
|
|
|
const char *target_triple)
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
TargetSP target_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2011-09-24 08:52:29 +08:00
|
|
|
const bool add_dependent_modules = true;
|
|
|
|
Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
|
2012-10-19 00:33:33 +08:00
|
|
|
filename,
|
2011-09-24 08:52:29 +08:00
|
|
|
target_triple,
|
|
|
|
add_dependent_modules,
|
|
|
|
NULL,
|
|
|
|
target_sp));
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (target_sp);
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndTargetTriple (filename=\"%s\", triple=%s) => SBTarget(%p)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()), filename,
|
|
|
|
target_triple, static_cast<void*>(target_sp.get()));
|
2010-10-30 12:51:46 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
return sb_target;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget
|
2011-02-23 08:35:02 +08:00
|
|
|
SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *arch_cstr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
TargetSP target_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
Error error;
|
2011-09-24 08:52:29 +08:00
|
|
|
const bool add_dependent_modules = true;
|
2010-06-23 09:19:29 +08:00
|
|
|
|
2012-10-19 00:33:33 +08:00
|
|
|
error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
|
|
|
|
filename,
|
2011-09-24 08:52:29 +08:00
|
|
|
arch_cstr,
|
|
|
|
add_dependent_modules,
|
|
|
|
NULL,
|
|
|
|
target_sp);
|
2010-06-23 09:19:29 +08:00
|
|
|
|
|
|
|
if (error.Success())
|
|
|
|
{
|
2010-08-27 05:32:51 +08:00
|
|
|
m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get());
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (target_sp);
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", arch=%s) => SBTarget(%p)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()), filename, arch_cstr,
|
|
|
|
static_cast<void*>(target_sp.get()));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
return sb_target;
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget
|
|
|
|
SBDebugger::CreateTarget (const char *filename)
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
TargetSP target_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-04-19 07:15:17 +08:00
|
|
|
ArchSpec arch = Target::GetDefaultArchitecture ();
|
2010-06-23 09:19:29 +08:00
|
|
|
Error error;
|
2011-09-24 08:52:29 +08:00
|
|
|
const bool add_dependent_modules = true;
|
|
|
|
|
2012-03-21 02:34:04 +08:00
|
|
|
PlatformSP platform_sp(m_opaque_sp->GetPlatformList().GetSelectedPlatform());
|
2011-09-24 08:52:29 +08:00
|
|
|
error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
|
2012-10-19 00:33:33 +08:00
|
|
|
filename,
|
2011-09-24 08:52:29 +08:00
|
|
|
arch,
|
|
|
|
add_dependent_modules,
|
2012-03-21 02:34:04 +08:00
|
|
|
platform_sp,
|
2011-09-24 08:52:29 +08:00
|
|
|
target_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
if (error.Success())
|
|
|
|
{
|
2010-08-27 05:32:51 +08:00
|
|
|
m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get());
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (target_sp);
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()), filename,
|
|
|
|
static_cast<void*>(target_sp.get()));
|
2012-01-30 15:41:31 +08:00
|
|
|
return sb_target;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-06-16 05:24:24 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::DeleteTarget (lldb::SBTarget &target)
|
|
|
|
{
|
|
|
|
bool result = false;
|
2012-01-30 15:41:31 +08:00
|
|
|
if (m_opaque_sp)
|
2011-06-16 05:24:24 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp(target.GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
// No need to lock, the target list is thread safe
|
|
|
|
result = m_opaque_sp->GetTargetList().DeleteTarget (target_sp);
|
|
|
|
target_sp->Destroy();
|
|
|
|
target.Clear();
|
2012-04-10 04:22:01 +08:00
|
|
|
const bool mandatory = true;
|
|
|
|
ModuleList::RemoveOrphanSharedModules(mandatory);
|
2012-01-30 15:41:31 +08:00
|
|
|
}
|
2011-06-16 05:24:24 +08:00
|
|
|
}
|
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-06-16 05:24:24 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(target.m_opaque_sp.get()), result);
|
2011-06-16 05:24:24 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
SBTarget
|
|
|
|
SBDebugger::GetTargetAtIndex (uint32_t idx)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// No need to lock, the target list is thread safe
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (m_opaque_sp->GetTargetList().GetTargetAtIndex (idx));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_target;
|
|
|
|
}
|
|
|
|
|
2012-05-09 07:06:07 +08:00
|
|
|
uint32_t
|
|
|
|
SBDebugger::GetIndexOfTarget (lldb::SBTarget target)
|
|
|
|
{
|
|
|
|
|
|
|
|
lldb::TargetSP target_sp = target.GetSP();
|
|
|
|
if (!target_sp)
|
|
|
|
return UINT32_MAX;
|
|
|
|
|
|
|
|
if (!m_opaque_sp)
|
|
|
|
return UINT32_MAX;
|
|
|
|
|
|
|
|
return m_opaque_sp->GetTargetList().GetIndexOfTarget (target.GetSP());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBTarget
|
2013-09-06 00:53:14 +08:00
|
|
|
SBDebugger::FindTargetWithProcessID (lldb::pid_t pid)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// No need to lock, the target list is thread safe
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget
|
|
|
|
SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_name)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
if (m_opaque_sp && filename && filename[0])
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
// No need to lock, the target list is thread safe
|
2011-04-08 06:46:35 +08:00
|
|
|
ArchSpec arch (arch_name, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get());
|
2010-10-21 04:54:39 +08:00
|
|
|
TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL));
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (target_sp);
|
2010-06-23 09:19:29 +08:00
|
|
|
}
|
|
|
|
return sb_target;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::FindTargetWithLLDBProcess (const ProcessSP &process_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget sb_target;
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// No need to lock, the target list is thread safe
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_target.SetSP (m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get()));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_target;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBDebugger::GetNumTargets ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// No need to lock, the target list is thread safe
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp->GetTargetList().GetNumTargets ();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBTarget
|
2010-08-27 05:32:51 +08:00
|
|
|
SBDebugger::GetSelectedTarget ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget sb_target;
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// No need to lock, the target list is thread safe
|
2012-01-30 15:41:31 +08:00
|
|
|
target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget ();
|
|
|
|
sb_target.SetSP (target_sp);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
2011-04-19 07:15:17 +08:00
|
|
|
sb_target.GetDescription (sstr, eDescriptionLevelBrief);
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(target_sp.get()), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_target;
|
|
|
|
}
|
|
|
|
|
2011-09-14 07:25:31 +08:00
|
|
|
void
|
|
|
|
SBDebugger::SetSelectedTarget (SBTarget &sb_target)
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2011-09-14 07:25:31 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
TargetSP target_sp (sb_target.GetSP());
|
2011-09-14 07:25:31 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get());
|
2011-09-14 07:25:31 +08:00
|
|
|
}
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_target.GetDescription (sstr, eDescriptionLevelBrief);
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(target_sp.get()), sstr.GetData());
|
2011-09-14 07:25:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
SBPlatform
|
|
|
|
SBDebugger::GetSelectedPlatform()
|
|
|
|
{
|
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBPlatform sb_platform;
|
|
|
|
DebuggerSP debugger_sp(m_opaque_sp);
|
|
|
|
if (debugger_sp)
|
|
|
|
{
|
|
|
|
sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform());
|
|
|
|
}
|
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(sb_platform.GetSP().get()),
|
|
|
|
sb_platform.GetName());
|
2013-11-21 05:07:01 +08:00
|
|
|
return sb_platform;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform)
|
|
|
|
{
|
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
DebuggerSP debugger_sp(m_opaque_sp);
|
|
|
|
if (debugger_sp)
|
|
|
|
{
|
|
|
|
debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP());
|
|
|
|
}
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
|
|
|
static_cast<void*>(sb_platform.GetSP().get()),
|
|
|
|
sb_platform.GetName());
|
2013-11-21 05:07:01 +08:00
|
|
|
}
|
|
|
|
|
2012-09-07 05:58:25 +08:00
|
|
|
void
|
2012-09-07 06:02:28 +08:00
|
|
|
SBDebugger::DispatchInput (void* baton, const void *data, size_t data_len)
|
2012-09-07 05:58:25 +08:00
|
|
|
{
|
|
|
|
DispatchInput (data,data_len);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
2012-08-21 00:21:04 +08:00
|
|
|
SBDebugger::DispatchInput (const void *data, size_t data_len)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2014-01-28 07:43:24 +08:00
|
|
|
// Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
//
|
|
|
|
// if (log)
|
|
|
|
// log->Printf ("SBDebugger(%p)::DispatchInput (data=\"%.*s\", size_t=%" PRIu64 ")",
|
|
|
|
// m_opaque_sp.get(),
|
|
|
|
// (int) data_len,
|
|
|
|
// (const char *) data,
|
|
|
|
// (uint64_t)data_len);
|
|
|
|
//
|
|
|
|
// if (m_opaque_sp)
|
|
|
|
// m_opaque_sp->DispatchInput ((const char *) data, data_len);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-11-20 04:47:54 +08:00
|
|
|
void
|
|
|
|
SBDebugger::DispatchInputInterrupt ()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->DispatchInputInterrupt ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::DispatchInputEndOfFile ()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->DispatchInputEndOfFile ();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
SBDebugger::PushInputReader (SBInputReader &reader)
|
|
|
|
{
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
|
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-03 04:41:46 +08:00
|
|
|
void
|
2014-01-28 07:43:24 +08:00
|
|
|
SBDebugger::RunCommandInterpreter (bool auto_handle_events,
|
|
|
|
bool spawn_thread)
|
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-03 04:41:46 +08:00
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
2014-01-28 07:43:24 +08:00
|
|
|
m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(auto_handle_events, spawn_thread);
|
This patch captures and serializes all output being written by the
command line driver, including the lldb prompt being output by
editline, the asynchronous process output & error messages, and
asynchronous messages written by target stop-hooks.
As part of this it introduces a new Stream class,
StreamAsynchronousIO. A StreamAsynchronousIO object is created with a
broadcaster, who will eventually broadcast the stream's data for a
listener to handle, and an event type indicating what type of event
the broadcaster will broadcast. When the Write method is called on a
StreamAsynchronousIO object, the data is appended to an internal
string. When the Flush method is called on a StreamAsynchronousIO
object, it broadcasts it's data string and clears the string.
Anything in lldb-core that needs to generate asynchronous output for
the end-user should use the StreamAsynchronousIO objects.
I have also added a new notification type for InputReaders, to let
them know that a asynchronous output has been written. This is to
allow the input readers to, for example, refresh their prompts and
lines, if desired. I added the case statements to all the input
readers to catch this notification, but I haven't added any code for
handling them yet (except to the IOChannel input reader).
llvm-svn: 130721
2011-05-03 04:41:46 +08:00
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
void
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::reset (const DebuggerSP &debugger_sp)
|
2010-06-23 09:19:29 +08:00
|
|
|
{
|
|
|
|
m_opaque_sp = debugger_sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
Debugger *
|
|
|
|
SBDebugger::get () const
|
|
|
|
{
|
|
|
|
return m_opaque_sp.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
Debugger &
|
|
|
|
SBDebugger::ref () const
|
|
|
|
{
|
|
|
|
assert (m_opaque_sp.get());
|
|
|
|
return *m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2011-10-01 10:59:24 +08:00
|
|
|
const lldb::DebuggerSP &
|
|
|
|
SBDebugger::get_sp () const
|
|
|
|
{
|
|
|
|
return m_opaque_sp;
|
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
|
2010-07-01 00:22:25 +08:00
|
|
|
SBDebugger
|
|
|
|
SBDebugger::FindDebuggerWithID (int id)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
// No need to lock, the debugger list is thread safe
|
2010-07-01 00:22:25 +08:00
|
|
|
SBDebugger sb_debugger;
|
2011-04-19 07:15:17 +08:00
|
|
|
DebuggerSP debugger_sp = Debugger::FindDebuggerWithID (id);
|
2010-07-01 00:22:25 +08:00
|
|
|
if (debugger_sp)
|
|
|
|
sb_debugger.reset (debugger_sp);
|
|
|
|
return sb_debugger;
|
|
|
|
}
|
2010-08-31 03:44:40 +08:00
|
|
|
|
2010-09-10 01:45:09 +08:00
|
|
|
const char *
|
|
|
|
SBDebugger::GetInstanceName()
|
2010-09-04 08:03:46 +08:00
|
|
|
{
|
2012-08-23 02:39:03 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetInstanceName().AsCString();
|
|
|
|
else
|
2010-09-10 01:45:09 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBDebugger::SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name)
|
|
|
|
{
|
2012-08-23 02:39:03 +08:00
|
|
|
SBError sb_error;
|
|
|
|
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName (ConstString(debugger_instance_name)));
|
|
|
|
Error error;
|
|
|
|
if (debugger_sp)
|
|
|
|
{
|
|
|
|
ExecutionContext exe_ctx (debugger_sp->GetCommandInterpreter().GetExecutionContext());
|
|
|
|
error = debugger_sp->SetPropertyValue (&exe_ctx,
|
|
|
|
eVarSetOperationAssign,
|
|
|
|
var_name,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat ("invalid debugger instance name '%s'", debugger_instance_name);
|
|
|
|
}
|
|
|
|
if (error.Fail())
|
|
|
|
sb_error.SetError(error);
|
|
|
|
return sb_error;
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
SBStringList
|
2010-09-10 01:45:09 +08:00
|
|
|
SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger_instance_name)
|
2010-09-04 08:03:46 +08:00
|
|
|
{
|
|
|
|
SBStringList ret_value;
|
2012-08-23 02:39:03 +08:00
|
|
|
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName (ConstString(debugger_instance_name)));
|
|
|
|
Error error;
|
|
|
|
if (debugger_sp)
|
|
|
|
{
|
|
|
|
ExecutionContext exe_ctx (debugger_sp->GetCommandInterpreter().GetExecutionContext());
|
|
|
|
lldb::OptionValueSP value_sp (debugger_sp->GetPropertyValue (&exe_ctx,
|
|
|
|
var_name,
|
|
|
|
false,
|
|
|
|
error));
|
|
|
|
if (value_sp)
|
|
|
|
{
|
|
|
|
StreamString value_strm;
|
|
|
|
value_sp->DumpValue (&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
|
|
|
|
const std::string &value_str = value_strm.GetString();
|
|
|
|
if (!value_str.empty())
|
|
|
|
{
|
|
|
|
StringList string_list;
|
2014-01-28 07:43:24 +08:00
|
|
|
string_list.SplitIntoLines(value_str);
|
2012-08-23 02:39:03 +08:00
|
|
|
return SBStringList(&string_list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SBStringList();
|
2010-09-04 08:03:46 +08:00
|
|
|
}
|
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
uint32_t
|
|
|
|
SBDebugger::GetTerminalWidth () const
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetTerminalWidth ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetTerminalWidth (uint32_t term_width)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetTerminalWidth (term_width);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBDebugger::GetPrompt() const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2014-04-04 12:06:10 +08:00
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2014-04-04 12:06:10 +08:00
|
|
|
log->Printf ("SBDebugger(%p)::GetPrompt () => \"%s\"",
|
|
|
|
static_cast<void*>(m_opaque_sp.get()),
|
2010-10-27 07:49:36 +08:00
|
|
|
(m_opaque_sp ? m_opaque_sp->GetPrompt() : ""));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-09-18 09:14:36 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetPrompt ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetPrompt (const char *prompt)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetPrompt (prompt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
ScriptLanguage
|
2010-09-18 09:14:36 +08:00
|
|
|
SBDebugger::GetScriptLanguage() const
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetScriptLanguage ();
|
|
|
|
return eScriptLanguageNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-04-19 07:15:17 +08:00
|
|
|
SBDebugger::SetScriptLanguage (ScriptLanguage script_lang)
|
2010-09-18 09:14:36 +08:00
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2010-09-18 09:14:36 +08:00
|
|
|
m_opaque_sp->SetScriptLanguage (script_lang);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-09-18 09:14:36 +08:00
|
|
|
}
|
|
|
|
|
2010-08-31 03:44:40 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::SetUseExternalEditor (bool value)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->SetUseExternalEditor (value);
|
2010-12-21 04:49:23 +08:00
|
|
|
return false;
|
2010-08-31 03:44:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2010-09-21 04:44:43 +08:00
|
|
|
SBDebugger::GetUseExternalEditor ()
|
2010-08-31 03:44:40 +08:00
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
2010-09-21 04:44:43 +08:00
|
|
|
return m_opaque_sp->GetUseExternalEditor ();
|
2010-12-21 04:49:23 +08:00
|
|
|
return false;
|
2010-08-31 03:44:40 +08:00
|
|
|
}
|
|
|
|
|
2013-05-24 04:47:45 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::SetUseColor (bool value)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->SetUseColor (value);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBDebugger::GetUseColor () const
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetUseColor ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::GetDescription (SBStream &description)
|
|
|
|
{
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
const char *name = m_opaque_sp->GetInstanceName().AsCString();
|
2011-04-19 07:15:17 +08:00
|
|
|
user_id_t id = m_opaque_sp->GetID();
|
2012-11-30 05:49:15 +08:00
|
|
|
strm.Printf ("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id);
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString ("No value");
|
2010-09-20 13:20:02 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-11-20 04:47:54 +08:00
|
|
|
|
2011-04-19 07:15:17 +08:00
|
|
|
user_id_t
|
2010-11-20 04:47:54 +08:00
|
|
|
SBDebugger::GetID()
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetID();
|
|
|
|
return LLDB_INVALID_UID;
|
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBDebugger::SetCurrentPlatform (const char *platform_name)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
PlatformSP platform_sp (Platform::Create (platform_name, sb_error.ref()));
|
|
|
|
|
|
|
|
if (platform_sp)
|
|
|
|
{
|
|
|
|
bool make_selected = true;
|
|
|
|
m_opaque_sp->GetPlatformList().Append (platform_sp, make_selected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
2011-06-17 11:31:01 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::SetCurrentPlatformSDKRoot (const char *sysroot)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
PlatformSP platform_sp (m_opaque_sp->GetPlatformList().GetSelectedPlatform());
|
|
|
|
|
|
|
|
if (platform_sp)
|
|
|
|
{
|
|
|
|
platform_sp->SetSDKRootDirectory (ConstString (sysroot));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-29 12:06:55 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::GetCloseInputOnEOF () const
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
return m_opaque_sp->GetCloseInputOnEOF ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetCloseInputOnEOF (bool b)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->SetCloseInputOnEOF (b);
|
|
|
|
}
|
2012-02-15 10:34:21 +08:00
|
|
|
|
|
|
|
SBTypeCategory
|
|
|
|
SBDebugger::GetCategory (const char* category_name)
|
|
|
|
{
|
|
|
|
if (!category_name || *category_name == 0)
|
|
|
|
return SBTypeCategory();
|
|
|
|
|
|
|
|
TypeCategoryImplSP category_sp;
|
|
|
|
|
|
|
|
if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, false))
|
|
|
|
return SBTypeCategory(category_sp);
|
|
|
|
else
|
|
|
|
return SBTypeCategory();
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeCategory
|
|
|
|
SBDebugger::CreateCategory (const char* category_name)
|
|
|
|
{
|
|
|
|
if (!category_name || *category_name == 0)
|
|
|
|
return SBTypeCategory();
|
|
|
|
|
|
|
|
TypeCategoryImplSP category_sp;
|
|
|
|
|
|
|
|
if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, true))
|
|
|
|
return SBTypeCategory(category_sp);
|
|
|
|
else
|
|
|
|
return SBTypeCategory();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBDebugger::DeleteCategory (const char* category_name)
|
|
|
|
{
|
|
|
|
if (!category_name || *category_name == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return DataVisualization::Categories::Delete(ConstString(category_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBDebugger::GetNumCategories()
|
|
|
|
{
|
|
|
|
return DataVisualization::Categories::GetCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeCategory
|
|
|
|
SBDebugger::GetCategoryAtIndex (uint32_t index)
|
|
|
|
{
|
|
|
|
return SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index));
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeCategory
|
|
|
|
SBDebugger::GetDefaultCategory()
|
|
|
|
{
|
|
|
|
return GetCategory("default");
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTypeFormat
|
|
|
|
SBDebugger::GetFormatForType (SBTypeNameSpecifier type_name)
|
|
|
|
{
|
|
|
|
SBTypeCategory default_category_sb = GetDefaultCategory();
|
|
|
|
if (default_category_sb.GetEnabled())
|
|
|
|
return default_category_sb.GetFormatForType(type_name);
|
|
|
|
return SBTypeFormat();
|
|
|
|
}
|
|
|
|
|
2012-02-21 13:33:55 +08:00
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
2012-02-15 10:34:21 +08:00
|
|
|
SBTypeSummary
|
|
|
|
SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name)
|
|
|
|
{
|
2012-05-09 05:49:57 +08:00
|
|
|
if (type_name.IsValid() == false)
|
|
|
|
return SBTypeSummary();
|
|
|
|
return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
2012-02-21 13:33:55 +08:00
|
|
|
#endif // LLDB_DISABLE_PYTHON
|
2012-02-15 10:34:21 +08:00
|
|
|
|
|
|
|
SBTypeFilter
|
|
|
|
SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name)
|
|
|
|
{
|
2012-05-09 05:49:57 +08:00
|
|
|
if (type_name.IsValid() == false)
|
|
|
|
return SBTypeFilter();
|
|
|
|
return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
|
|
|
|
2012-02-21 13:33:55 +08:00
|
|
|
#ifndef LLDB_DISABLE_PYTHON
|
2012-02-15 10:34:21 +08:00
|
|
|
SBTypeSynthetic
|
|
|
|
SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name)
|
|
|
|
{
|
2012-05-09 05:49:57 +08:00
|
|
|
if (type_name.IsValid() == false)
|
|
|
|
return SBTypeSynthetic();
|
|
|
|
return SBTypeSynthetic(DataVisualization::GetSyntheticForType(type_name.GetSP()));
|
2012-02-15 10:34:21 +08:00
|
|
|
}
|
2012-02-21 13:33:55 +08:00
|
|
|
#endif // LLDB_DISABLE_PYTHON
|
2012-02-15 10:34:21 +08:00
|
|
|
|
2012-02-21 10:23:08 +08:00
|
|
|
bool
|
|
|
|
SBDebugger::EnableLog (const char *channel, const char **categories)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
|
|
|
|
StreamString errors;
|
|
|
|
return m_opaque_sp->EnableLog (channel, categories, NULL, log_options, errors);
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2012-02-23 06:49:20 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
SBDebugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
return m_opaque_sp->SetLoggingCallback (log_callback, baton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|