blob: 05ffa5ac82687ffb1693d988608e3e7faca98b3a [file] [log] [blame]
//===-- SBTarget.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_SBTarget_h_
#define LLDB_SBTarget_h_
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBFileSpec.h"
namespace lldb {
class SBBreakpoint;
class SBTarget
{
public:
//------------------------------------------------------------------
// Broadcaster bits.
//------------------------------------------------------------------
enum
{
eBroadcastBitBreakpointChanged = (1 << 0),
eBroadcastBitModulesLoaded = (1 << 1),
eBroadcastBitModulesUnloaded = (1 << 2)
};
//------------------------------------------------------------------
// Constructors
//------------------------------------------------------------------
SBTarget ();
SBTarget (const lldb::SBTarget& rhs);
#ifndef SWIG
const lldb::SBTarget&
operator = (const lldb::SBTarget& rhs);
#endif
//------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------
~SBTarget();
bool
IsValid() const;
lldb::SBProcess
GetProcess ();
//------------------------------------------------------------------
/// Launch a new process.
///
/// Launch a new process by spawning a new process using the
/// target object's executable module's file as the file to launch.
/// Arguments are given in \a argv, and the environment variables
/// are in \a envp. Standard input and output files can be
/// optionally re-directed to \a stdin_path, \a stdout_path, and
/// \a stderr_path.
///
/// @param[in] listener
/// An optional listener that will receive all process events.
/// If \a listener is valid then \a listener will listen to all
/// process events. If not valid, then this target's debugger
/// (SBTarget::GetDebugger()) will listen to all process events.
///
/// @param[in] argv
/// The argument array.
///
/// @param[in] envp
/// The environment array.
///
/// @param[in] launch_flags
/// Flags to modify the launch (@see lldb::LaunchFlags)
///
/// @param[in] stdin_path
/// The path to use when re-directing the STDIN of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] stdout_path
/// The path to use when re-directing the STDOUT of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] stderr_path
/// The path to use when re-directing the STDERR of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] working_directory
/// The working directory to have the child process run in
///
/// @param[in] launch_flags
/// Some launch options specified by logical OR'ing
/// lldb::LaunchFlags enumeration values together.
///
/// @return
/// An error object. Call GetID() to get the process ID if
/// the error object is success.
//------------------------------------------------------------------
lldb::SBProcess
Launch (SBListener &listener,
char const **argv,
char const **envp,
const char *stdin_path,
const char *stdout_path,
const char *stderr_path,
const char *working_directory,
uint32_t launch_flags, // See LaunchFlags
bool stop_at_entry,
lldb::SBError& error);
//------------------------------------------------------------------
/// Launch a new process.
///
/// Launch a new process by spawning a new process using the
/// target object's executable module's file as the file to launch.
/// Arguments are given in \a argv, and the environment variables
/// are in \a envp. Standard input and output files can be
/// optionally re-directed to \a stdin_path, \a stdout_path, and
/// \a stderr_path.
///
/// @param[in] listener
/// An optional listener that will receive all process events.
/// If NULL, then the this target's debugger (SBTarget::GetDebugger())
/// will listen to all process events. If non-NULL, \a listener
/// will listen to all process events.
///
/// @param[in] argv
/// The argument array.
///
/// @param[in] envp
/// The environment array.
///
/// @param[in] launch_flags
/// Flags to modify the launch (@see lldb::LaunchFlags)
///
/// @param[in] stdin_path
/// The path to use when re-directing the STDIN of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] stdout_path
/// The path to use when re-directing the STDOUT of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] stderr_path
/// The path to use when re-directing the STDERR of the new
/// process. If all stdXX_path arguments are NULL, a pseudo
/// terminal will be used.
///
/// @param[in] working_directory
/// The working directory to have the child process run in
///
/// @param[in] launch_flags
/// Some launch options specified by logical OR'ing
/// lldb::LaunchFlags enumeration values together.
///
/// @return
/// An error object. Call GetID() to get the process ID if
/// the error object is success.
//------------------------------------------------------------------
lldb::SBProcess
AttachToProcessWithID (SBListener &listener,
lldb::pid_t pid, // The process ID to attach to
lldb::SBError& error); // An error explaining what went wrong if attach fails
lldb::SBProcess
AttachToProcessWithName (SBListener &listener,
const char *name, // basename of process to attach to
bool wait_for, // if true wait for a new instance of "name" to be launched
lldb::SBError& error); // An error explaining what went wrong if attach fails
lldb::SBProcess
ConnectRemote (SBListener &listener,
const char *url,
const char *plugin_name, // Can be NULL
SBError& error);
lldb::SBFileSpec
GetExecutable ();
uint32_t
GetNumModules () const;
lldb::SBModule
GetModuleAtIndex (uint32_t idx);
lldb::SBDebugger
GetDebugger() const;
lldb::SBModule
FindModule (const lldb::SBFileSpec &file_spec);
void
Clear ();
bool
DeleteTargetFromList (lldb_private::TargetList *list);
bool
ResolveLoadAddress (lldb::addr_t vm_addr,
lldb::SBAddress& addr);
SBSymbolContext
ResolveSymbolContextForAddress (const SBAddress& addr,
uint32_t resolve_scope);
lldb::SBBreakpoint
BreakpointCreateByLocation (const char *file, uint32_t line);
lldb::SBBreakpoint
BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
lldb::SBBreakpoint
BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
lldb::SBBreakpoint
BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
lldb::SBBreakpoint
BreakpointCreateByAddress (addr_t address);
uint32_t
GetNumBreakpoints () const;
lldb::SBBreakpoint
GetBreakpointAtIndex (uint32_t idx) const;
bool
BreakpointDelete (break_id_t break_id);
lldb::SBBreakpoint
FindBreakpointByID (break_id_t break_id);
bool
EnableAllBreakpoints ();
bool
DisableAllBreakpoints ();
bool
DeleteAllBreakpoints ();
lldb::SBBroadcaster
GetBroadcaster () const;
#ifndef SWIG
bool
operator == (const lldb::SBTarget &rhs) const;
bool
operator != (const lldb::SBTarget &rhs) const;
#endif
bool
GetDescription (lldb::SBStream &description, lldb::DescriptionLevel);
bool
GetDescription (lldb::SBStream &description, lldb::DescriptionLevel) const;
protected:
friend class SBAddress;
friend class SBDebugger;
friend class SBFunction;
friend class SBProcess;
friend class SBSymbol;
//------------------------------------------------------------------
// Constructors are private, use static Target::Create function to
// create an instance of this class.
//------------------------------------------------------------------
SBTarget (const lldb::TargetSP& target_sp);
void
reset (const lldb::TargetSP& target_sp);
lldb_private::Target *
operator ->() const;
lldb_private::Target *
get() const;
private:
//------------------------------------------------------------------
// For Target only
//------------------------------------------------------------------
lldb::TargetSP m_opaque_sp;
};
} // namespace lldb
#endif // LLDB_SBTarget_h_