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
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/API/SBDebugger.h"
|
|
|
|
#include "lldb/API/SBBreakpoint.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBFileSpec.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/API/SBListener.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBModule.h"
|
2011-09-13 08:29:56 +08:00
|
|
|
#include "lldb/API/SBSourceManager.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2011-06-21 09:34:41 +08:00
|
|
|
#include "lldb/API/SBSymbolContextList.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"
|
|
|
|
#include "lldb/Core/ArchSpec.h"
|
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
#include "lldb/Core/Disassembler.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-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
|
|
|
#include "lldb/Host/FileSpec.h"
|
2011-02-01 09:31:41 +08:00
|
|
|
#include "lldb/Host/Host.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Interpreter/Args.h"
|
2011-07-30 03:53:35 +08:00
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
2011-06-30 06:09:02 +08:00
|
|
|
#include "lldb/Symbol/VariableList.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"
|
|
|
|
|
|
|
|
|
|
|
|
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 ()
|
|
|
|
{
|
|
|
|
SBProcess sb_process;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), process_sp.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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
debugger.reset (target_sp->GetDebugger().shared_from_this());
|
2010-06-23 09:19:29 +08:00
|
|
|
return debugger;
|
|
|
|
}
|
|
|
|
|
2011-03-31 08:01:24 +08:00
|
|
|
SBProcess
|
|
|
|
SBTarget::LaunchSimple
|
|
|
|
(
|
|
|
|
char const **argv,
|
|
|
|
char const **envp,
|
|
|
|
const char *working_directory
|
|
|
|
)
|
|
|
|
{
|
|
|
|
char *stdin_path = NULL;
|
|
|
|
char *stdout_path = NULL;
|
|
|
|
char *stderr_path = NULL;
|
|
|
|
uint32_t launch_flags = 0;
|
|
|
|
bool stop_at_entry = false;
|
|
|
|
SBError error;
|
|
|
|
SBListener listener = GetDebugger().GetListener();
|
|
|
|
return Launch (listener,
|
|
|
|
argv,
|
|
|
|
envp,
|
|
|
|
stdin_path,
|
|
|
|
stdout_path,
|
|
|
|
stderr_path,
|
|
|
|
working_directory,
|
|
|
|
launch_flags,
|
|
|
|
stop_at_entry,
|
|
|
|
error);
|
|
|
|
}
|
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
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
SBProcess sb_process;
|
|
|
|
ProcessSP process_sp;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
|
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))...",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(),
|
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
|
|
|
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
|
|
|
}
|
2012-01-30 17:04:36 +08:00
|
|
|
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_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-04-30 09:09:13 +08:00
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-04-30 09:09:13 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
state = process_sp->GetState();
|
2011-04-30 09:09:13 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2011-04-30 09:09:13 +08:00
|
|
|
{
|
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == eStateConnected)
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
// If we are already connected, then we have already specified the
|
|
|
|
// listener, so if a valid listener is supplied, we need to error out
|
|
|
|
// to let the client know.
|
|
|
|
if (listener.IsValid())
|
2011-01-27 14:44:37 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
error.SetErrorString ("process is connected and already has a listener, pass empty listener");
|
|
|
|
return sb_process;
|
2011-01-27 14:44:37 +08:00
|
|
|
}
|
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
else
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2011-02-04 05:28:34 +08:00
|
|
|
if (listener.IsValid())
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref());
|
2011-02-04 05:28:34 +08:00
|
|
|
else
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener());
|
2011-04-30 09:09:13 +08:00
|
|
|
}
|
2011-01-27 09:01:10 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-04-30 09:09:13 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
2011-04-30 09:09:13 +08:00
|
|
|
if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO"))
|
|
|
|
launch_flags |= eLaunchFlagDisableSTDIO;
|
2011-01-27 09:01:10 +08:00
|
|
|
|
2011-11-04 05:22:33 +08:00
|
|
|
ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags);
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
2011-11-04 05:22:33 +08:00
|
|
|
if (exe_module)
|
2011-11-29 12:03:30 +08:00
|
|
|
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
|
2011-11-04 05:22:33 +08:00
|
|
|
if (argv)
|
|
|
|
launch_info.GetArguments().AppendArguments (argv);
|
|
|
|
if (envp)
|
|
|
|
launch_info.GetEnvironmentEntries ().SetArguments (envp);
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
error.SetError (process_sp->Launch (launch_info));
|
2011-04-30 09:09:13 +08:00
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
// We we are stopping at the entry point, we can return now!
|
|
|
|
if (stop_at_entry)
|
|
|
|
return sb_process;
|
2011-01-27 09:01:10 +08:00
|
|
|
|
2011-04-30 09:09:13 +08:00
|
|
|
// Make sure we are stopped at the entry
|
2012-01-30 15:41:31 +08:00
|
|
|
StateType state = process_sp->WaitForProcessToStop (NULL);
|
2011-04-30 09:09:13 +08:00
|
|
|
if (state == eStateStopped)
|
2011-01-27 09:01:10 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
// resume the process to skip the entry point
|
2012-01-30 15:41:31 +08:00
|
|
|
error.SetError (process_sp->Resume());
|
2011-04-30 09:09:13 +08:00
|
|
|
if (error.Success())
|
2011-01-27 09:01:10 +08:00
|
|
|
{
|
2011-04-30 09:09:13 +08:00
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop yet again!
|
2012-01-30 17:04:36 +08:00
|
|
|
if (target_sp->GetDebugger().GetAsyncExecution () == false)
|
2012-01-30 15:41:31 +08:00
|
|
|
process_sp->WaitForProcessToStop (NULL);
|
2011-01-27 09:01:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-30 09:09:13 +08:00
|
|
|
}
|
|
|
|
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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), process_sp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-10-07 06:10:17 +08:00
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
|
2011-12-02 10:10:57 +08:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
|
|
|
|
lldb::SBProcess
|
|
|
|
SBTarget::AttachToProcessWithID (SBListener &listener,
|
|
|
|
::pid_t pid,
|
|
|
|
lldb::SBError& error)
|
|
|
|
{
|
|
|
|
return AttachToProcessWithID (listener, (lldb::pid_t)pid, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #if defined(__APPLE__)
|
2010-10-07 06:10:17 +08:00
|
|
|
|
|
|
|
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;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-06-24 11:21:43 +08:00
|
|
|
|
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
state = process_sp->GetState();
|
2011-06-24 11:21:43 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == eStateConnected)
|
|
|
|
{
|
|
|
|
// If we are already connected, then we have already specified the
|
|
|
|
// listener, so if a valid listener is supplied, we need to error out
|
|
|
|
// to let the client know.
|
|
|
|
if (listener.IsValid())
|
|
|
|
{
|
|
|
|
error.SetErrorString ("process is connected and already has a listener, pass empty listener");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
2011-02-04 05:28:34 +08:00
|
|
|
else
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
|
|
|
if (listener.IsValid())
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref());
|
2011-06-24 11:21:43 +08:00
|
|
|
else
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener());
|
2011-06-24 11:21:43 +08:00
|
|
|
}
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
|
|
|
|
2011-11-15 11:53:30 +08:00
|
|
|
ProcessAttachInfo attach_info;
|
|
|
|
attach_info.SetProcessID (pid);
|
2012-01-30 15:41:31 +08:00
|
|
|
error.SetError (process_sp->Attach (attach_info));
|
2011-06-17 08:51:15 +08:00
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop!
|
2012-01-30 17:04:36 +08:00
|
|
|
if (target_sp->GetDebugger().GetAsyncExecution () == false)
|
2012-01-30 15:41:31 +08:00
|
|
|
process_sp->WaitForProcessToStop (NULL);
|
2010-10-07 06:10:17 +08:00
|
|
|
}
|
|
|
|
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;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (name && target_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-12-21 04:49:23 +08:00
|
|
|
|
2011-06-24 11:21:43 +08:00
|
|
|
StateType state = eStateInvalid;
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->GetProcessSP();
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
state = process_sp->GetState();
|
2011-06-24 11:21:43 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp->IsAlive() && state != eStateConnected)
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
|
|
|
if (state == eStateAttaching)
|
|
|
|
error.SetErrorString ("process attach is in progress");
|
|
|
|
else
|
|
|
|
error.SetErrorString ("a process is already being debugged");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == eStateConnected)
|
|
|
|
{
|
|
|
|
// If we are already connected, then we have already specified the
|
|
|
|
// listener, so if a valid listener is supplied, we need to error out
|
|
|
|
// to let the client know.
|
|
|
|
if (listener.IsValid())
|
|
|
|
{
|
|
|
|
error.SetErrorString ("process is connected and already has a listener, pass empty listener");
|
|
|
|
return sb_process;
|
|
|
|
}
|
|
|
|
}
|
2011-02-04 05:28:34 +08:00
|
|
|
else
|
2011-06-24 11:21:43 +08:00
|
|
|
{
|
|
|
|
if (listener.IsValid())
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref());
|
2011-06-24 11:21:43 +08:00
|
|
|
else
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener());
|
2011-06-24 11:21:43 +08:00
|
|
|
}
|
2010-10-07 06:10:17 +08:00
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2010-10-07 06:10:17 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
2011-11-15 11:53:30 +08:00
|
|
|
ProcessAttachInfo attach_info;
|
|
|
|
attach_info.GetExecutableFile().SetFile(name, false);
|
|
|
|
attach_info.SetWaitForLaunch(wait_for);
|
2012-01-30 15:41:31 +08:00
|
|
|
error.SetError (process_sp->Attach (attach_info));
|
2011-06-18 03:21:30 +08:00
|
|
|
// If we are doing synchronous mode, then wait for the
|
|
|
|
// process to stop!
|
2012-01-30 17:04:36 +08:00
|
|
|
if (target_sp->GetDebugger().GetAsyncExecution () == false)
|
2012-01-30 15:41:31 +08:00
|
|
|
process_sp->WaitForProcessToStop (NULL);
|
2010-10-07 06:10:17 +08:00
|
|
|
}
|
|
|
|
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;
|
2012-01-30 15:41:31 +08:00
|
|
|
ProcessSP process_sp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-03-04 08:31:13 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-03-04 08:31:13 +08:00
|
|
|
if (listener.IsValid())
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (listener.ref(), plugin_name);
|
2011-03-04 08:31:13 +08:00
|
|
|
else
|
2012-01-30 17:04:36 +08:00
|
|
|
process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name);
|
2011-03-04 08:31:13 +08:00
|
|
|
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
if (process_sp)
|
2011-03-04 08:31:13 +08:00
|
|
|
{
|
2012-01-30 15:41:31 +08:00
|
|
|
sb_process.SetSP (process_sp);
|
|
|
|
error.SetError (process_sp->ConnectRemote (url));
|
2011-03-04 08:31:13 +08:00
|
|
|
}
|
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Module *exe_module = target_sp->GetExecutableModulePointer();
|
2011-08-11 10:48:45 +08:00
|
|
|
if (exe_module)
|
|
|
|
exe_file_spec.SetFileSpec (exe_module->GetFileSpec());
|
2010-06-09 00:52:24 +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)::GetExecutable () => SBFileSpec(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_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::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
|
|
|
}
|
|
|
|
|
2012-01-30 15:41:31 +08:00
|
|
|
lldb::TargetSP
|
|
|
|
SBTarget::GetSP () const
|
2011-10-01 10:59:24 +08:00
|
|
|
{
|
|
|
|
return m_opaque_sp;
|
|
|
|
}
|
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
void
|
2012-01-30 15:41:31 +08:00
|
|
|
SBTarget::SetSP (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
|
|
|
}
|
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
lldb::SBAddress
|
|
|
|
SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr)
|
2010-12-13 03:25:26 +08:00
|
|
|
{
|
2011-07-23 00:46:35 +08:00
|
|
|
lldb::SBAddress sb_addr;
|
|
|
|
Address &addr = sb_addr.ref();
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
if (target_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr))
|
2011-07-23 00:46:35 +08:00
|
|
|
return sb_addr;
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-12-13 03:25:26 +08:00
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
// We have a load address that isn't in a section, just return an address
|
|
|
|
// with the offset filled in (the address) and the section set to NULL
|
|
|
|
addr.SetSection(NULL);
|
|
|
|
addr.SetOffset(vm_addr);
|
|
|
|
return sb_addr;
|
2010-12-13 03:25:26 +08:00
|
|
|
}
|
|
|
|
|
2011-03-03 05:34:46 +08:00
|
|
|
SBSymbolContext
|
|
|
|
SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope)
|
|
|
|
{
|
|
|
|
SBSymbolContext sc;
|
2012-01-30 17:04:36 +08:00
|
|
|
if (addr.IsValid())
|
|
|
|
{
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref());
|
|
|
|
}
|
2011-03-03 05:34:46 +08:00
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && line != 0)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_bp = target_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",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp.get())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
2011-09-21 09:17:13 +08:00
|
|
|
FileSpecList module_spec_list;
|
|
|
|
module_spec_list.Append (FileSpec (module_name, false));
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, 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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_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;
|
|
|
|
}
|
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByName (const char *symbol_name,
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
2011-10-11 09:18:55 +08:00
|
|
|
{
|
|
|
|
uint32_t name_type_mask = eFunctionNameTypeAuto;
|
|
|
|
return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByName (const char *symbol_name,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && symbol_name && symbol_name[0])
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_bp = target_sp->CreateBreakpoint (module_list.get(),
|
2011-09-23 08:54:11 +08:00
|
|
|
comp_unit_list.get(),
|
|
|
|
symbol_name,
|
2011-10-11 09:18:55 +08:00
|
|
|
name_type_mask,
|
2011-09-23 08:54:11 +08:00
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2011-10-11 09:18:55 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), symbol_name, name_type_mask, sb_bp.get());
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && symbol_name_regex && symbol_name_regex[0])
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2010-06-09 00:52:24 +08:00
|
|
|
RegularExpression regexp(symbol_name_regex);
|
|
|
|
|
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
2011-09-21 09:17:13 +08:00
|
|
|
FileSpecList module_spec_list;
|
|
|
|
module_spec_list.Append (FileSpec (module_name, false));
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, false);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, 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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_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;
|
|
|
|
}
|
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex,
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const SBFileSpecList &comp_unit_list)
|
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && symbol_name_regex && symbol_name_regex[0])
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-09-23 08:54:11 +08:00
|
|
|
RegularExpression regexp(symbol_name_regex);
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, false);
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), symbol_name_regex, sb_bp.get());
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_bp = target_sp->CreateBreakpoint (address, false);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", target_sp.get(), (uint64_t) address, sb_bp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-21 09:17:13 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name)
|
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && source_regex && source_regex[0])
|
2011-09-21 09:17:13 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-09-21 09:17:13 +08:00
|
|
|
RegularExpression regexp(source_regex);
|
2011-09-23 08:54:11 +08:00
|
|
|
FileSpecList source_file_spec_list;
|
|
|
|
source_file_spec_list.Append (source_file.ref());
|
2011-09-21 09:17:13 +08:00
|
|
|
|
|
|
|
if (module_name && module_name[0])
|
|
|
|
{
|
|
|
|
FileSpecList module_spec_list;
|
|
|
|
module_spec_list.Append (FileSpec (module_name, false));
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false);
|
2011-09-21 09:17:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false);
|
2011-09-21 09:17:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
source_file->GetPath (path, sizeof(path));
|
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), source_regex, path, module_name, sb_bp.get());
|
2011-09-21 09:17:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
|
|
|
|
2011-09-23 08:54:11 +08:00
|
|
|
lldb::SBBreakpoint
|
|
|
|
SBTarget::BreakpointCreateBySourceRegex (const char *source_regex,
|
|
|
|
const SBFileSpecList &module_list,
|
|
|
|
const lldb::SBFileSpecList &source_file_list)
|
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBBreakpoint sb_bp;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && source_regex && source_regex[0])
|
2011-09-23 08:54:11 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-09-23 08:54:11 +08:00
|
|
|
RegularExpression regexp(source_regex);
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false);
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), source_regex, sb_bp.get());
|
2011-09-23 08:54:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_bp;
|
|
|
|
}
|
2011-09-21 09:17:13 +08:00
|
|
|
|
2011-09-27 06:40:50 +08:00
|
|
|
uint32_t
|
|
|
|
SBTarget::GetNumBreakpoints () const
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
return target_sp->GetBreakpointList().GetSize();
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBBreakpoint
|
|
|
|
SBTarget::GetBreakpointAtIndex (uint32_t idx) const
|
|
|
|
{
|
|
|
|
SBBreakpoint sb_breakpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
|
|
|
// The breakpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
return sb_breakpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::BreakpointDelete (break_id_t bp_id)
|
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
bool result = false;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
result = target_sp->RemoveBreakpointByID (bp_id);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", target_sp.get(), (uint32_t) bp_id, result);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && bp_id != LLDB_INVALID_BREAK_ID)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_breakpoint = target_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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_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
|
|
|
|
2011-09-27 06:40:50 +08:00
|
|
|
bool
|
|
|
|
SBTarget::EnableAllBreakpoints ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->EnableAllBreakpoints ();
|
2011-09-27 06:40:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DisableAllBreakpoints ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->DisableAllBreakpoints ();
|
2011-09-27 06:40:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::DeleteAllBreakpoints ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->RemoveAllBreakpoints ();
|
2011-09-27 06:40:50 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-07-24 07:33:17 +08:00
|
|
|
uint32_t
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::GetNumWatchpoints () const
|
2010-07-24 07:33:17 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
// The watchpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
return target_sp->GetWatchpointList().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
|
|
|
}
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint
|
|
|
|
SBTarget::GetWatchpointAtIndex (uint32_t idx) const
|
2011-09-28 04:29:45 +08:00
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
// The watchpoint list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
*sb_watchpoint = target_sp->GetWatchpointList().GetByIndex(idx);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2011-10-14 08:42:25 +08:00
|
|
|
return sb_watchpoint;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::DeleteWatchpoint (watch_id_t wp_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
|
|
|
|
|
|
|
bool result = false;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
result = target_sp->RemoveWatchpointByID (wp_id);
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", target_sp.get(), (uint32_t) wp_id, result);
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint
|
|
|
|
SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && wp_id != LLDB_INVALID_WATCH_ID)
|
2011-09-27 06:40:50 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
*sb_watchpoint = target_sp->GetWatchpointList().FindByID(wp_id);
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
2011-10-14 08:42:25 +08:00
|
|
|
log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), (uint32_t) wp_id, sb_watchpoint.get());
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
2011-10-14 02:08:26 +08:00
|
|
|
return sb_watchpoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBWatchpoint
|
|
|
|
SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write)
|
|
|
|
{
|
|
|
|
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
|
|
|
|
|
|
|
SBWatchpoint sb_watchpoint;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-10-14 02:08:26 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
2011-10-14 08:42:25 +08:00
|
|
|
uint32_t watch_type = (read ? LLDB_WATCH_TYPE_READ : 0) |
|
|
|
|
(write ? LLDB_WATCH_TYPE_WRITE : 0);
|
2012-01-30 17:04:36 +08:00
|
|
|
sb_watchpoint = target_sp->CreateWatchpoint(addr, size, watch_type);
|
2011-10-14 02:08:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%llx, 0x%u) => SBWatchpoint(%p)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), addr, (uint32_t) size, sb_watchpoint.get());
|
2011-10-14 02:08:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return sb_watchpoint;
|
2011-09-27 06:40:50 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::EnableAllWatchpoints ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->EnableAllWatchpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::DisableAllWatchpoints ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->DisableAllWatchpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-10-14 02:08:26 +08:00
|
|
|
SBTarget::DeleteAllWatchpoints ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
Mutex::Locker api_locker (target_sp->GetAPIMutex());
|
|
|
|
target_sp->RemoveAllWatchpoints ();
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
lldb::SBModule
|
|
|
|
SBTarget::AddModule (const char *path,
|
|
|
|
const char *triple,
|
|
|
|
const char *uuid_cstr)
|
|
|
|
{
|
|
|
|
lldb::SBModule sb_module;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
|
|
|
FileSpec module_file_spec;
|
|
|
|
UUID module_uuid;
|
|
|
|
ArchSpec module_arch;
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
module_file_spec.SetFile(path, false);
|
|
|
|
|
|
|
|
if (uuid_cstr)
|
|
|
|
module_uuid.SetfromCString(uuid_cstr);
|
|
|
|
|
|
|
|
if (triple)
|
2012-01-30 17:04:36 +08:00
|
|
|
module_arch.SetTriple (triple, target_sp->GetPlatform ().get());
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
sb_module.SetSP(target_sp->GetSharedModule (module_file_spec,
|
|
|
|
module_arch,
|
|
|
|
uuid_cstr ? &module_uuid : NULL));
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBTarget::AddModule (lldb::SBModule &module)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->GetImages().AppendIfNeeded (module.GetSP());
|
2011-09-24 08:52:29 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
num = target_sp->GetImages().GetSize();
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2012-01-30 17:04:36 +08:00
|
|
|
log->Printf ("SBTarget(%p)::GetNumModules () => %d", target_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;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp && sb_file_spec.IsValid())
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
sb_module.SetSP (target_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL, NULL));
|
2010-12-21 04:49:23 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
2012-01-29 14:07:39 +08:00
|
|
|
lldb::ByteOrder
|
|
|
|
SBTarget::GetByteOrder ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
return target_sp->GetArchitecture().GetByteOrder();
|
2012-01-29 14:07:39 +08:00
|
|
|
return eByteOrderInvalid;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBTarget::GetTriple ()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2012-01-29 14:07:39 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
std::string triple (target_sp->GetArchitecture().GetTriple().str());
|
2012-01-29 14:07:39 +08:00
|
|
|
// Unique the string so we don't run into ownership issues since
|
|
|
|
// the const strings put the string into the string pool once and
|
|
|
|
// the strings never comes out
|
|
|
|
ConstString const_triple (triple.c_str());
|
|
|
|
return const_triple.GetCString();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBTarget::GetAddressByteSize()
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
return target_sp->GetArchitecture().GetAddressByteSize();
|
2012-01-29 14:07:39 +08:00
|
|
|
return sizeof(void*);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
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;
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp;
|
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-12-21 04:49:23 +08:00
|
|
|
{
|
|
|
|
// The module list is thread safe, no need to lock
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp = target_sp->GetImages().GetModuleAtIndex(idx);
|
|
|
|
sb_module.SetSP (module_sp);
|
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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp.get(), idx, module_sp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_module;
|
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
bool
|
|
|
|
SBTarget::RemoveModule (lldb::SBModule module)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
return target_sp->GetImages().Remove(module.GetSP());
|
2011-09-24 08:52:29 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
SBBroadcaster broadcaster(target_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)",
|
2012-01-30 17:04:36 +08:00
|
|
|
target_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)
|
|
|
|
{
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2010-09-21 00:21:41 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->Dump (&strm, description_level);
|
2010-09-21 00:21:41 +08:00
|
|
|
}
|
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;
|
|
|
|
}
|
2011-06-21 09:34:41 +08:00
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBTarget::FindFunctions (const char *name,
|
|
|
|
uint32_t name_type_mask,
|
|
|
|
bool append,
|
|
|
|
lldb::SBSymbolContextList& sc_list)
|
|
|
|
{
|
|
|
|
if (!append)
|
|
|
|
sc_list.Clear();
|
2012-01-30 17:04:36 +08:00
|
|
|
if (name && name[0])
|
2011-06-21 09:34:41 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
|
|
|
{
|
|
|
|
const bool symbols_ok = true;
|
|
|
|
return target_sp->GetImages().FindFunctions (ConstString(name),
|
|
|
|
name_type_mask,
|
|
|
|
symbols_ok,
|
|
|
|
append,
|
|
|
|
*sc_list);
|
|
|
|
}
|
2011-06-21 09:34:41 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-07-30 03:53:35 +08:00
|
|
|
lldb::SBType
|
|
|
|
SBTarget::FindFirstType (const char* type)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (type && target_sp)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
size_t count = target_sp->GetImages().GetSize();
|
2011-07-30 03:53:35 +08:00
|
|
|
for (size_t idx = 0; idx < count; idx++)
|
|
|
|
{
|
|
|
|
SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type);
|
|
|
|
|
|
|
|
if (found_at_idx.IsValid())
|
|
|
|
return found_at_idx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SBType();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBTypeList
|
|
|
|
SBTarget::FindTypes (const char* type)
|
|
|
|
{
|
|
|
|
|
|
|
|
SBTypeList retval;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (type && target_sp)
|
2011-07-30 03:53:35 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleList& images = target_sp->GetImages();
|
2011-07-30 03:53:35 +08:00
|
|
|
ConstString name_const(type);
|
|
|
|
SymbolContext sc;
|
|
|
|
TypeList type_list;
|
|
|
|
|
|
|
|
uint32_t num_matches = images.FindTypes(sc,
|
|
|
|
name_const,
|
|
|
|
true,
|
|
|
|
UINT32_MAX,
|
|
|
|
type_list);
|
|
|
|
|
|
|
|
for (size_t idx = 0; idx < num_matches; idx++)
|
|
|
|
{
|
2011-08-04 06:57:10 +08:00
|
|
|
TypeSP type_sp (type_list.GetTypeAtIndex(idx));
|
|
|
|
if (type_sp)
|
|
|
|
retval.Append(SBType(type_sp));
|
2011-07-30 03:53:35 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2011-06-30 06:09:02 +08:00
|
|
|
SBValueList
|
|
|
|
SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
|
|
|
|
{
|
|
|
|
SBValueList sb_value_list;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (name && target_sp)
|
2011-06-30 06:09:02 +08:00
|
|
|
{
|
|
|
|
VariableList variable_list;
|
|
|
|
const bool append = true;
|
2012-01-30 17:04:36 +08:00
|
|
|
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name),
|
|
|
|
append,
|
|
|
|
max_matches,
|
|
|
|
variable_list);
|
2011-06-30 06:09:02 +08:00
|
|
|
|
|
|
|
if (match_count > 0)
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
|
2011-06-30 06:09:02 +08:00
|
|
|
if (exe_scope == NULL)
|
2012-01-30 17:04:36 +08:00
|
|
|
exe_scope = target_sp.get();
|
2011-06-30 06:09:02 +08:00
|
|
|
ValueObjectList &value_object_list = sb_value_list.ref();
|
|
|
|
for (uint32_t i=0; i<match_count; ++i)
|
|
|
|
{
|
|
|
|
lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i)));
|
|
|
|
if (valobj_sp)
|
|
|
|
value_object_list.Append(valobj_sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb_value_list;
|
|
|
|
}
|
|
|
|
|
2011-09-13 08:29:56 +08:00
|
|
|
SBSourceManager
|
|
|
|
SBTarget::GetSourceManager()
|
|
|
|
{
|
|
|
|
SBSourceManager source_manager (*this);
|
|
|
|
return source_manager;
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2011-12-15 07:49:37 +08:00
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size)
|
|
|
|
{
|
|
|
|
SBInstructionList sb_instructions;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-12-15 07:49:37 +08:00
|
|
|
{
|
|
|
|
Address addr;
|
|
|
|
|
|
|
|
if (base_addr.get())
|
|
|
|
addr = *base_addr.get();
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(),
|
2011-12-15 07:49:37 +08:00
|
|
|
NULL,
|
|
|
|
addr,
|
|
|
|
buf,
|
|
|
|
size));
|
|
|
|
}
|
|
|
|
|
|
|
|
return sb_instructions;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::SBInstructionList
|
|
|
|
SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size)
|
|
|
|
{
|
|
|
|
return GetInstructions (ResolveLoadAddress(base_addr), buf, size);
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::SetSectionLoadAddress (lldb::SBSection section,
|
|
|
|
lldb::addr_t section_base_addr)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
|
|
|
if (!section.IsValid())
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid section");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->GetSectionLoadList().SetSectionLoadAddress (section.GetSection(), section_base_addr);
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::ClearSectionLoadAddress (lldb::SBSection section)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
|
|
|
if (!section.IsValid())
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid section");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection());
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
|
|
|
char path[PATH_MAX];
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp (module.GetSP());
|
|
|
|
if (module_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ObjectFile *objfile = module_sp->GetObjectFile();
|
2011-09-24 08:52:29 +08:00
|
|
|
if (objfile)
|
|
|
|
{
|
|
|
|
SectionList *section_list = objfile->GetSectionList();
|
|
|
|
if (section_list)
|
|
|
|
{
|
|
|
|
const size_t num_sections = section_list->GetSize();
|
|
|
|
for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
|
|
|
|
{
|
|
|
|
SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
|
|
|
|
if (section_sp)
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), section_sp->GetFileAddress() + slide_offset);
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp->GetFileSpec().GetPath (path, sizeof(path));
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp->GetFileSpec().GetPath (path, sizeof(path));
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path);
|
|
|
|
}
|
|
|
|
}
|
2012-01-30 17:04:36 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid module");
|
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBError
|
|
|
|
SBTarget::ClearModuleLoadAddress (lldb::SBModule module)
|
|
|
|
{
|
|
|
|
SBError sb_error;
|
|
|
|
|
|
|
|
char path[PATH_MAX];
|
2012-01-30 17:04:36 +08:00
|
|
|
TargetSP target_sp(GetSP());
|
|
|
|
if (target_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ModuleSP module_sp (module.GetSP());
|
|
|
|
if (module_sp)
|
2011-09-24 08:52:29 +08:00
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
ObjectFile *objfile = module_sp->GetObjectFile();
|
2011-09-24 08:52:29 +08:00
|
|
|
if (objfile)
|
|
|
|
{
|
|
|
|
SectionList *section_list = objfile->GetSectionList();
|
|
|
|
if (section_list)
|
|
|
|
{
|
|
|
|
const size_t num_sections = section_list->GetSize();
|
|
|
|
for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx)
|
|
|
|
{
|
|
|
|
SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx));
|
|
|
|
if (section_sp)
|
2012-01-30 17:04:36 +08:00
|
|
|
target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp.get());
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp->GetFileSpec().GetPath (path, sizeof(path));
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-30 17:04:36 +08:00
|
|
|
module_sp->GetFileSpec().GetPath (path, sizeof(path));
|
2011-09-24 08:52:29 +08:00
|
|
|
sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path);
|
|
|
|
}
|
|
|
|
}
|
2012-01-30 17:04:36 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid module");
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sb_error.SetErrorStringWithFormat ("invalid target");
|
|
|
|
}
|
|
|
|
return sb_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|