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
39 : Broadcaster(debugger.GetBroadcasterManager(),
40 TargetList::GetStaticBroadcasterClass().str()),
41 m_target_list(), m_target_list_mutex(), m_selected_target_idx(0) {
43}
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 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
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 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
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));
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.
135
136 lldb::offset_t file_offset = 0;
137 lldb::offset_t file_size = 0;
138 ModuleSpecList module_specs;
139 const size_t num_specs = ObjectFile::GetModuleSpecifications(
140 module_spec.GetFileSpec(), file_offset, file_size, module_specs);
141
142 if (num_specs > 0) {
143 ModuleSpec matching_module_spec;
144
145 if (num_specs == 1) {
146 if (module_specs.GetModuleSpecAtIndex(0, matching_module_spec)) {
147 if (platform_arch.IsValid()) {
148 if (platform_arch.IsCompatibleMatch(
149 matching_module_spec.GetArchitecture())) {
150 // If the OS or vendor weren't specified, then adopt the module's
151 // architecture so that the platform matching can be more
152 // accurate.
153 update_platform_arch(matching_module_spec.GetArchitecture());
154 } else {
155 StreamString platform_arch_strm;
156 StreamString module_arch_strm;
157
158 platform_arch.DumpTriple(platform_arch_strm.AsRawOstream());
159 matching_module_spec.GetArchitecture().DumpTriple(
160 module_arch_strm.AsRawOstream());
162 "the specified architecture '%s' is not compatible with '%s' "
163 "in '%s'",
164 platform_arch_strm.GetData(), module_arch_strm.GetData(),
165 module_spec.GetFileSpec().GetPath().c_str());
166 return error;
167 }
168 } else {
169 // Only one arch and none was specified.
170 prefer_platform_arch = true;
171 platform_arch = matching_module_spec.GetArchitecture();
172 }
173 }
174 } else if (arch.IsValid()) {
175 // Fat binary. A (valid) architecture was specified.
176 module_spec.GetArchitecture() = arch;
177 if (module_specs.FindMatchingModuleSpec(module_spec,
178 matching_module_spec))
179 update_platform_arch(matching_module_spec.GetArchitecture());
180 } else {
181 // Fat binary. No architecture specified, check if there is
182 // only one platform for all of the architectures.
183 std::vector<PlatformSP> candidates;
184 std::vector<ArchSpec> archs;
185 for (const ModuleSpec &spec : module_specs.ModuleSpecs())
186 archs.push_back(spec.GetArchitecture());
187 if (PlatformSP platform_for_archs_sp =
188 platform_list.GetOrCreate(archs, {}, candidates)) {
189 platform_sp = platform_for_archs_sp;
190 } else if (candidates.empty()) {
192 "no matching platforms found for this file");
193 return error;
194 } else {
195 // More than one platform claims to support this file.
196 StreamString error_strm;
197 std::set<llvm::StringRef> platform_set;
198 error_strm.Printf(
199 "more than one platform supports this executable (");
200 for (const auto &candidate : candidates) {
201 llvm::StringRef platform_name = candidate->GetName();
202 if (platform_set.count(platform_name))
203 continue;
204 if (!platform_set.empty())
205 error_strm.PutCString(", ");
206 error_strm.PutCString(platform_name);
207 platform_set.insert(platform_name);
208 }
209 error_strm.Printf("), specify an architecture to disambiguate");
210 error = Status(error_strm.GetString().str());
211 return error;
212 }
213 }
214 }
215 }
216
217 // If we have a valid architecture, make sure the current platform is
218 // compatible with that architecture.
219 if (!prefer_platform_arch && arch.IsValid()) {
220 if (!platform_sp->IsCompatibleArchitecture(
221 arch, {}, ArchSpec::CompatibleMatch, nullptr)) {
222 platform_sp = platform_list.GetOrCreate(arch, {}, &platform_arch);
223 if (platform_sp)
224 platform_list.SetSelectedPlatform(platform_sp);
225 }
226 } else if (platform_arch.IsValid()) {
227 // If "arch" isn't valid, yet "platform_arch" is, it means we have an
228 // executable file with a single architecture which should be used.
229 ArchSpec fixed_platform_arch;
230 if (!platform_sp->IsCompatibleArchitecture(
231 platform_arch, {}, ArchSpec::CompatibleMatch, nullptr)) {
232 platform_sp =
233 platform_list.GetOrCreate(platform_arch, {}, &fixed_platform_arch);
234 if (platform_sp)
235 platform_list.SetSelectedPlatform(platform_sp);
236 }
237 }
238
239 if (!platform_arch.IsValid())
240 platform_arch = arch;
241
242 return TargetList::CreateTargetInternal(debugger, user_exe_path,
243 platform_arch, load_dependent_files,
244 platform_sp, target_sp);
245}
246
248 llvm::StringRef user_exe_path,
249 const ArchSpec &specified_arch,
250 LoadDependentFiles load_dependent_files,
251 lldb::PlatformSP &platform_sp,
252 lldb::TargetSP &target_sp) {
253 LLDB_SCOPED_TIMERF("TargetList::CreateTarget (file = '%s', arch = '%s')",
254 user_exe_path.str().c_str(),
255 specified_arch.GetArchitectureName());
257 const bool is_dummy_target = false;
258
259 ArchSpec arch(specified_arch);
260
261 if (arch.IsValid()) {
262 if (!platform_sp || !platform_sp->IsCompatibleArchitecture(
263 arch, {}, ArchSpec::CompatibleMatch, nullptr))
264 platform_sp =
265 debugger.GetPlatformList().GetOrCreate(specified_arch, {}, &arch);
266 }
267
268 if (!platform_sp)
269 platform_sp = debugger.GetPlatformList().GetSelectedPlatform();
270
271 if (!arch.IsValid())
272 arch = specified_arch;
273
274 FileSpec file(user_exe_path);
275 if (!FileSystem::Instance().Exists(file) && user_exe_path.starts_with("~")) {
276 // we want to expand the tilde but we don't want to resolve any symbolic
277 // links so we can't use the FileSpec constructor's resolve flag
278 llvm::SmallString<64> unglobbed_path;
280 Resolver.ResolveFullPath(user_exe_path, unglobbed_path);
281
282 if (unglobbed_path.empty())
283 file = FileSpec(user_exe_path);
284 else
285 file = FileSpec(unglobbed_path.c_str());
286 }
287
288 bool user_exe_path_is_bundle = false;
289 char resolved_bundle_exe_path[PATH_MAX];
290 resolved_bundle_exe_path[0] = '\0';
291 if (file) {
292 if (FileSystem::Instance().IsDirectory(file))
293 user_exe_path_is_bundle = true;
294
295 if (file.IsRelative() && !user_exe_path.empty()) {
296 llvm::SmallString<64> cwd;
297 if (! llvm::sys::fs::current_path(cwd)) {
298 FileSpec cwd_file(cwd.c_str());
299 cwd_file.AppendPathComponent(file);
300 if (FileSystem::Instance().Exists(cwd_file))
301 file = cwd_file;
302 }
303 }
304
305 ModuleSP exe_module_sp;
306 if (platform_sp) {
307 FileSpecList executable_search_paths(
309 ModuleSpec module_spec(file, arch);
310 error = platform_sp->ResolveExecutable(module_spec, exe_module_sp,
311 executable_search_paths.GetSize()
312 ? &executable_search_paths
313 : nullptr);
314 }
315
316 if (error.Success() && exe_module_sp) {
317 if (exe_module_sp->GetObjectFile() == nullptr) {
318 if (arch.IsValid()) {
320 "\"%s\" doesn't contain architecture %s", file.GetPath().c_str(),
321 arch.GetArchitectureName());
322 } else {
324 "unsupported file type \"%s\"", file.GetPath().c_str());
325 }
326 return error;
327 }
328 target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
329 debugger.GetTargetList().RegisterInProcessTarget(target_sp);
330 target_sp->SetExecutableModule(exe_module_sp, load_dependent_files);
331 if (user_exe_path_is_bundle)
332 exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path,
333 sizeof(resolved_bundle_exe_path));
334 if (target_sp->GetPreloadSymbols())
335 exe_module_sp->PreloadSymbols();
336 }
337 } else {
338 // No file was specified, just create an empty target with any arch if a
339 // valid arch was specified
340 target_sp.reset(new Target(debugger, arch, platform_sp, is_dummy_target));
341 debugger.GetTargetList().RegisterInProcessTarget(target_sp);
342 }
343
344 if (!target_sp)
345 return error;
346
347 // Set argv0 with what the user typed, unless the user specified a
348 // directory. If the user specified a directory, then it is probably a
349 // bundle that was resolved and we need to use the resolved bundle path
350 if (!user_exe_path.empty()) {
351 // Use exactly what the user typed as the first argument when we exec or
352 // posix_spawn
353 if (user_exe_path_is_bundle && resolved_bundle_exe_path[0]) {
354 target_sp->SetArg0(resolved_bundle_exe_path);
355 } else {
356 // Use resolved path
357 target_sp->SetArg0(file.GetPath().c_str());
358 }
359 }
360 if (file.GetDirectory()) {
361 FileSpec file_dir;
362 file_dir.SetDirectory(file.GetDirectory());
363 target_sp->AppendExecutableSearchPaths(file_dir);
364 }
365
366 // Now prime this from the dummy target:
367 target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget());
368
369 return error;
370}
371
373 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
374 auto it = llvm::find(m_target_list, target_sp);
375 if (it == m_target_list.end())
376 return false;
377
378 m_target_list.erase(it);
379 return true;
380}
381
383 const FileSpec &exe_file_spec, const ArchSpec *exe_arch_ptr) const {
384 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
385 auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
386 [&exe_file_spec, exe_arch_ptr](const TargetSP &item) {
387 Module *exe_module = item->GetExecutableModulePointer();
388 if (!exe_module ||
389 !FileSpec::Match(exe_file_spec, exe_module->GetFileSpec()))
390 return false;
391
392 return !exe_arch_ptr ||
393 exe_arch_ptr->IsCompatibleMatch(exe_module->GetArchitecture());
394 });
395
396 if (it != m_target_list.end())
397 return *it;
398
399 return TargetSP();
400}
401
403 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
404 auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
405 [pid](const TargetSP &item) {
406 auto *process_ptr = item->GetProcessSP().get();
407 return process_ptr && (process_ptr->GetID() == pid);
408 });
409
410 if (it != m_target_list.end())
411 return *it;
412
413 return TargetSP();
414}
415
417 TargetSP target_sp;
418 if (!process)
419 return target_sp;
420
421 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
422 auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
423 [process](const TargetSP &item) {
424 return item->GetProcessSP().get() == process;
425 });
426
427 if (it != m_target_list.end())
428 target_sp = *it;
429
430 return target_sp;
431}
432
434 TargetSP target_sp;
435 if (!target)
436 return target_sp;
437
438 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
439 auto it = std::find_if(m_target_list.begin(), m_target_list.end(),
440 [target](const TargetSP &item) { return item.get() == target; });
441 if (it != m_target_list.end())
442 target_sp = *it;
443
444 return target_sp;
445}
446
448 uint32_t num_async_interrupts_sent = 0;
449
450 if (pid != LLDB_INVALID_PROCESS_ID) {
451 TargetSP target_sp(FindTargetWithProcessID(pid));
452 if (target_sp) {
453 Process *process = target_sp->GetProcessSP().get();
454 if (process) {
455 process->SendAsyncInterrupt();
456 ++num_async_interrupts_sent;
457 }
458 }
459 } else {
460 // We don't have a valid pid to broadcast to, so broadcast to the target
461 // list's async broadcaster...
463 }
464
465 return num_async_interrupts_sent;
466}
467
468uint32_t TargetList::SignalIfRunning(lldb::pid_t pid, int signo) {
469 uint32_t num_signals_sent = 0;
470 Process *process = nullptr;
471 if (pid == LLDB_INVALID_PROCESS_ID) {
472 // Signal all processes with signal
473 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
474 for (const auto &target_sp : m_target_list) {
475 process = target_sp->GetProcessSP().get();
476 if (process && process->IsAlive()) {
477 ++num_signals_sent;
478 process->Signal(signo);
479 }
480 }
481 } else {
482 // Signal a specific process with signal
483 TargetSP target_sp(FindTargetWithProcessID(pid));
484 if (target_sp) {
485 process = target_sp->GetProcessSP().get();
486 if (process && process->IsAlive()) {
487 ++num_signals_sent;
488 process->Signal(signo);
489 }
490 }
491 }
492 return num_signals_sent;
493}
494
496 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
497 return m_target_list.size();
498}
499
501 TargetSP target_sp;
502 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
503 if (idx < m_target_list.size())
504 target_sp = m_target_list[idx];
505 return target_sp;
506}
507
509 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
510 auto it = llvm::find(m_target_list, target_sp);
511 if (it != m_target_list.end())
512 return std::distance(m_target_list.begin(), it);
513 return UINT32_MAX;
514}
515
516void TargetList::AddTargetInternal(TargetSP target_sp, bool do_select) {
517 lldbassert(!llvm::is_contained(m_target_list, target_sp) &&
518 "target already exists it the list");
519 UnregisterInProcessTarget(target_sp);
520 m_target_list.push_back(std::move(target_sp));
521 if (do_select)
523}
524
526 lldbassert(!m_target_list.empty());
527 m_selected_target_idx = index < m_target_list.size() ? index : 0;
528}
529
530void TargetList::SetSelectedTarget(uint32_t index) {
531 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
533}
534
536 // Don't allow an invalid target shared pointer or a target that has been
537 // destroyed to become the selected target.
538 if (target_sp && target_sp->IsValid()) {
539 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
540 auto it = llvm::find(m_target_list, target_sp);
541 SetSelectedTargetInternal(std::distance(m_target_list.begin(), it));
542 }
543}
544
546 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
550}
551
553 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
554 for (const auto &target_sp : m_target_list) {
555 if (target_sp->GetImages().FindModule(&module))
556 return true;
557 }
558 for (const auto &target_sp: m_in_process_target_list) {
559 if (target_sp->GetImages().FindModule(&module))
560 return true;
561 }
562 return false;
563}
564
566 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
567 [[maybe_unused]] bool was_added;
568 std::tie(std::ignore, was_added) =
569 m_in_process_target_list.insert(target_sp);
570 assert(was_added && "Target pointer was left in the in-process map");
571 }
572
574 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
575 [[maybe_unused]] bool was_present =
576 m_in_process_target_list.erase(target_sp);
577 assert(was_present && "Target pointer being removed was not registered");
578 }
579
581 std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
582 return m_in_process_target_list.count(target_sp) == 1;
583 }
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition: LLDBAssert.h:15
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
An architecture specification class.
Definition: ArchSpec.h:31
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:359
void DumpTriple(llvm::raw_ostream &s) const
Definition: ArchSpec.cpp:1472
bool IsCompatibleMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, CompatibleMatch).
Definition: ArchSpec.h:513
bool TripleVendorWasSpecified() const
Definition: ArchSpec.h:364
bool TripleOSWasSpecified() const
Definition: ArchSpec.h:368
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:570
An event broadcasting class.
Definition: Broadcaster.h:146
void BroadcastEvent(lldb::EventSP &event_sp)
Broadcast an event which has no associated data.
Definition: Broadcaster.h:168
A class to manage flag bits.
Definition: Debugger.h:80
CommandInterpreter & GetCommandInterpreter()
Definition: Debugger.h:168
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:198
PlatformList & GetPlatformList()
Definition: Debugger.h:200
Target & GetDummyTarget()
Definition: Debugger.h:496
A file collection class.
Definition: FileSpecList.h:91
size_t GetSize() const
Get the number of files in the file list.
A file utility class.
Definition: FileSpec.h:56
void AppendPathComponent(llvm::StringRef component)
Definition: FileSpec.cpp:447
void SetDirectory(ConstString directory)
Directory string set accessor.
Definition: FileSpec.cpp:335
bool IsRelative() const
Returns true if the filespec represents a relative path.
Definition: FileSpec.cpp:507
const ConstString & GetDirectory() const
Directory string const get accessor.
Definition: FileSpec.h:223
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:367
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
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()
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:396
bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const
Definition: ModuleSpec.h:323
bool FindMatchingModuleSpec(const ModuleSpec &module_spec, ModuleSpec &match_module_spec) const
Definition: ModuleSpec.h:333
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:53
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:89
static size_t GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs, lldb::DataBufferSP data_sp=lldb::DataBufferSP())
Definition: ObjectFile.cpp:196
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:1100
void SetSelectedPlatform(const lldb::PlatformSP &platform_sp)
Definition: Platform.h:1108
lldb::PlatformSP GetOrCreate(llvm::StringRef name)
Definition: Platform.cpp:2107
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
void SendAsyncInterrupt(Thread *thread=nullptr)
Send an async interrupt request.
Definition: Process.cpp:3893
Status Signal(int signal)
Sends a process a UNIX signal signal.
Definition: Process.cpp:3591
virtual bool IsAlive()
Check if a process is still alive.
Definition: Process.cpp:1100
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
Definition: StreamString.h:45
llvm::StringRef GetString() const
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:401
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)
Definition: TargetList.cpp:525
static llvm::StringRef GetStaticBroadcasterClass()
Definition: TargetList.cpp:32
lldb::TargetSP FindTargetWithProcessID(lldb::pid_t pid) const
Find the target that contains a process with process ID pid.
Definition: TargetList.cpp:402
bool IsTargetInProcess(lldb::TargetSP target_sp)
Definition: TargetList.cpp:580
lldb::TargetSP GetTargetAtIndex(uint32_t index) const
Definition: TargetList.cpp:500
TargetList(Debugger &debugger)
Constructor.
Definition: TargetList.cpp:38
std::recursive_mutex m_target_list_mutex
Definition: TargetList.h:201
uint32_t GetIndexOfTarget(lldb::TargetSP target_sp) const
Definition: TargetList.cpp:508
lldb::TargetSP GetTargetSP(Target *target) const
Definition: TargetList.cpp:433
void UnregisterInProcessTarget(lldb::TargetSP target_sp)
Definition: TargetList.cpp:573
void SetSelectedTarget(uint32_t index)
Definition: TargetList.cpp:530
uint32_t SendAsyncInterrupt(lldb::pid_t pid=LLDB_INVALID_PROCESS_ID)
Send an async interrupt to one or all processes.
Definition: TargetList.cpp:447
bool DeleteTarget(lldb::TargetSP &target_sp)
Delete a Target object from the list.
Definition: TargetList.cpp:372
lldb::TargetSP FindTargetWithProcess(lldb_private::Process *process) const
Definition: TargetList.cpp:416
void RegisterInProcessTarget(lldb::TargetSP target_sp)
Definition: TargetList.cpp:565
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.
Definition: TargetList.cpp:45
lldb::TargetSP GetSelectedTarget()
Definition: TargetList.cpp:545
void AddTargetInternal(lldb::TargetSP target_sp, bool do_select)
Definition: TargetList.cpp:516
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)
Definition: TargetList.cpp:76
bool AnyTargetContainsModule(Module &module)
Returns whether any module, including ones in the process of being added, contains this module.
Definition: TargetList.cpp:552
size_t GetNumTargets() const
Definition: TargetList.cpp:495
uint32_t SignalIfRunning(lldb::pid_t pid, int signo)
Definition: TargetList.cpp:468
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...
Definition: TargetList.cpp:382
std::unordered_set< lldb::TargetSP > m_in_process_target_list
Definition: TargetList.h:200
uint32_t m_selected_target_idx
Definition: TargetList.h:202
static FileSpecList GetDefaultExecutableSearchPaths()
Definition: Target.cpp:2737
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
Definition: lldb-defines.h:19
#define LLDB_INVALID_PROCESS_ID
Definition: lldb-defines.h:89
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:388
uint64_t offset_t
Definition: lldb-types.h:85
uint64_t pid_t
Definition: lldb-types.h:83
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:448
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:373
#define PATH_MAX