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 | |
llvm::StringRef | 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. | |
size_t | 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 () |
bool | AnyTargetContainsModule (Module &module) |
Returns whether any module, including ones in the process of being added, contains this module. | |
TargetIterable | Targets () |
Public Member Functions inherited from lldb_private::Broadcaster | |
Broadcaster (lldb::BroadcasterManagerSP manager_sp, std::string 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) |
void | BroadcastEventIfUnique (uint32_t event_type) |
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. | |
const std::string & | GetBroadcasterName () |
Get this broadcaster's name. | |
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 llvm::StringRef | 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 () |
void | SetPrimaryListener (lldb::ListenerSP listener_sp) |
lldb::ListenerSP | GetPrimaryListener () |
Static Public Member Functions | |
static llvm::StringRef | GetStaticBroadcasterClass () |
Private Member Functions | |
TargetList (Debugger &debugger) | |
Constructor. | |
void | RegisterInProcessTarget (lldb::TargetSP target_sp) |
void | UnregisterInProcessTarget (lldb::TargetSP target_sp) |
bool | IsTargetInProcess (lldb::TargetSP target_sp) |
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::unordered_set< lldb::TargetSP > | m_in_process_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< BroadcasterImpl > | BroadcasterImplSP |
typedef std::weak_ptr< BroadcasterImpl > | BroadcasterImplWP |
Protected Member Functions inherited from lldb_private::Broadcaster | |
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 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 515 of file TargetList.cpp.
References lldbassert, m_target_list, SetSelectedTargetInternal(), and UnregisterInProcessTarget().
Referenced by CreateTarget().
bool TargetList::AnyTargetContainsModule | ( | Module & | module | ) |
Returns whether any module, including ones in the process of being added, contains this module.
I don't want to give direct access to these not yet added target, but for interruption purposes, we might need to ask whether this target contains this module.
Definition at line 551 of file TargetList.cpp.
References m_in_process_target_list, m_target_list, and m_target_list_mutex.
Status 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
Definition at line 61 of file TargetList.cpp.
References AddTargetInternal(), CreateTargetInternal(), and m_target_list_mutex.
Status 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. |
Definition at line 45 of file TargetList.cpp.
References AddTargetInternal(), CreateTargetInternal(), and m_target_list_mutex.
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::Debugger::GetTargetList(), lldb_private::FileSystem::Instance(), lldb_private::FileSpec::IsRelative(), lldb_private::ArchSpec::IsValid(), LLDB_SCOPED_TIMERF, PATH_MAX, RegisterInProcessTarget(), lldb_private::TildeExpressionResolver::ResolveFullPath(), and lldb_private::FileSpec::SetDirectory().
|
staticprivate |
Definition at line 76 of file TargetList.cpp.
References lldb_private::Stream::AsRawOstream(), lldb_private::ArchSpec::CompatibleMatch, lldb_private::OptionGroupPlatform::CreatePlatformWithOptions(), CreateTargetInternal(), lldb_private::ArchSpec::DumpTriple(), error(), lldb_private::FileSystem::Exists(), lldb_private::ModuleSpecList::FindMatchingModuleSpec(), lldb_private::ModuleSpec::GetArchitecture(), lldb_private::Debugger::GetCommandInterpreter(), lldb_private::StreamString::GetData(), lldb_private::ModuleSpec::GetFileSpec(), lldb_private::ModuleSpecList::GetModuleSpecAtIndex(), lldb_private::ObjectFile::GetModuleSpecifications(), lldb_private::PlatformList::GetOrCreate(), lldb_private::FileSpec::GetPath(), lldb_private::Debugger::GetPlatformList(), lldb_private::PlatformList::GetSelectedPlatform(), lldb_private::StreamString::GetString(), lldb_private::FileSystem::Instance(), lldb_private::ArchSpec::IsCompatibleMatch(), lldb_private::ArchSpec::IsValid(), lldb_private::ModuleSpecList::ModuleSpecs(), lldb_private::OptionGroupPlatform::PlatformMatches(), lldb_private::OptionGroupPlatform::PlatformWasSpecified(), lldb_private::Stream::Printf(), lldb_private::Stream::PutCString(), lldb_private::FileSystem::Resolve(), lldb_private::Host::ResolveExecutableInBundle(), lldb_private::FileSystem::ResolveExecutableLocation(), lldb_private::PlatformList::SetSelectedPlatform(), lldb_private::ArchSpec::TripleOSWasSpecified(), and lldb_private::ArchSpec::TripleVendorWasSpecified().
Referenced by CreateTarget(), and CreateTargetInternal().
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 371 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 381 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
TargetSP TargetList::FindTargetWithProcess | ( | lldb_private::Process * | process | ) | const |
Definition at line 415 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 401 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 507 of file TargetList.cpp.
References m_target_list, m_target_list_mutex, and UINT32_MAX.
Referenced by lldb_private::Process::HandleProcessStateChangedEvent().
size_t TargetList::GetNumTargets | ( | ) | const |
Definition at line 494 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
Referenced by CommandObjectTargetSelect::DoExecute(), CommandObjectTargetDelete::DoExecute(), DumpTargetList(), lldb_private::Target::SetLabel(), and lldb_private::CommandObjectQuit::ShouldAskForConfirmation().
lldb::TargetSP TargetList::GetSelectedTarget | ( | ) |
Definition at line 544 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 499 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
Referenced by CommandObjectTargetSelect::DoExecute(), CommandObjectTargetDelete::DoExecute(), DumpTargetList(), GetSelectedTarget(), lldb_private::Target::SetLabel(), and lldb_private::CommandObjectQuit::ShouldAskForConfirmation().
Definition at line 432 of file TargetList.cpp.
References m_target_list, and m_target_list_mutex.
|
private |
Definition at line 579 of file TargetList.cpp.
References m_in_process_target_list, and m_target_list_mutex.
|
privatedelete |
|
private |
Definition at line 564 of file TargetList.cpp.
References m_in_process_target_list, and m_target_list_mutex.
Referenced by CreateTargetInternal().
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 446 of file TargetList.cpp.
References lldb_private::Broadcaster::BroadcastEvent(), lldb_private::Process::eBroadcastBitInterrupt, FindTargetWithProcessID(), LLDB_INVALID_PROCESS_ID, and lldb_private::Process::SendAsyncInterrupt().
void TargetList::SetSelectedTarget | ( | const lldb::TargetSP & | target | ) |
Definition at line 534 of file TargetList.cpp.
References m_target_list, m_target_list_mutex, and SetSelectedTargetInternal().
void TargetList::SetSelectedTarget | ( | uint32_t | index | ) |
Definition at line 529 of file TargetList.cpp.
References m_target_list_mutex, and SetSelectedTargetInternal().
Referenced by CommandObjectTargetSelect::DoExecute().
|
private |
Definition at line 524 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 467 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 194 of file TargetList.h.
References m_target_list, and m_target_list_mutex.
Referenced by lldb_private::Debugger::Clear(), and lldb_private::DebuggerStats::ReportStatistics().
|
private |
Definition at line 572 of file TargetList.cpp.
References m_in_process_target_list, and m_target_list_mutex.
Referenced by AddTargetInternal().
|
friend |
Definition at line 23 of file TargetList.h.
|
private |
Definition at line 200 of file TargetList.h.
Referenced by AnyTargetContainsModule(), IsTargetInProcess(), RegisterInProcessTarget(), and UnregisterInProcessTarget().
|
private |
Definition at line 202 of file TargetList.h.
Referenced by GetSelectedTarget(), and SetSelectedTargetInternal().
|
private |
Definition at line 199 of file TargetList.h.
Referenced by AddTargetInternal(), AnyTargetContainsModule(), DeleteTarget(), FindTargetWithExecutableAndArchitecture(), FindTargetWithProcess(), FindTargetWithProcessID(), GetIndexOfTarget(), GetNumTargets(), GetSelectedTarget(), GetTargetAtIndex(), GetTargetSP(), SetSelectedTarget(), SetSelectedTargetInternal(), SignalIfRunning(), and Targets().
|
mutableprivate |
Definition at line 201 of file TargetList.h.
Referenced by AnyTargetContainsModule(), CreateTarget(), DeleteTarget(), FindTargetWithExecutableAndArchitecture(), FindTargetWithProcess(), FindTargetWithProcessID(), GetIndexOfTarget(), GetNumTargets(), GetSelectedTarget(), GetTargetAtIndex(), GetTargetSP(), IsTargetInProcess(), RegisterInProcessTarget(), SetSelectedTarget(), SignalIfRunning(), Targets(), and UnregisterInProcessTarget().