2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBTarget.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-03-25 05:19:54 +08:00
|
|
|
#include "lldb/lldb-public.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
#include "lldb/API/SBFileSpec.h"
|
|
|
|
#include "lldb/API/SBModule.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Breakpoint/BreakpointID.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointIDList.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointList.h"
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
|
|
|
#include "lldb/Core/Address.h"
|
|
|
|
#include "lldb/Core/AddressResolver.h"
|
|
|
|
#include "lldb/Core/AddressResolverName.h"
|
2010-06-16 03:49:27 +08:00
|
|
|
#include "lldb/Interpreter/Args.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/ArchSpec.h"
|
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
#include "lldb/Core/Disassembler.h"
|
2011-02-08 13:05:52 +08:00
|
|
|
#include "lldb/Host/FileSpec.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/RegularExpression.h"
|
|
|
|
#include "lldb/Core/SearchFilter.h"
|
|
|
|
#include "lldb/Core/STLUtils.h"
|
2011-02-01 09:31:41 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/TargetList.h"
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
#include "../source/Commands/CommandObjectBreakpoint.h"
|
|
|
|
|
2010-06-09 15:44:37 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBProcess.h"
|
|
|
|
#include "lldb/API/SBListener.h"
|
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
#define DEFAULT_DISASM_BYTE_SIZE 32
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// SBTarget constructor
|
|
|
|
//----------------------------------------------------------------------
|
2010-12-15 13:08:08 +08:00
|
|
|
SBTarget::SBTarget () :
|
|
|
|
m_opaque_sp ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget::SBTarget (const SBTarget& rhs) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (rhs.m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBTarget::SBTarget(const TargetSP& target_sp) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
const SBTarget&
|
|
|
|
SBTarget::operator = (const SBTarget& rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_sp = rhs.m_opaque_sp;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
SBTarget::~SBTarget()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::IsValid () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBProcess
|
|
|
|
SBTarget::GetProcess ()
|
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBProcess sb_process;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_process.SetProcess (m_opaque_sp->GetProcessSP());
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)",
|
|
|
|
m_opaque_sp.get(), sb_process.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBDebugger
|
|
|
|
SBTarget::GetDebugger () const
|
|
|
|
{
|
|
|
|
SBDebugger debugger;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
debugger.reset (m_opaque_sp->GetDebugger().GetSP());
|
|
|
|
return debugger;
|
|
|
|
}
|
|
|
|
|
2010-10-07 12:19:01 +08:00
|
|
|
|
|
|
|
SBProcess
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
SBTarget::Launch
|
2010-10-07 06:10:17 +08:00
|
|
|
(
|
2011-02-04 05:28:34 +08:00
|
|
|
SBListener &listener,
|
2010-10-07 06:10:17 +08:00
|
|
|
char const **argv,
|
|
|
|
char const **envp,
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
const char *stdin_path,
|
|
|
|
const char *stdout_path,
|
|
|
|
const char *stderr_path,
|
|
|
|
const char *working_directory,
|
|
|
|
uint32_t launch_flags, // See LaunchFlags
|
2010-10-07 06:10:17 +08:00
|
|
|
bool stop_at_entry,
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
lldb::SBError& error
|
2010-10-07 06:10:17 +08:00
|
|
|
)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-29 12:59:35 +08:00
|
|
|
{
|
Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.
Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.
Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.
After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.
Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.
llvm-svn: 124060
2011-01-23 13:56:20 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...",
|
|
|
|
m_opaque_sp.get(),
|
|
|
|
argv,
|
|
|
|
envp,
|
|
|
|
stdin_path ? stdin_path : "NULL",
|
|
|
|
stdout_path ? stdout_path : "NULL",
|
|
|
|
stderr_path ? stderr_path : "NULL",
|
|
|
|
working_directory ? working_directory : "NULL",
|
|
|
|
launch_flags,
|
|
|
|
stop_at_entry,
|
|
|
|
error.get());
|
2010-10-29 12:59:35 +08:00
|
|
|
}
|
2010-10-06 11:53:16 +08:00
|
|
|
SBProcess sb_process;
|
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-10-06 11:53:16 +08:00
|
|
|
|
2011-01-27 09:01:10 +08:00
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR"))
|
|
|
|
launch_flags |= eLaunchFlagDisableASLR;
|
|
|
|
|
2011-01-27 14:44:37 +08:00
|
|
|
static const char *g_launch_tty = NULL;
|
|
|
|
static bool g_got_launch_tty = false;
|
|
|
|
if (!g_got_launch_tty)
|
|
|
|
{
|
|
|
|
// Get the LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY only once
|
|
|
|
g_got_launch_tty = true;
|
|
|
|
g_launch_tty = ::getenv ("LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY");
|
|
|
|
if (g_launch_tty)
|
|
|
|
{
|
|
|
|
// LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY is a path to a terminal to reuse
|
|
|
|
// if the first character is '/', else it is a boolean value.
|
|
|
|
if (g_launch_tty[0] != '/')
|
|
|
|
{
|
|
|
|
if (Args::StringToBoolean(g_launch_tty, false, NULL))
|
|
|
|
g_launch_tty = "";
|
|
|
|
else
|
|
|
|
g_launch_tty = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((launch_flags & eLaunchFlagLaunchInTTY) || g_launch_tty)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 09:01:10 +08:00
|
|
|
ArchSpec arch (m_opaque_sp->GetArchitecture ());
|
|
|
|
|
|
|
|
Module *exe_module = m_opaque_sp->GetExecutableModule().get();
|
|
|
|
if (exe_module)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-01-27 09:01:10 +08:00
|
|
|
char exec_file_path[PATH_MAX];
|
|
|
|
exe_module->GetFileSpec().GetPath(exec_file_path, sizeof(exec_file_path));
|
|
|
|
if (exe_module->GetFileSpec().Exists())
|
2010-10-06 11:53:16 +08:00
|
|
|
{
|
2011-01-27 09:01:10 +08:00
|
|
|
// Make a new argument vector
|
|
|
|
std::vector<const char *> exec_path_plus_argv;
|
|
|
|
// Append the resolved executable path
|
|
|
|
exec_path_plus_argv.push_back (exec_file_path);
|
|
|
|
|
|
|
|
// Push all args if there are any
|
|
|
|
if (argv)
|
|
|
|
{
|
|
|
|
for (int i = 0; argv[i]; ++i)
|
|
|
|
exec_path_plus_argv.push_back(argv[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push a NULL to terminate the args.
|
|
|
|
exec_path_plus_argv.push_back(NULL);
|
|
|
|
|
|
|
|
|
2011-01-27 14:44:37 +08:00
|
|
|
const char *tty_name = NULL;
|
|
|
|
if (g_launch_tty && g_launch_tty[0] == '/')
|
|
|
|
tty_name = g_launch_tty;
|
|
|
|
|
|
|
|
lldb::pid_t pid = Host::LaunchInNewTerminal (tty_name,
|
|
|
|
&exec_path_plus_argv[0],
|
|
|
|
envp,
|
|
|
|
working_directory,
|
|
|
|
&arch,
|
|
|
|
true,
|
|
|
|
launch_flags & eLaunchFlagDisableASLR);
|
|
|
|
|
2011-01-27 09:01:10 +08:00
|
|
|
if (pid != LLDB_INVALID_PROCESS_ID)
|
2010-10-06 11:53:16 +08:00
|
|
|
{
|
2011-02-04 05:28:34 +08:00
|
|
|
sb_process = AttachToProcessWithID(listener, pid, error);
|
2010-10-06 11:53:16 +08:00
|
|
|
}
|
2011-01-27 09:01:10 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat("failed to launch process in terminal");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat("executable doesn't exist: \"%s\"", exec_file_path);
|
2010-10-06 11:53:16 +08:00
|
|
|
}
|
2011-01-27 09:01:10 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat("invalid executable");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2010-10-07 06:10:17 +08:00
|
|
|
else
|
|
|
|
{
|
2011-02-04 05:28:34 +08:00
|
|
|
if (listener.IsValid())
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref()));
|
|
|
|
else
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
|
2011-01-27 09:01:10 +08:00
|
|
|
|
|
|
|
if (sb_process.IsValid())
|
|
|
|
{
|
|
|
|
|
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
|
|
|
|
launch_flags |= eLaunchFlagDisableSTDIO;
|
|
|
|
|
|
|
|
|
|
|
|
error.SetError (sb_process->Launch (argv, envp, launch_flags, stdin_path, stdout_path, stderr_path, working_directory));
|
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
// We we are stopping at the entry point, we can return now!
|
|
|
|
if (stop_at_entry)
|
|
|
|
return sb_process;
|
|
|
|
|
|
|
|
// Make sure we are stopped at the entry
|
|
|
|
StateType state = sb_process->WaitForProcessToStop (NULL);
|
|
|
|
if (state == eStateStopped)
|
|
|
|
{
|
|
|
|
// resume the process to skip the entry point
|
|
|
|
error.SetError (sb_process->Resume());
|
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop yet again!
|
|
|
|
if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false)
|
|
|
|
sb_process->WaitForProcessToStop (NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
2010-10-07 06:10:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 05:48:37 +08:00
|
|
|
log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)",
|
|
|
|
m_opaque_sp.get(), sb_process.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lldb::SBProcess
|
2010-10-07 12:19:01 +08:00
|
|
|
SBTarget::AttachToProcessWithID
|
2010-10-07 06:10:17 +08:00
|
|
|
(
|
2011-02-04 05:28:34 +08:00
|
|
|
SBListener &listener,
|
2010-10-07 06:10:17 +08:00
|
|
|
lldb::pid_t pid,// The process ID to attach to
|
|
|
|
SBError& error // An error explaining what went wrong if attach fails
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SBProcess sb_process;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2011-02-04 05:28:34 +08:00
|
|
|
if (listener.IsValid())
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref()));
|
|
|
|
else
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
|
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
|
|
|
|
if (sb_process.IsValid())
|
|
|
|
{
|
|
|
|
error.SetError (sb_process->Attach (pid));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
|
|
|
return sb_process;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBProcess
|
2010-10-07 12:19:01 +08:00
|
|
|
SBTarget::AttachToProcessWithName
|
2010-10-07 06:10:17 +08:00
|
|
|
(
|
2011-02-04 05:28:34 +08:00
|
|
|
SBListener &listener,
|
2010-10-07 06:10:17 +08:00
|
|
|
const char *name, // basename of process to attach to
|
|
|
|
bool wait_for, // if true wait for a new instance of "name" to be launched
|
|
|
|
SBError& error // An error explaining what went wrong if attach fails
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SBProcess sb_process;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
|
|
|
|
2011-02-04 05:28:34 +08:00
|
|
|
if (listener.IsValid())
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref()));
|
|
|
|
else
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener()));
|
2010-10-07 06:10:17 +08:00
|
|
|
|
|
|
|
if (sb_process.IsValid())
|
|
|
|
{
|
|
|
|
error.SetError (sb_process->Attach (name, wait_for));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-10-06 11:53:16 +08:00
|
|
|
return sb_process;
|
2010-10-07 06:10:17 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-03-04 08:31:13 +08:00
|
|
|
lldb::SBProcess
|
|
|
|
SBTarget::ConnectRemote
|
|
|
|
(
|
|
|
|
SBListener &listener,
|
|
|
|
const char *url,
|
|
|
|
const char *plugin_name,
|
|
|
|
SBError& error
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SBProcess sb_process;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
|
|
|
if (listener.IsValid())
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (listener.ref(), plugin_name));
|
|
|
|
else
|
|
|
|
sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener(), plugin_name));
|
|
|
|
|
|
|
|
|
|
|
|
if (sb_process.IsValid())
|
|
|
|
{
|
|
|
|
error.SetError (sb_process->ConnectRemote (url));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unable to create lldb_private::Process");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("SBTarget is invalid");
|
|
|
|
}
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec
|
|
|
|
SBTarget::GetExecutable ()
|
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec exe_file_spec;
|
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
|
|
|
ModuleSP exe_module_sp (m_opaque_sp->GetExecutableModule ());
|
2010-06-09 00:52:24 +08:00
|
|
|
if (exe_module_sp)
|
|
|
|
exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec());
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
|
|
|
|
m_opaque_sp.get(), exe_file_spec.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return exe_file_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DeleteTargetFromList (TargetList *list)
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
|
|
|
return list->DeleteTarget (m_opaque_sp);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::operator == (const SBTarget &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::operator != (const SBTarget &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb_private::Target *
|
2010-06-23 09:19:29 +08:00
|
|
|
SBTarget::operator ->() const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_sp.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2010-06-23 09:19:29 +08:00
|
|
|
|
|
|
|
lldb_private::Target *
|
|
|
|
SBTarget::get() const
|
|
|
|
{
|
|
|
|
return m_opaque_sp.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBTarget::reset (const lldb::TargetSP& target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp = target_sp;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-12-13 03:25:26 +08:00
|
|
|
bool
|
|
|
|
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr,
|
|
|
|
lldb::SBAddress& addr)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-12-13 03:25:26 +08:00
|
|
|
return m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, *addr);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-13 03:25:26 +08:00
|
|
|
|
|
|
|
addr->Clear();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-03 05:34:46 +08:00
|
|
|
SBSymbolContext
|
|
|
|
SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope)
|
|
|
|
{
|
|
|
|
SBSymbolContext sc;
|
|
|
|
if (m_opaque_sp)
|
|
|
|
m_opaque_sp->GetImages().ResolveSymbolContextForAddress (*addr, resolve_scope, sc.ref());
|
|
|
|
return sc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByLocation (const char *file, uint32_t line)
|
|
|
|
{
|
2010-11-08 08:28:40 +08:00
|
|
|
return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp.get() && line != 0)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
*sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_bp.GetDescription (sstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
char path[PATH_MAX];
|
|
|
|
sb_file_spec->GetPath (path, sizeof(path));
|
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s",
|
2010-10-30 12:51:46 +08:00
|
|
|
m_opaque_sp.get(),
|
2010-10-31 11:01:06 +08:00
|
|
|
path,
|
2010-10-30 12:51:46 +08:00
|
|
|
line,
|
2010-10-31 11:01:06 +08:00
|
|
|
sb_bp.get(),
|
2010-10-26 11:11:13 +08:00
|
|
|
sstr.GetData());
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp.get() && symbol_name && symbol_name[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
2010-10-21 04:54:39 +08:00
|
|
|
FileSpec module_file_spec(module_name, false);
|
2010-10-01 05:21:43 +08:00
|
|
|
*sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-01 05:21:43 +08:00
|
|
|
*sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, eFunctionNameTypeFull | eFunctionNameTypeBase, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
m_opaque_sp.get(), symbol_name, module_name, sb_bp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
RegularExpression regexp(symbol_name_regex);
|
|
|
|
|
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
2010-10-21 04:54:39 +08:00
|
|
|
FileSpec module_file_spec(module_name, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
*sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
*sb_bp = m_opaque_sp->CreateBreakpoint (NULL, regexp, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
|
|
|
|
m_opaque_sp.get(), symbol_name_regex, module_name, sb_bp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByAddress (addr_t address)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBBreakpoint sb_bp;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp.get())
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
*sb_bp = m_opaque_sp->CreateBreakpoint (address, false);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (%p, address=%p) => SBBreakpoint(%p)", m_opaque_sp.get(), address, sb_bp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::FindBreakpointByID (break_id_t bp_id)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
SBBreakpoint sb_breakpoint;
|
|
|
|
if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-07-24 07:33:17 +08:00
|
|
|
*sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
|
|
|
|
m_opaque_sp.get(), (uint32_t) bp_id, sb_breakpoint.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
return sb_breakpoint;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
uint32_t
|
|
|
|
SBTarget::GetNumBreakpoints () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2010-07-24 07:33:17 +08:00
|
|
|
return m_opaque_sp->GetBreakpointList().GetSize();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-07-24 07:33:17 +08:00
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
2010-07-24 07:33:17 +08:00
|
|
|
SBTarget::GetBreakpointAtIndex (uint32_t idx) const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SBBreakpoint sb_breakpoint;
|
2010-07-24 07:33:17 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2010-07-24 07:33:17 +08:00
|
|
|
*sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_breakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::BreakpointDelete (break_id_t bp_id)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
bool result = false;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-10-26 11:11:13 +08:00
|
|
|
result = m_opaque_sp->RemoveBreakpointByID (bp_id);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-29 12:59:35 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", m_opaque_sp.get(), (uint32_t) bp_id, result);
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::EnableAllBreakpoints ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->EnableAllBreakpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DisableAllBreakpoints ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->DisableAllBreakpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DeleteAllBreakpoints ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-12-21 04:49:23 +08:00
|
|
|
Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex());
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_sp->RemoveAllBreakpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBTarget::GetNumModules () const
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
uint32_t num = 0;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
|
|
|
num = m_opaque_sp->GetImages().GetSize();
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-29 12:59:35 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetNumModules () => %d", m_opaque_sp.get(), num);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return num;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
void
|
|
|
|
SBTarget::Clear ()
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-29 12:59:35 +08:00
|
|
|
log->Printf ("SBTarget(%p)::Clear ()", m_opaque_sp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-07-31 04:12:55 +08:00
|
|
|
m_opaque_sp.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBModule
|
|
|
|
SBTarget::FindModule (const SBFileSpec &sb_file_spec)
|
|
|
|
{
|
|
|
|
SBModule sb_module;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp && sb_file_spec.IsValid())
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBModule
|
|
|
|
SBTarget::GetModuleAtIndex (uint32_t idx)
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBModule sb_module;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
|
|
|
|
m_opaque_sp.get(), idx, sb_module.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBBroadcaster
|
|
|
|
SBTarget::GetBroadcaster () const
|
|
|
|
{
|
2010-11-06 09:53:30 +08:00
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
SBBroadcaster broadcaster(m_opaque_sp.get(), false);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-29 12:59:35 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
|
2010-10-27 07:49:36 +08:00
|
|
|
m_opaque_sp.get(), broadcaster.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return broadcaster;
|
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
|
|
|
|
bool
|
2010-10-26 11:11:13 +08:00
|
|
|
SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level)
|
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
|
|
|
{
|
|
|
|
description.ref();
|
|
|
|
m_opaque_sp->Dump (description.get(), description_level);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
description.Printf ("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level) const
|
2010-09-20 13:20:02 +08:00
|
|
|
{
|
|
|
|
if (m_opaque_sp)
|
2010-09-21 00:21:41 +08:00
|
|
|
{
|
2010-09-23 07:01:29 +08:00
|
|
|
description.ref();
|
2010-10-26 11:11:13 +08:00
|
|
|
m_opaque_sp->Dump (description.get(), description_level);
|
2010-09-21 00:21:41 +08:00
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
else
|
|
|
|
description.Printf ("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|