LLDB mainline
|
#include <TargetList.h>
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 | |
ConstString & | GetBroadcasterClass () 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. | |
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. | |
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. | |
bool | DeleteTarget (lldb::TargetSP &target_sp) |
Delete a Target object from the list. | |
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. | |
lldb::TargetSP | FindTargetWithProcessID (lldb::pid_t pid) const |
Find the target that contains a process with process ID pid. | |
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. | |
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 () |
![]() | |
Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name) | |
Construct with a broadcaster with a name. | |
virtual | ~Broadcaster () |
Destructor. | |
void | CheckInWithManager () |
void | BroadcastEvent (lldb::EventSP &event_sp) |
Broadcast an event which has no associated data. | |
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. | |
ConstString | GetBroadcasterName () |
Get the NULL terminated C string name of this Broadcaster object. | |
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. | |
void | SetEventName (uint32_t event_mask, const char *name) |
Set the name for an event bit. | |
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. | |
bool | HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX) |
Provides a simple mechanism to temporarily redirect events from broadcaster. | |
bool | IsHijackedForEvent (uint32_t event_mask) |
void | RestoreBroadcaster () |
Restore the state of the Broadcaster from a previous hijack attempt. | |
virtual ConstString & | GetBroadcasterClass () const |
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching. | |
lldb::BroadcasterManagerSP | GetManager () |
virtual void | SetShadowListener (lldb::ListenerSP listener_sp) |
Static Public Member Functions | |
static ConstString & | GetStaticBroadcasterClass () |
Private Member Functions | |
TargetList (Debugger &debugger) | |
Constructor. | |
void | AddTargetInternal (lldb::TargetSP target_sp, bool do_select) |
void | SetSelectedTargetInternal (uint32_t index) |
TargetList (const TargetList &)=delete | |
const TargetList & | operator= (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 | |
![]() | |
typedef std::shared_ptr< BroadcasterImpl > | BroadcasterImplSP |
typedef std::weak_ptr< BroadcasterImpl > | BroadcasterImplWP |
![]() | |
BroadcasterImplSP | GetBroadcasterImpl () |
const char * | GetHijackingListenerName () |
Definition at line 21 of file TargetList.h.
typedef std::vector<lldb::TargetSP> lldb_private::TargetList::collection |
Definition at line 46 of file TargetList.h.
typedef LockingAdaptedIterable<collection, lldb::TargetSP, vector_adapter, std::recursive_mutex> lldb_private::TargetList::TargetIterable |
Definition at line 49 of file TargetList.h.
anonymous enum |
Broadcaster event bits definitions.
Enumerator | |
---|---|
eBroadcastBitInterrupt |
Definition at line 36 of file TargetList.h.
|
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().
Definition at line 38 of file TargetList.cpp.
References lldb_private::Broadcaster::CheckInWithManager().
|
privatedelete |
|
private |
Definition at line 513 of file TargetList.cpp.
References lldbassert, m_target_list, and SetSelectedTargetInternal().
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
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.
[in] | debugger | The debugger to associate this target with |
[in] | user_exe_path | The 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_str | A 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_modules | Track down the dependent modules for an executable and load those into the module list. |
[in] | platform_options | A 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_sp | A shared pointer to a target that will be filled in if this call is successful. |
Referenced by PlatformPOSIX::Attach(), lldb_private::PlatformWindows::Attach(), lldb_private::platform_gdb_server::PlatformRemoteGDBServer::Attach(), lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::CreateEmptyProcess(), lldb_private::Platform::DoConnectProcess(), CommandObjectProcessAttach::DoExecute(), and CommandObjectTargetCreate::DoExecute().
|
staticprivate |
Definition at line 246 of file TargetList.cpp.
References lldb_private::FileSpec::AppendPathComponent(), lldb_private::ArchSpec::CompatibleMatch, error(), lldb_private::ArchSpec::GetArchitectureName(), lldb_private::Target::GetDefaultExecutableSearchPaths(), lldb_private::FileSpec::GetDirectory(), lldb_private::Debugger::GetDummyTarget(), lldb_private::PlatformList::GetOrCreate(), lldb_private::FileSpec::GetPath(), lldb_private::Debugger::GetPlatformList(), lldb_private::PlatformList::GetSelectedPlatform(), lldb_private::FileSpecList::GetSize(), lldb_private::FileSystem::Instance(), lldb_private::FileSpec::IsRelative(), lldb_private::ArchSpec::IsValid(), LLDB_SCOPED_TIMERF, PATH_MAX, lldb_private::TildeExpressionResolver::ResolveFullPath(), and lldb_private::FileSpec::SetDirectory().
|
staticprivate |
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.
[in] | target_sp | The shared pointer to a target. |
Definition at line 369 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
Referenced by CommandObjectTargetDelete::DoExecute(), and lldb_private::trace_intel_pt::TraceIntelPTBundleLoader::LoadBundle().
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.
[in] | exe_file_spec | A 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_ptr | If not nullptr then the architecture also needs to match, else the architectures will be compared. |
Definition at line 379 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
TargetSP TargetList::FindTargetWithProcess | ( | lldb_private::Process * | process | ) | const |
Definition at line 413 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
TargetSP TargetList::FindTargetWithProcessID | ( | lldb::pid_t | pid | ) | const |
Find the target that contains a process with process ID pid.
[in] | pid | The process ID to search our target list for. |
Definition at line 399 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
Referenced by SendAsyncInterrupt(), and SignalIfRunning().
|
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().
uint32_t TargetList::GetIndexOfTarget | ( | lldb::TargetSP | target_sp | ) | const |
Definition at line 505 of file TargetList.cpp.
References m_target_list, m_target_list_mutex, and UINT32_MAX.
Referenced by lldb_private::Process::HandleProcessStateChangedEvent().
int TargetList::GetNumTargets | ( | ) | const |
Definition at line 492 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
Referenced by CommandObjectTargetSelect::DoExecute(), CommandObjectTargetDelete::DoExecute(), DumpTargetList(), and lldb_private::CommandObjectQuit::ShouldAskForConfirmation().
lldb::TargetSP TargetList::GetSelectedTarget | ( | ) |
Definition at line 537 of file TargetList.cpp.
References GetTargetAtIndex(), m_selected_target_idx, m_target_list, and m_target_list_mutex.
Referenced by CommandObjectTargetDelete::DoExecute(), DumpTargetList(), lldb_private::Debugger::GetSelectedOrDummyTarget(), lldb_private::Debugger::GetSelectedTarget(), and lldb_private::Process::HandleProcessStateChangedEvent().
|
static |
Definition at line 32 of file TargetList.cpp.
Referenced by GetBroadcasterClass().
lldb::TargetSP TargetList::GetTargetAtIndex | ( | uint32_t | index | ) | const |
Definition at line 497 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
Referenced by CommandObjectTargetDelete::DoExecute(), DumpTargetList(), GetSelectedTarget(), and lldb_private::CommandObjectQuit::ShouldAskForConfirmation().
TargetSP TargetList::GetTargetSP | ( | Target * | target | ) | const |
Definition at line 430 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
|
privatedelete |
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.
[in] | pid | The process ID to search our target list for, if pid is LLDB_INVALID_PROCESS_ID, then the interrupt will be sent to all processes. |
Definition at line 444 of file TargetList.cpp.
References lldb_private::Broadcaster::BroadcastEvent(), lldb_private::Process::eBroadcastBitInterrupt, FindTargetWithProcessID(), LLDB_INVALID_PROCESS_ID, and lldb_private::Process::SendAsyncInterrupt().
void lldb_private::TargetList::SetSelectedTarget | ( | const lldb::TargetSP & | target | ) |
void TargetList::SetSelectedTarget | ( | uint32_t | index | ) |
Definition at line 526 of file TargetList.cpp.
References m_target_list_mutex, and SetSelectedTargetInternal().
Referenced by CommandObjectTargetSelect::DoExecute().
|
private |
Definition at line 521 of file TargetList.cpp.
References lldbassert, m_selected_target_idx, and m_target_list.
Referenced by AddTargetInternal(), and SetSelectedTarget().
uint32_t TargetList::SignalIfRunning | ( | lldb::pid_t | pid, |
int | signo | ||
) |
Definition at line 465 of file TargetList.cpp.
References FindTargetWithProcessID(), lldb_private::Process::IsAlive(), LLDB_INVALID_PROCESS_ID, m_target_list, m_target_list_mutex, and lldb_private::Process::Signal().
|
inline |
Definition at line 188 of file TargetList.h.
References m_target_list, and m_target_list_mutex.
Referenced by lldb_private::Debugger::Clear(), and lldb_private::DebuggerStats::ReportStatistics().
|
friend |
Definition at line 23 of file TargetList.h.
|
private |
Definition at line 195 of file TargetList.h.
Referenced by GetSelectedTarget(), and SetSelectedTargetInternal().
|
private |
Definition at line 193 of file TargetList.h.
Referenced by AddTargetInternal(), DeleteTarget(), FindTargetWithExecutableAndArchitecture(), FindTargetWithProcess(), FindTargetWithProcessID(), GetIndexOfTarget(), GetNumTargets(), GetSelectedTarget(), GetTargetAtIndex(), GetTargetSP(), SetSelectedTargetInternal(), SignalIfRunning(), and Targets().
|
mutableprivate |
Definition at line 194 of file TargetList.h.
Referenced by DeleteTarget(), FindTargetWithExecutableAndArchitecture(), FindTargetWithProcess(), FindTargetWithProcessID(), GetIndexOfTarget(), GetNumTargets(), GetSelectedTarget(), GetTargetAtIndex(), GetTargetSP(), SetSelectedTarget(), SignalIfRunning(), and Targets().