LLDB  mainline
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected 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...
 

Public Member Functions

ConstStringGetBroadcasterClass () const override
 
 ~TargetList () override
 
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)
 
uint32_t SetSelectedTarget (Target *target)
 
lldb::TargetSP GetSelectedTarget ()
 
- 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 ()
 

Protected Types

typedef std::vector< lldb::TargetSP > collection
 
- Protected Types inherited from lldb_private::Broadcaster
typedef std::shared_ptr< BroadcasterImplBroadcasterImplSP
 
typedef std::weak_ptr< BroadcasterImplBroadcasterImplWP
 

Protected Attributes

collection m_target_list
 
lldb::TargetSP m_dummy_target_sp
 
std::recursive_mutex m_target_list_mutex
 
uint32_t m_selected_target_idx
 

Friends

class Debugger
 

Additional Inherited Members

- Protected Member Functions inherited from lldb_private::Broadcaster
BroadcasterImplSP GetBroadcasterImpl ()
 
const char * GetHijackingListenerName ()
 

Detailed Description

Definition at line 20 of file TargetList.h.

Member Typedef Documentation

◆ collection

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

Definition at line 183 of file TargetList.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Broadcaster event bits definitions.

Enumerator
eBroadcastBitInterrupt 

Definition at line 35 of file TargetList.h.

Constructor & Destructor Documentation

◆ ~TargetList()

TargetList::~TargetList ( )
override

Definition at line 46 of file TargetList.cpp.

References lldb_private::FileSpec::AppendPathComponent(), lldb_private::OptionGroupPlatform::CreatePlatformWithOptions(), lldb_private::ArchSpec::DumpTriple(), lldb_private::eLoadDependentsNo, lldb_private::ModuleSpecList::FindMatchingModuleSpec(), lldb_private::ModuleSpec::GetArchitecture(), lldb_private::ArchSpec::GetArchitectureName(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::StreamString::GetData(), lldb_private::FileSpec::GetDirectory(), lldb_private::Debugger::GetDummyTarget(), lldb_private::ModuleSpec::GetFileSpec(), lldb_private::ModuleSpecList::GetModuleSpecAtIndex(), lldb_private::Platform::GetName(), lldb_private::FileSpec::GetPath(), lldb_private::Debugger::GetPlatformList(), lldb_private::PlatformList::GetSelectedPlatform(), lldb_private::StreamString::GetString(), lldb_private::ArchSpec::GetTriple(), lldb_private::ArchSpec::IsCompatibleMatch(), lldb_private::FileSpec::IsRelative(), lldb_private::ArchSpec::IsValid(), PATH_MAX, lldb_private::OptionGroupPlatform::PlatformMatches(), lldb_private::OptionGroupPlatform::PlatformWasSpecified(), lldb_private::Stream::Printf(), lldb_private::Stream::PutCString(), lldb_private::TildeExpressionResolver::ResolveFullPath(), lldb_private::Status::SetErrorString(), lldb_private::Status::SetErrorStringWithFormat(), lldb_private::FileSpec::SetFile(), lldb_private::PlatformList::SetSelectedPlatform(), lldb_private::ArchSpec::TripleOSWasSpecified(), and lldb_private::ArchSpec::TripleVendorWasSpecified().

Referenced by GetBroadcasterClass().

Member Function Documentation

◆ CreateTarget() [1/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]file_specThe main executable file for a debug target. This value can be nullptr and the file can be set later using: Target::SetExecutableModule (ModuleSP&)
[in]triple_cstrA 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::platform_freebsd::PlatformFreeBSD::Attach(), lldb_private::PlatformWindows::Attach(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::Attach(), lldb_private::Platform::ConnectProcess(), lldb_private::platform_netbsd::PlatformNetBSD::DebugProcess(), lldb_private::platform_linux::PlatformLinux::DebugProcess(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::DebugProcess(), CommandObjectTargetCreate::DoExecute(), and GetBroadcasterClass().

◆ CreateTarget() [2/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

◆ 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 443 of file TargetList.cpp.

Referenced by CommandObjectTargetDelete::DoExecute(), and GetBroadcasterClass().

◆ 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 456 of file TargetList.cpp.

References lldb_private::Module::GetArchitecture(), lldb_private::FileSpec::GetDirectory(), lldb_private::Module::GetFileSpec(), and lldb_private::ArchSpec::IsCompatibleMatch().

Referenced by GetBroadcasterClass().

◆ FindTargetWithProcess()

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

Definition at line 495 of file TargetList.cpp.

Referenced by GetBroadcasterClass().

◆ 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 481 of file TargetList.cpp.

References lldb_private::UserID::GetID().

Referenced by GetBroadcasterClass().

◆ GetBroadcasterClass()

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

◆ 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.

References lldb_private::Debugger::GetBroadcasterManager().

Referenced by GetBroadcasterClass().

◆ GetTargetAtIndex()

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

◆ GetTargetSP()

TargetSP TargetList::GetTargetSP ( Target target) const

Definition at line 510 of file TargetList.cpp.

Referenced by GetBroadcasterClass().

◆ 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 525 of file TargetList.cpp.

References LLDB_INVALID_PROCESS_ID, and lldb_private::Process::SendAsyncInterrupt().

Referenced by GetBroadcasterClass().

◆ SetSelectedTarget()

uint32_t TargetList::SetSelectedTarget ( Target target)

◆ SignalIfRunning()

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

Friends And Related Function Documentation

◆ Debugger

friend class Debugger
friend

Definition at line 22 of file TargetList.h.

Member Data Documentation

◆ m_dummy_target_sp

lldb::TargetSP lldb_private::TargetList::m_dummy_target_sp
protected

Definition at line 186 of file TargetList.h.

◆ m_selected_target_idx

uint32_t lldb_private::TargetList::m_selected_target_idx
protected

Definition at line 188 of file TargetList.h.

◆ m_target_list

collection lldb_private::TargetList::m_target_list
protected

Definition at line 185 of file TargetList.h.

◆ m_target_list_mutex

std::recursive_mutex lldb_private::TargetList::m_target_list_mutex
mutableprotected

Definition at line 187 of file TargetList.h.


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