LLDB  mainline
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
lldb_private::TargetList Class Reference

#include <TargetList.h>

Inheritance diagram for lldb_private::TargetList:
Inheritance graph
[legend]
Collaboration diagram for lldb_private::TargetList:
Collaboration graph
[legend]

Public Types

enum  { eBroadcastBitInterrupt = (1 << 0) }
 Broadcaster event bits definitions. More...
 
typedef std::vector< lldb::TargetSP > collection
 
typedef LockingAdaptedIterable< collection, lldb::TargetSP, vector_adapter, std::recursive_mutex > TargetIterable
 

Public Member Functions

ConstStringGetBroadcasterClass () const override
 This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching. More...
 
Status CreateTarget (Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp)
 Create a new Target. More...
 
Status CreateTarget (Debugger &debugger, llvm::StringRef user_exe_path, const ArchSpec &arch, LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp)
 Create a new Target. More...
 
bool DeleteTarget (lldb::TargetSP &target_sp)
 Delete a Target object from the list. More...
 
int GetNumTargets () const
 
lldb::TargetSP GetTargetAtIndex (uint32_t index) const
 
uint32_t GetIndexOfTarget (lldb::TargetSP target_sp) const
 
lldb::TargetSP FindTargetWithExecutableAndArchitecture (const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr=nullptr) const
 Find the target that contains has an executable whose path matches exe_file_spec, and whose architecture matches arch_ptr if arch_ptr is not nullptr. More...
 
lldb::TargetSP FindTargetWithProcessID (lldb::pid_t pid) const
 Find the target that contains a process with process ID pid. More...
 
lldb::TargetSP FindTargetWithProcess (lldb_private::Process *process) const
 
lldb::TargetSP GetTargetSP (Target *target) const
 
uint32_t SendAsyncInterrupt (lldb::pid_t pid=LLDB_INVALID_PROCESS_ID)
 Send an async interrupt to one or all processes. More...
 
uint32_t SignalIfRunning (lldb::pid_t pid, int signo)
 
void SetSelectedTarget (uint32_t index)
 
void SetSelectedTarget (const lldb::TargetSP &target)
 
lldb::TargetSP GetSelectedTarget ()
 
TargetIterable Targets ()
 
- Public Member Functions inherited from lldb_private::Broadcaster
 Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name)
 Construct with a broadcaster with a name. More...
 
virtual ~Broadcaster ()
 Destructor. More...
 
void CheckInWithManager ()
 
void BroadcastEvent (lldb::EventSP &event_sp)
 Broadcast an event which has no associated data. More...
 
void BroadcastEventIfUnique (lldb::EventSP &event_sp)
 
void BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp)
 
void BroadcastEvent (uint32_t event_type, EventData *event_data=nullptr)
 
void BroadcastEventIfUnique (uint32_t event_type, EventData *event_data=nullptr)
 
void Clear ()
 
virtual void AddInitialEventsToListener (const lldb::ListenerSP &listener_sp, uint32_t requested_events)
 
uint32_t AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
 Listen for any events specified by event_mask. More...
 
ConstString GetBroadcasterName ()
 Get the NULL terminated C string name of this Broadcaster object. More...
 
bool GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const
 Get the event name(s) for one or more event bits. More...
 
void SetEventName (uint32_t event_mask, const char *name)
 Set the name for an event bit. More...
 
const char * GetEventName (uint32_t event_mask) const
 
bool EventTypeHasListeners (uint32_t event_type)
 
bool RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Removes a Listener from this broadcasters list and frees the event bits specified by event_mask that were previously acquired by listener (assuming listener was listening to this object) for other listener objects to use. More...
 
bool HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Provides a simple mechanism to temporarily redirect events from broadcaster. More...
 
bool IsHijackedForEvent (uint32_t event_mask)
 
void RestoreBroadcaster ()
 Restore the state of the Broadcaster from a previous hijack attempt. More...
 
lldb::BroadcasterManagerSP GetManager ()
 

Static Public Member Functions

static ConstStringGetStaticBroadcasterClass ()
 

Private Member Functions

 TargetList (Debugger &debugger)
 Constructor. More...
 
void AddTargetInternal (lldb::TargetSP target_sp, bool do_select)
 
void SetSelectedTargetInternal (uint32_t index)
 
 TargetList (const TargetList &)=delete
 
const TargetListoperator= (const TargetList &)=delete
 

Static Private Member Functions

static Status CreateTargetInternal (Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles load_dependent_files, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp)
 
static Status CreateTargetInternal (Debugger &debugger, llvm::StringRef user_exe_path, const ArchSpec &arch, LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp)
 

Private Attributes

collection m_target_list
 
std::recursive_mutex m_target_list_mutex
 
uint32_t m_selected_target_idx
 

Friends

class Debugger
 

Additional Inherited Members

- Protected Types inherited from lldb_private::Broadcaster
typedef std::shared_ptr< BroadcasterImplBroadcasterImplSP
 
typedef std::weak_ptr< BroadcasterImplBroadcasterImplWP
 
- Protected Member Functions inherited from lldb_private::Broadcaster
BroadcasterImplSP GetBroadcasterImpl ()
 
const char * GetHijackingListenerName ()
 

Detailed Description

Definition at line 21 of file TargetList.h.

Member Typedef Documentation

◆ collection

typedef std::vector<lldb::TargetSP> lldb_private::TargetList::collection

Definition at line 46 of file TargetList.h.

◆ TargetIterable

Definition at line 49 of file TargetList.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Broadcaster event bits definitions.

Enumerator
eBroadcastBitInterrupt 

Definition at line 36 of file TargetList.h.

Constructor & Destructor Documentation

◆ TargetList() [1/2]

TargetList::TargetList ( Debugger debugger)
private

Constructor.

The constructor for the target list is private. Clients can get ahold of of the one and only target list through the lldb_private::Debugger::GetSharedInstance().GetTargetList().

See also
static TargetList& lldb_private::Debugger::GetTargetList().

Definition at line 38 of file TargetList.cpp.

References lldb_private::Broadcaster::CheckInWithManager().

◆ TargetList() [2/2]

lldb_private::TargetList::TargetList ( const TargetList )
privatedelete

Member Function Documentation

◆ AddTargetInternal()

void TargetList::AddTargetInternal ( lldb::TargetSP  target_sp,
bool  do_select 
)
private

Definition at line 551 of file TargetList.cpp.

References lldbassert, m_target_list, and SetSelectedTargetInternal().

◆ CreateTarget() [1/2]

Status lldb_private::TargetList::CreateTarget ( Debugger debugger,
llvm::StringRef  user_exe_path,
const ArchSpec arch,
LoadDependentFiles  get_dependent_modules,
lldb::PlatformSP &  platform_sp,
lldb::TargetSP &  target_sp 
)

Create a new Target.

Same as the function above, but used when you already know the platform you will be using

◆ CreateTarget() [2/2]

Status lldb_private::TargetList::CreateTarget ( Debugger debugger,
llvm::StringRef  user_exe_path,
llvm::StringRef  triple_str,
LoadDependentFiles  get_dependent_modules,
const OptionGroupPlatform platform_options,
lldb::TargetSP &  target_sp 
)

Create a new Target.

Clients must use this function to create a Target. This allows a global list of targets to be maintained in a central location so signal handlers and other global functions can use it to locate an appropriate target to deliver asynchronous information to.

Parameters
[in]debuggerThe debugger to associate this target with
[in]user_exe_pathThe main executable file for a debug target. This value can be empty and the file can be set later using: Target::SetExecutableModule (ModuleSP&)
[in]triple_strA target triple string to be used for the target. This can be nullptr if the triple is not known or when attaching to a process.
[in]get_dependent_modulesTrack down the dependent modules for an executable and load those into the module list.
[in]platform_optionsA pointer to the platform options to use when creating this target. If this value is nullptr, then the currently selected platform will be used.
[out]target_spA shared pointer to a target that will be filled in if this call is successful.
Returns
An error object that indicates success or failure

Referenced by PlatformPOSIX::Attach(), lldb_private::PlatformWindows::Attach(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::Attach(), lldb_private::Platform::DoConnectProcess(), and CommandObjectTargetCreate::DoExecute().

◆ CreateTargetInternal() [1/2]

Status TargetList::CreateTargetInternal ( Debugger debugger,
llvm::StringRef  user_exe_path,
const ArchSpec arch,
LoadDependentFiles  get_dependent_modules,
lldb::PlatformSP &  platform_sp,
lldb::TargetSP &  target_sp 
)
staticprivate

◆ CreateTargetInternal() [2/2]

static Status lldb_private::TargetList::CreateTargetInternal ( Debugger debugger,
llvm::StringRef  user_exe_path,
llvm::StringRef  triple_str,
LoadDependentFiles  load_dependent_files,
const OptionGroupPlatform platform_options,
lldb::TargetSP &  target_sp 
)
staticprivate

◆ DeleteTarget()

bool TargetList::DeleteTarget ( lldb::TargetSP &  target_sp)

Delete a Target object from the list.

When clients are done with the Target objects, this function should be called to release the memory associated with a target object.

Parameters
[in]target_spThe shared pointer to a target.
Returns
Returns true if the target was successfully removed from from this target list, false otherwise. The client will be left with the last remaining shared pointer to the target in target_sp which can then be properly released.

Definition at line 407 of file TargetList.cpp.

References m_target_list, and m_target_list_mutex.

Referenced by CommandObjectTargetDelete::DoExecute().

◆ FindTargetWithExecutableAndArchitecture()

TargetSP TargetList::FindTargetWithExecutableAndArchitecture ( const FileSpec exe_file_spec,
const ArchSpec exe_arch_ptr = nullptr 
) const

Find the target that contains has an executable whose path matches exe_file_spec, and whose architecture matches arch_ptr if arch_ptr is not nullptr.

Parameters
[in]exe_file_specA file spec containing a basename, or a full path (directory and basename). If exe_file_spec contains only a filename (empty GetDirectory() value) then matching will be done solely based on the filenames and directories won't be compared. If exe_file_spec contains a filename and a directory, then both must match.
[in]exe_arch_ptrIf not nullptr then the architecture also needs to match, else the architectures will be compared.
Returns
A shared pointer to a target object. The returned shared pointer will contain nullptr if no target objects have a executable whose full or partial path matches with a matching process ID.

Definition at line 417 of file TargetList.cpp.

References m_target_list, and m_target_list_mutex.

◆ FindTargetWithProcess()

TargetSP TargetList::FindTargetWithProcess ( lldb_private::Process process) const

Definition at line 451 of file TargetList.cpp.

References m_target_list, and m_target_list_mutex.

◆ FindTargetWithProcessID()

TargetSP TargetList::FindTargetWithProcessID ( lldb::pid_t  pid) const

Find the target that contains a process with process ID pid.

Parameters
[in]pidThe process ID to search our target list for.
Returns
A shared pointer to a target object. The returned shared pointer will contain nullptr if no target objects own a process with a matching process ID.

Definition at line 437 of file TargetList.cpp.

References m_target_list, and m_target_list_mutex.

Referenced by SendAsyncInterrupt(), and SignalIfRunning().

◆ GetBroadcasterClass()

ConstString& lldb_private::TargetList::GetBroadcasterClass ( ) const
inlineoverridevirtual

This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching.

FIXME: Probably should make a ManagedBroadcaster subclass with all the bits needed to work with the BroadcasterManager, so that it is clearer how to add one.

Reimplemented from lldb_private::Broadcaster.

Definition at line 42 of file TargetList.h.

References GetStaticBroadcasterClass().

◆ GetIndexOfTarget()

uint32_t TargetList::GetIndexOfTarget ( lldb::TargetSP  target_sp) const

◆ GetNumTargets()

int TargetList::GetNumTargets ( ) const

◆ GetSelectedTarget()

lldb::TargetSP TargetList::GetSelectedTarget ( )

◆ GetStaticBroadcasterClass()

ConstString & TargetList::GetStaticBroadcasterClass ( )
static

Definition at line 32 of file TargetList.cpp.

Referenced by GetBroadcasterClass().

◆ GetTargetAtIndex()

lldb::TargetSP TargetList::GetTargetAtIndex ( uint32_t  index) const

◆ GetTargetSP()

TargetSP TargetList::GetTargetSP ( Target target) const

Definition at line 468 of file TargetList.cpp.

References m_target_list, and m_target_list_mutex.

◆ operator=()

const TargetList& lldb_private::TargetList::operator= ( const TargetList )
privatedelete

◆ SendAsyncInterrupt()

uint32_t TargetList::SendAsyncInterrupt ( lldb::pid_t  pid = LLDB_INVALID_PROCESS_ID)

Send an async interrupt to one or all processes.

Find the target that contains the process with process ID pid and send a LLDB_EVENT_ASYNC_INTERRUPT event to the process's event queue.

Parameters
[in]pidThe process ID to search our target list for, if pid is LLDB_INVALID_PROCESS_ID, then the interrupt will be sent to all processes.
Returns
The number of async interrupts sent.

Definition at line 482 of file TargetList.cpp.

References lldb_private::Broadcaster::BroadcastEvent(), lldb_private::Process::eBroadcastBitInterrupt, FindTargetWithProcessID(), LLDB_INVALID_PROCESS_ID, and lldb_private::Process::SendAsyncInterrupt().

◆ SetSelectedTarget() [1/2]

void lldb_private::TargetList::SetSelectedTarget ( const lldb::TargetSP &  target)

◆ SetSelectedTarget() [2/2]

void TargetList::SetSelectedTarget ( uint32_t  index)

◆ SetSelectedTargetInternal()

void TargetList::SetSelectedTargetInternal ( uint32_t  index)
private

Definition at line 560 of file TargetList.cpp.

References lldbassert, m_selected_target_idx, and m_target_list.

Referenced by AddTargetInternal(), and SetSelectedTarget().

◆ SignalIfRunning()

uint32_t TargetList::SignalIfRunning ( lldb::pid_t  pid,
int  signo 
)

◆ Targets()

TargetIterable lldb_private::TargetList::Targets ( )
inline

Definition at line 188 of file TargetList.h.

References m_target_list, and m_target_list_mutex.

Referenced by lldb_private::Debugger::Clear().

Friends And Related Function Documentation

◆ Debugger

friend class Debugger
friend

Definition at line 23 of file TargetList.h.

Member Data Documentation

◆ m_selected_target_idx

uint32_t lldb_private::TargetList::m_selected_target_idx
private

Definition at line 195 of file TargetList.h.

Referenced by GetSelectedTarget(), and SetSelectedTargetInternal().

◆ m_target_list

collection lldb_private::TargetList::m_target_list
private

◆ m_target_list_mutex

std::recursive_mutex lldb_private::TargetList::m_target_list_mutex
mutableprivate

The documentation for this class was generated from the following files: