LLDB mainline
TargetList.cpp
Go to the documentation of this file.
1//===-- TargetList.cpp ----------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Debugger.h"
11#include "lldb/Core/Module.h"
13#include "lldb/Host/Host.h"
14#include "lldb/Host/HostInfo.h"
19#include "lldb/Target/Process.h"
21#include "lldb/Utility/Event.h"
22#include "lldb/Utility/State.h"
24#include "lldb/Utility/Timer.h"
25
26#include "llvm/ADT/SmallString.h"
27#include "llvm/Support/FileSystem.h"
28
29using namespace lldb;
30using namespace lldb_private;
31
33 static constexpr llvm::StringLiteral class_name("lldb.targetList");
34 return class_name;
35}
36
37// TargetList constructor
44
46 llvm::StringRef user_exe_path,
47 llvm::StringRef triple_str,
48 LoadDependentFiles load_dependent_files,
49 const OptionGroupPlatform *platform_options,
50 TargetSP &target_sp) {
51
53 debugger, user_exe_path, triple_str, load_dependent_files,
54 platform_options, target_sp);
55
56 if (target_sp && result.Success())
57 AddTargetInternal(target_sp, /*do_select*/ true);
58 return result;
59}
60
62 llvm::StringRef user_exe_path,
63 const ArchSpec &specified_arch,
64 LoadDependentFiles load_dependent_files,
65 PlatformSP &platform_sp, TargetSP &target_sp) {
66
68 debugger, user_exe_path, specified_arch, load_dependent_files,
69 platform_sp, target_sp);
70
71 if (target_sp && result.Success())
72 AddTargetInternal(target_sp, /*do_select*/ true);
73 return result;
74}
75
77 Debugger &debugger, llvm::StringRef user_exe_path,
78 llvm::StringRef triple_str, LoadDependentFiles load_dependent_files,
79 const OptionGroupPlatform *platform_options, TargetSP &target_sp) {
81
82 PlatformList &platform_list = debugger.GetPlatformList();
83 // Let's start by looking at the selected platform.
84 PlatformSP platform_sp = platform_list.GetSelectedPlatform();
85
86 // This variable corresponds to the architecture specified by the triple
87 // string. If that string was empty the currently selected platform will
88 // determine the architecture.
89 const ArchSpec arch(triple_str);
90 if (!triple_str.empty() && !arch.IsValid()) {
91 error = Status::FromErrorStringWithFormat("invalid triple '%s'",
92 triple_str.str().c_str());
93 return error;
94 }
95
96 ArchSpec platform_arch(arch);
97
98 // Create a new platform if a platform was specified in the platform options
99 // and doesn't match the selected platform.
100 if (platform_options && platform_options->PlatformWasSpecified() &&
101 !platform_options->PlatformMatches(platform_sp)) {
102 const bool select_platform = true;
103 platform_sp = platform_options->CreatePlatformWithOptions(
104 debugger.GetCommandInterpreter(), arch, select_platform, error,
105 platform_arch);
106 if (!platform_sp)
107 return error;
108 }
109
110 bool prefer_platform_arch = false;
111 auto update_platform_arch = [&](const ArchSpec &module_arch) {
112 // If the OS or vendor weren't specified, then adopt the module's
113 // architecture so that the platform matching can be more accurate.
114 if (!platform_arch.TripleOSWasSpecified() ||
115 !platform_arch.TripleVendorWasSpecified()) {
116 prefer_platform_arch = true;
117 platform_arch = module_arch;
118 }
119 };
120
121 if (!user_exe_path.empty()) {
122 ModuleSpec module_spec(FileSpec(user_exe_path, FileSpec::Style::native));
123 FileSystem::Instance().Resolve(module_spec.GetFileSpec());
124
125 // Try to resolve the exe based on PATH and/or platform-specific suffixes,
126 // but only if using the host platform.
127 if (platform_sp->IsHost() &&
128 !FileSystem::Instance().Exists(module_spec.GetFileSpec()))
130 module_spec.GetFileSpec());
131
132 // Resolve the executable in case we are given a path to a application
133 // bundle like a .app bundle on MacOSX.
134 Host::ResolveExecutableInBundle(module_spec.GetFileSpec());
135
136 lldb::offset_t file_offset = 0;
137 lldb::offset_t file_size = 0;
138 ModuleSpecList module_specs = ObjectFile::GetModuleSpecifications(
139 module_spec.GetFileSpec(), file_offset, file_size);
140
141 if (module_specs.GetSize() > 0) {
142 ModuleSpec matching_module_spec;
143
144 if (module_specs.GetSize() == 1) {
145 if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec)) {
146 if (platform_arch.IsValid()) {
147 if (platform_arch.IsCompatibleMatch(
148 matching_module_spec.GetArchitecture())) {
149 // If the OS or vendor weren't specified, then adopt the module's
150 // architecture so that the platform matching can be more
151 // accurate.
152 update_platform_arch(matching_module_spec.GetArchitecture());
153 } else {
154 StreamString platform_arch_strm;
155 StreamString module_arch_strm;
156
157 platform_arch.DumpTriple(platform_arch_strm.AsRawOstream());
158 matching_module_spec.GetArchitecture().DumpTriple(
159 module_arch_strm.AsRawOstream());
161 "the specified architecture '%s' is not compatible with '%s' "
162 "in '%s'",
163 platform_arch_strm.GetData(), module_arch_strm.GetData(),
164 module_spec.GetFileSpec().GetPath().c_str());
165 return error;
166 }
167 } else {
168 // Only one arch and none was specified.
169 prefer_platform_arch = true;
170 platform_arch = matching_module_spec.GetArchitecture();
171 }
172 }
173 } else if (arch.IsValid()) {
174 // Fat binary. A (valid) architecture was specified.
175 module_spec.GetArchitecture() = arch;
176 if (module_specs.FindMatchingModuleSpec(module_spec,
177 matching_module_spec))
178 update_platform_arch(matching_module_spec.GetArchitecture());
179 } else {
180 // Fat binary. No architecture specified, check if there is
181 // only one platform for all of the architectures.
182 std::vector<PlatformSP> candidates;
183 std::vector<ArchSpec> archs;
184 for (const ModuleSpec &spec : module_specs.ModuleSpecs())
185 archs.push_back(spec.GetArchitecture());
186 if (PlatformSP platform_for_archs_sp =
187 platform_list.GetOrCreate(archs, {}, candidates)) {
188 platform_sp = platform_for_archs_sp;
189 } else if (candidates.empty()) {
191 "no matching platforms found for this file");
192 return error;
193 } else {
194 // More than one platform claims to support this file.
195 StreamString error_strm;
196 std::set<llvm::StringRef> platform_set;
197 error_strm.Printf(
198 "more than one platform supports this executable (");
199 for (const auto &candidate : candidates) {
200 llvm::StringRef platform_name = candidate->GetName();
201 if (platform_set.count(platform_name))
202 continue;
203 if (!platform_set.empty())
204 error_strm.PutCString(", ");
205 error_strm.PutCString(platform_name);
206 platform_set.insert(platform_name);
207 }
208 error_strm.Printf("), specify an architecture to disambiguate");
209 error = Status(error_strm.GetString().str());
210 return error;
211 }
212 }
213 }
214 }
215
216 // If we have a valid architecture, make sure the current platform is
217 // compatible with that architecture.
218 if (!prefer_platform_arch && arch.IsValid()) {
219 if (!platform_sp->IsCompatibleArchitecture(
220 arch, {}, ArchSpec::CompatibleMatch, nullptr)) {
221 platform_sp = platform_list.GetOrCreate(arch, {}, &platform_arch);
222 if (platform_sp)
223 platform_list.SetSelectedPlatform(platform_sp);
224 }
225 } else if (platform_arch.IsValid()) {
226 // If "arch" isn't valid, yet "platform_arch" is, it means we have an
227 // executable file with a single architecture which should be used.
228 ArchSpec fixed_platform_arch;
229 if (!platform_sp->IsCompatibleArchitecture(
230 platform_arch, {}, ArchSpec::CompatibleMatch, nullptr)) {
231 platform_sp =
232 platform_list.GetOrCreate(platform_arch, {}, &fixed_platform_arch);
233 if (platform_sp)
234 platform_list.SetSelectedPlatform(platform_sp);
235 }
236 }
237
238 if (!platform_arch.IsValid())
239 platform_arch = arch;
240
241 return TargetList::CreateTargetInternal(debugger, user_exe_path,
242 platform_arch, load_dependent_files,
243 platform_sp, target_sp);
244}
245
247 llvm::StringRef user_exe_path,
248 const ArchSpec &specified_arch,
249 LoadDependentFiles load_dependent_files,
250 lldb::PlatformSP &platform_sp,
251 lldb::TargetSP &target_sp) {
252 LLDB_SCOPED_TIMERF("TargetList::CreateTarget (file = '%s', arch = '%s')",
253 user_exe_path.str().c_str(),
254 specified_arch.GetArchitectureName());
256 const bool is_dummy_target = false;
257
258 ArchSpec arch(specified_arch);
259
260 if (arch.IsValid()) {
261 if (!platform_sp || !platform_sp->IsCompatibleArchitecture(
262 arch, {}, ArchSpec::CompatibleMatch, nullptr))
263 platform_sp =
264 debugger.GetPlatformList().GetOrCreate(specified_arch, {}, &arch);
265 }
266
267 if (!platform_sp)
268 platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
269
270 if (!arch.IsValid())
271 arch = specified_arch;
272
273 FileSpec file(user_exe_path);
274 if (!FileSystem::Instance().Exists(file) && user_exe_path.starts_with("~")) {
275 // we want to expand the tilde but we don't want to resolve any symbolic
276 // links so we can't use the FileSpec constructor's resolve flag
277 llvm::SmallString<64> unglobbed_path;
278 StandardTildeExpressionResolver Resolver;
279 Resolver.ResolveFullPath(user_exe_path, unglobbed_path);
280
281 if (unglobbed_path.empty())
282 file = FileSpec(user_exe_path);
283 else
284 file = FileSpec(unglobbed_path.c_str());
285 }
286
287 bool user_exe_path_is_bundle = false;
288 char resolved_bundle_exe_path[PATH_MAX];
289 resolved_bundle_exe_path[0] = '\0';
290 if (file) {
291 if (FileSystem::Instance().IsDirectory(file))
292 user_exe_path_is_bundle = true;
293
294 if (file.IsRelative() && !user_exe_path.empty()) {
295 llvm::SmallString<64> cwd;
296 if (! llvm::sys::fs::current_path(cwd)) {
297 FileSpec cwd_file(cwd.c_str());
298 cwd_file.AppendPathComponent(file);
299 if (FileSystem::Instance().Exists(cwd_file))
300 file = cwd_file;
301 }
302 }
303
304 ModuleSP exe_module_sp;
305 if (platform_sp) {
306 ModuleSpec module_spec(file, arch);
307 module_spec.SetTarget(target_sp);
308 // Set the platform so that GetSharedModule can use it for the locate
309 // module callback, even when Target is not yet available (during target
310 // creation for launch mode).
311 module_spec.SetPlatform(platform_sp);
312 error = platform_sp->ResolveExecutable(module_spec, exe_module_sp);
313 }
314
315 if (error.Success() && exe_module_sp) {
316 if (exe_module_sp->GetObjectFile() == nullptr) {
317 if (arch.IsValid()) {
319 "\"%s\" doesn't contain architecture %s", file.GetPath().c_str(),
320 arch.GetArchitectureName());
321 } else {
323 "unsupported file type \"%s\"", file.GetPath().c_str());
324 }
325 return error;
326 }
327 target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
328 debugger.GetTargetList().RegisterInProcessTarget(target_sp);
329 target_sp->SetExecutableModule(exe_module_sp, load_dependent_files);
330 if (user_exe_path_is_bundle)
331 exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path,
332 sizeof(resolved_bundle_exe_path));
333 if (target_sp->GetPreloadSymbols())
334 exe_module_sp->PreloadSymbols();
335 }
336 } else {
337 // No file was specified, just create an empty target with any arch if a
338 // valid arch was specified
339 target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
340 debugger.GetTargetList().RegisterInProcessTarget(target_sp);
341 }
342
343 if (!target_sp)
344 return error;
345
346 // Set argv0 with what the user typed, unless the user specified a
347 // directory. If the user specified a directory, then it is probably a
348 // bundle that was resolved and we need to use the resolved bundle path
349 if (!user_exe_path.empty()) {
350 // Use exactly what the user typed as the first argument when we exec or
351 // posix_spawn
352 if (user_exe_path_is_bundle && resolved_bundle_exe_path[0]) {
353 target_sp->SetArg0(resolved_bundle_exe_path);
354 } else {
355 // Use resolved path
356 target_sp->SetArg0(file.GetPath().c_str());
357 }
358 }
359 if (file.GetDirectory()) {
360 FileSpec file_dir;
361 file_dir.SetDirectory(file.GetDirectory());
362 target_sp->AppendExecutableSearchPaths(file_dir);
363 }
364
365 // Now prime this from the dummy target:
366 target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget());
367
368 return error;
369}
370
372 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
373 auto it = llvm::find(m_target_list, target_sp);
374 if (it == m_target_list.end())
375 return false;
376
377 m_target_list.erase(it);
378 return true;
379}
380
382 const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr) const {
383 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
384 auto it = llvm::find_if(
385 m_target_list, [&exe_file_spec, exe_arch_ptr](const TargetSP &item) {
386 Module *exe_module = item->GetExecutableModulePointer();
387 if (!exe_module ||
388 !FileSpec::Match(exe_file_spec, exe_module->GetFileSpec()))
389 return false;
390
391 return !exe_arch_ptr ||
392 exe_arch_ptr->IsCompatibleMatch(exe_module->GetArchitecture());
393 });
394
395 if (it != m_target_list.end())
396 return *it;
397
398 return TargetSP();
399}
400
402 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
403 auto it = llvm::find_if(m_target_list, [pid](const TargetSP &item) {
404 auto *process_ptr = item->GetProcessSP().get();
405 return process_ptr && (process_ptr->GetID() == pid);
406 });
407
408 if (it != m_target_list.end())
409 return *it;
410
411 return TargetSP();
412}
413
415 TargetSP target_sp;
416 if (!process)
417 return target_sp;
418
419 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
420 auto it = llvm::find_if(m_target_list, [process](const TargetSP &item) {
421 return item->GetProcessSP().get() == process;
422 });
423
424 if (it != m_target_list.end())
425 target_sp = *it;
426
427 return target_sp;
428}
429
431 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
432 auto it = llvm::find_if(m_target_list, [id](const TargetSP &item) {
433 return item->GetGloballyUniqueID() == id;
434 });
435
436 if (it != m_target_list.end())
437 return *it;
438
439 return TargetSP();
440}
441
443 TargetSP target_sp;
444 if (!target)
445 return target_sp;
446
447 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
448 auto it = llvm::find_if(m_target_list, [target](const TargetSP &item) {
449 return item.get() == target;
450 });
451 if (it != m_target_list.end())
452 target_sp = *it;
453
454 return target_sp;
455}
456
458 uint32_t num_async_interrupts_sent = 0;
459
460 if (pid != LLDB_INVALID_PROCESS_ID) {
461 TargetSP target_sp(FindTargetWithProcessID(pid));
462 if (target_sp) {
463 Process *process = target_sp->GetProcessSP().get();
464 if (process) {
465 process->SendAsyncInterrupt();
466 ++num_async_interrupts_sent;
467 }
468 }
469 } else {
470 // We don't have a valid pid to broadcast to, so broadcast to the target
471 // list's async broadcaster...
473 }
474
475 return num_async_interrupts_sent;
476}
477
478uint32_t TargetList::SignalIfRunning(lldb::pid_t pid, int signo) {
479 uint32_t num_signals_sent = 0;
480 Process *process = nullptr;
481 if (pid == LLDB_INVALID_PROCESS_ID) {
482 // Signal all processes with signal
483 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
484 for (const auto &target_sp : m_target_list) {
485 process = target_sp->GetProcessSP().get();
486 if (process && process->IsAlive()) {
487 ++num_signals_sent;
488 process->Signal(signo);
489 }
490 }
491 } else {
492 // Signal a specific process with signal
493 TargetSP target_sp(FindTargetWithProcessID(pid));
494 if (target_sp) {
495 process = target_sp->GetProcessSP().get();
496 if (process && process->IsAlive()) {
497 ++num_signals_sent;
498 process->Signal(signo);
499 }
500 }
501 }
502 return num_signals_sent;
503}
504
506 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
507 return m_target_list.size();
508}
509
511 TargetSP target_sp;
512 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
513 if (idx < m_target_list.size())
514 target_sp = m_target_list[idx];
515 return target_sp;
516}
517
519 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
520 auto it = llvm::find(m_target_list, target_sp);
521 if (it != m_target_list.end())
522 return std::distance(m_target_list.begin(), it);
523 return UINT32_MAX;
524}
525
526void TargetList::AddTargetInternal(TargetSP target_sp, bool do_select) {
527 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
528 lldbassert(!llvm::is_contained(m_target_list, target_sp) &&
529 "target already exists it the list");
530 UnregisterInProcessTarget(target_sp);
531 m_target_list.push_back(std::move(target_sp));
532 if (do_select)
534}
535
537 lldbassert(!m_target_list.empty());
538 m_selected_target_idx = index < m_target_list.size() ? index : 0;
539}
540
541void TargetList::SetSelectedTarget(uint32_t index) {
542 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
544}
545
546void TargetList::SetSelectedTarget(const TargetSP &target_sp) {
547 // Don't allow an invalid target shared pointer or a target that has been
548 // destroyed to become the selected target.
549 if (target_sp && target_sp->IsValid()) {
550 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
551 auto it = llvm::find(m_target_list, target_sp);
552 SetSelectedTargetInternal(std::distance(m_target_list.begin(), it));
553 }
554}
555
557 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
561}
562
564 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
565 for (const auto &target_sp : m_target_list) {
566 if (target_sp->GetImages().FindModule(&module))
567 return true;
568 }
569 for (const auto &target_sp: m_in_process_target_list) {
570 if (target_sp->GetImages().FindModule(&module))
571 return true;
572 }
573 return false;
574}
575
577 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
578 [[maybe_unused]] bool was_added;
579 std::tie(std::ignore, was_added) =
580 m_in_process_target_list.insert(target_sp);
581 assert(was_added && "Target pointer was left in the in-process map");
582 }
583
585 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
586 [[maybe_unused]] bool was_present =
587 m_in_process_target_list.erase(target_sp);
588 assert(was_present && "Target pointer being removed was not registered");
589 }
590
592 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
593 return m_in_process_target_list.count(target_sp) == 1;
594 }
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition LLDBAssert.h:16
#define LLDB_SCOPED_TIMERF(...)
Definition Timer.h:86
An architecture specification class.
Definition ArchSpec.h:32
void DumpTriple(llvm::raw_ostream &s) const
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
Definition ArchSpec.h:509
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:548
Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name)
Construct with a broadcaster with a name.
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
A class to manage flag bits.
Definition Debugger.h:101
CommandInterpreter & GetCommandInterpreter()
Definition Debugger.h:189
TargetList & GetTargetList()
Get accessor for the target list.
Definition Debugger.h:227
PlatformList & GetPlatformList()
Definition Debugger.h:229
Target & GetDummyTarget()
Definition Debugger.h:536
A file utility class.
Definition FileSpec.h:57
void SetDirectory(ConstString directory)
Directory string set accessor.
Definition FileSpec.cpp:342
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition FileSpec.cpp:301
bool ResolveExecutableLocation(FileSpec &file_spec)
Call into the Host to see if it can help find the file.
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static bool ResolveExecutableInBundle(FileSpec &file)
When executable files may live within a directory, where the directory represents an executable bundl...
ModuleSpecIterable ModuleSpecs()
Definition ModuleSpec.h:428
bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
Definition ModuleSpec.h:356
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
Definition ModuleSpec.h:366
ArchSpec & GetArchitecture()
Definition ModuleSpec.h:93
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:90
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition Module.cpp:1026
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition Module.h:446
static ModuleSpecList GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataExtractorSP=lldb::DataExtractorSP())
bool PlatformMatches(const lldb::PlatformSP &platform_sp) const
lldb::PlatformSP CreatePlatformWithOptions(CommandInterpreter &interpreter, const ArchSpec &arch, bool make_selected, Status &error, ArchSpec &platform_arch) const
lldb::PlatformSP GetSelectedPlatform()
Select the active platform.
Definition Platform.h:1137
void SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
Definition Platform.h:1145
lldb::PlatformSP GetOrCreate(llvm::StringRef name)
A plug-in interface definition class for debugging a process.
Definition Process.h:354
void SendAsyncInterrupt(Thread *thread=nullptr)
Send an async interrupt request.
Definition Process.cpp:4022
Status Signal(int signal)
Sends a process a UNIX signal signal.
Definition Process.cpp:3696
virtual bool IsAlive()
Check if a process is still alive.
Definition Process.cpp:1076
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
const char * GetData() const
llvm::StringRef GetString() const
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:418
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
void SetSelectedTargetInternal(uint32_t index)
static llvm::StringRef GetStaticBroadcasterClass()
lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid) const
Find the target that contains a process with process ID pid.
bool IsTargetInProcess(lldb::TargetSP target_sp)
lldb::TargetSP GetTargetAtIndex(uint32_t index) const
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.
TargetList(Debugger &debugger)
Constructor.
std::recursive_mutex m_target_list_mutex
Definition TargetList.h:211
uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const
lldb::TargetSP GetTargetSP(Target *target) const
void UnregisterInProcessTarget(lldb::TargetSP target_sp)
void SetSelectedTarget(uint32_t index)
uint32_t SendAsyncInterrupt(lldb::pid_t pid=LLDB_INVALID_PROCESS_ID)
Send an async interrupt to one or all processes.
bool DeleteTarget(lldb::TargetSP &target_sp)
Delete a Target object from the list.
lldb::TargetSP FindTargetWithProcess(lldb_private::Process *process) const
void RegisterInProcessTarget(lldb::TargetSP target_sp)
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)
lldb::TargetSP GetSelectedTarget()
void AddTargetInternal(lldb::TargetSP target_sp, bool do_select)
lldb::TargetSP FindTargetByGloballyUniqueID(lldb::user_id_t id) const
Find the target that has a globally unique ID that matches ID id.
bool AnyTargetContainsModule(Module &module)
Returns whether any module, including ones in the process of being added, contains this module.
size_t GetNumTargets() const
uint32_t SignalIfRunning(lldb::pid_t pid, int signo)
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 architect...
std::unordered_set< lldb::TargetSP > m_in_process_target_list
Definition TargetList.h:210
bool ResolveFullPath(llvm::StringRef Expr, llvm::SmallVectorImpl< char > &Output)
Resolve an entire path that begins with a tilde expression, replacing the username portion with the m...
#define UINT32_MAX
#define LLDB_INVALID_PROCESS_ID
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Platform > PlatformSP
uint64_t offset_t
Definition lldb-types.h:85
uint64_t pid_t
Definition lldb-types.h:83
uint64_t user_id_t
Definition lldb-types.h:82
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
#define PATH_MAX