LLDB mainline
PlatformAndroid.cpp
Go to the documentation of this file.
1//===-- PlatformAndroid.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
9#include "lldb/Core/Module.h"
11#include "lldb/Core/Section.h"
12#include "lldb/Host/HostInfo.h"
14#include "lldb/Utility/Log.h"
17
18#include "AdbClient.h"
19#include "PlatformAndroid.h"
21#include "lldb/Target/Target.h"
22#include <optional>
23
24using namespace lldb;
25using namespace lldb_private;
26using namespace lldb_private::platform_android;
27using namespace std::chrono;
28
30
31namespace {
32
33#define LLDB_PROPERTIES_android
34#include "PlatformAndroidProperties.inc"
35
36enum {
37#define LLDB_PROPERTIES_android
38#include "PlatformAndroidPropertiesEnum.inc"
39};
40
41class PluginProperties : public Properties {
42public:
43 PluginProperties() {
44 m_collection_sp = std::make_shared<OptionValueProperties>(
46 m_collection_sp->Initialize(g_android_properties);
47 }
48};
49
50static PluginProperties &GetGlobalProperties() {
51 static PluginProperties g_settings;
52 return g_settings;
53}
54
55uint32_t g_initialize_count = 0;
56const unsigned int g_android_default_cache_size =
57 2048; // Fits inside 4k adb packet.
58
59} // end of anonymous namespace
60
62 PlatformLinux::Initialize();
63
64 if (g_initialize_count++ == 0) {
65#if defined(__ANDROID__)
66 PlatformSP default_platform_sp(new PlatformAndroid(true));
67 default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
68 Platform::SetHostPlatform(default_platform_sp);
69#endif
74 }
75}
76
78 if (g_initialize_count > 0) {
79 if (--g_initialize_count == 0) {
81 }
82 }
83
84 PlatformLinux::Terminate();
85}
86
89 if (log) {
90 const char *arch_name;
91 if (arch && arch->GetArchitectureName())
92 arch_name = arch->GetArchitectureName();
93 else
94 arch_name = "<null>";
95
96 const char *triple_cstr =
97 arch ? arch->GetTriple().getTriple().c_str() : "<null>";
98
99 LLDB_LOGF(log, "PlatformAndroid::%s(force=%s, arch={%s,%s})", __FUNCTION__,
100 force ? "true" : "false", arch_name, triple_cstr);
101 }
102
103 bool create = force;
104 if (!create && arch && arch->IsValid()) {
105 const llvm::Triple &triple = arch->GetTriple();
106 switch (triple.getVendor()) {
107 case llvm::Triple::PC:
108 create = true;
109 break;
110
111#if defined(__ANDROID__)
112 // Only accept "unknown" for the vendor if the host is android and if
113 // "unknown" wasn't specified (it was just returned because it was NOT
114 // specified).
115 case llvm::Triple::VendorType::UnknownVendor:
116 create = !arch->TripleVendorWasSpecified();
117 break;
118#endif
119 default:
120 break;
121 }
122
123 if (create) {
124 switch (triple.getEnvironment()) {
125 case llvm::Triple::Android:
126 break;
127
128#if defined(__ANDROID__)
129 // Only accept "unknown" for the OS if the host is android and it
130 // "unknown" wasn't specified (it was just returned because it was NOT
131 // specified)
132 case llvm::Triple::EnvironmentType::UnknownEnvironment:
133 create = !arch->TripleEnvironmentWasSpecified();
134 break;
135#endif
136 default:
137 create = false;
138 break;
139 }
140 }
141 }
142
143 if (create) {
144 LLDB_LOGF(log, "PlatformAndroid::%s() creating remote-android platform",
145 __FUNCTION__);
146 return PlatformSP(new PlatformAndroid(false));
147 }
148
149 LLDB_LOGF(
150 log, "PlatformAndroid::%s() aborting creation of remote-android platform",
151 __FUNCTION__);
152
153 return PlatformSP();
154}
155
158 GetPluginNameStatic(false))) {
160 debugger, GetGlobalProperties().GetValueProperties(),
161 "Properties for the Android platform plugin.",
162 /*is_global_property=*/true);
163 }
164}
165
168
169llvm::StringRef PlatformAndroid::GetPluginDescriptionStatic(bool is_host) {
170 if (is_host)
171 return "Local Android user platform plug-in.";
172 return "Remote Android user platform plug-in.";
173}
174
176 m_device_id.clear();
177
178 if (IsHost())
180 "can't connect to the host platform, always connected");
181
184
185 const char *url = args.GetArgumentAtIndex(0);
186 if (!url)
187 return Status::FromErrorString("URL is null.");
188 std::optional<URI> parsed_url = URI::Parse(url);
189 if (!parsed_url)
190 return Status::FromErrorStringWithFormat("Invalid URL: %s", url);
191 if (parsed_url->hostname != "localhost")
192 m_device_id = parsed_url->hostname.str();
193
194 auto error = PlatformLinux::ConnectRemote(args);
195 if (error.Success()) {
196 auto resolved_device_id_or_error = AdbClient::ResolveDeviceID(m_device_id);
197 if (!resolved_device_id_or_error)
198 return Status::FromError(resolved_device_id_or_error.takeError());
199 m_device_id = *resolved_device_id_or_error;
200 }
201 return error;
202}
203
205 const FileSpec &destination) {
207 return PlatformLinux::GetFile(source, destination);
208
209 FileSpec source_spec(source.GetPath(false), FileSpec::Style::posix);
210 if (source_spec.IsRelative())
212 source_spec.GetPathAsConstString(false).GetStringRef());
213
215 auto sync_service = GetSyncService(error);
216
217 // If sync service is available, try to use it
218 if (error.Success() && sync_service) {
219 uint32_t mode = 0, size = 0, mtime = 0;
220 error = sync_service->Stat(source_spec, mode, size, mtime);
221 if (error.Success()) {
222 if (mode != 0)
223 return sync_service->PullFile(source_spec, destination);
224
225 // mode == 0 can signify that adbd cannot access the file due security
226 // constraints - fall through to try "cat ..." as a fallback.
228 LLDB_LOGF(log, "Got mode == 0 on '%s': try to get file via 'shell cat'",
229 source_spec.GetPath(false).c_str());
230 }
231 }
232
233 // Fallback to shell cat command if sync service failed or returned mode == 0
234 std::string source_file = source_spec.GetPath(false);
235
237 LLDB_LOGF(log, "Using shell cat fallback for '%s'", source_file.c_str());
238
239 if (strchr(source_file.c_str(), '\'') != nullptr)
241 "Doesn't support single-quotes in filenames");
242
244 if (error.Fail())
245 return error;
246
247 char cmd[PATH_MAX];
248 snprintf(cmd, sizeof(cmd), "%scat '%s'", GetRunAs().c_str(),
249 source_file.c_str());
250
251 return adb->ShellToFile(cmd, minutes(1), destination);
252}
253
255 const FileSpec &destination, uint32_t uid,
256 uint32_t gid) {
258 return PlatformLinux::PutFile(source, destination, uid, gid);
259
260 FileSpec destination_spec(destination.GetPath(false), FileSpec::Style::posix);
261 if (destination_spec.IsRelative())
263 destination_spec.GetPath(false));
264
265 // TODO: Set correct uid and gid on remote file.
267 auto sync_service = GetSyncService(error);
268 if (error.Fail())
269 return error;
270 return sync_service->PushFile(source, destination_spec);
271}
272
273const char *PlatformAndroid::GetCacheHostname() { return m_device_id.c_str(); }
274
276 const uint64_t src_offset,
277 const uint64_t src_size,
278 const FileSpec &dst_file_spec) {
279 std::string source_file = src_file_spec.GetPath(false);
280 if (source_file.empty())
281 return Status::FromErrorString("Source file path cannot be empty");
282
283 std::string destination_file = dst_file_spec.GetPath(false);
284 if (destination_file.empty())
285 return Status::FromErrorString("Destination file path cannot be empty");
286
287 // In Android API level 23 and above, dynamic loader is able to load .so
288 // file directly from APK. In that case, src_offset will be an non-zero.
289 if (src_offset == 0) // Use GetFile for a normal file.
290 return GetFile(src_file_spec, dst_file_spec);
291
292 if (source_file.find('\'') != std::string::npos)
294 "Doesn't support single-quotes in filenames");
295
296 // For zip .so file, src_file_spec will be "zip_path!/so_path".
297 // Extract "zip_path" from the source_file.
298 static constexpr llvm::StringLiteral k_zip_separator("!/");
299 size_t pos = source_file.find(k_zip_separator);
300 if (pos != std::string::npos)
301 source_file.resize(pos);
302
305 if (error.Fail())
306 return error;
307
308 // Use 'shell dd' to download the file slice with the offset and size.
309 char cmd[PATH_MAX];
310 snprintf(cmd, sizeof(cmd),
311 "%sdd if='%s' iflag=skip_bytes,count_bytes "
312 "skip=%" PRIu64 " count=%" PRIu64 " status=none",
313 GetRunAs().c_str(), source_file.c_str(), src_offset, src_size);
314
315 return adb->ShellToFile(cmd, minutes(1), dst_file_spec);
316}
317
319 Status error = PlatformLinux::DisconnectRemote();
320 if (error.Success()) {
321 m_device_id.clear();
322 m_sdk_version = 0;
323 }
324 return error;
325}
326
328 return g_android_default_cache_size;
329}
330
332 if (!IsConnected())
333 return 0;
334
335 if (m_sdk_version != 0)
336 return m_sdk_version;
337
338 std::string version_string;
341 if (error.Fail())
342 return 0;
343 error =
344 adb->Shell("getprop ro.build.version.sdk", seconds(5), &version_string);
345 version_string = llvm::StringRef(version_string).trim().str();
346
347 if (error.Fail() || version_string.empty()) {
349 LLDB_LOGF(log, "Get SDK version failed. (error: %s, output: %s)",
350 error.AsCString(), version_string.c_str());
351 return 0;
352 }
353
354 // FIXME: improve error handling
355 llvm::to_integer(version_string, m_sdk_version);
356 return m_sdk_version;
357}
358
360 const FileSpec &dst_file_spec) {
361 // For oat file we can try to fetch additional debug info from the device
362 llvm::StringRef extension = module_sp->GetFileSpec().GetFileNameExtension();
363 if (extension != ".oat" && extension != ".odex")
365 "Symbol file downloading only supported for oat and odex files");
366
367 // If we have no information about the platform file we can't execute oatdump
368 if (!module_sp->GetPlatformFileSpec())
369 return Status::FromErrorString("No platform file specified");
370
371 // Symbolizer isn't available before SDK version 23
372 if (GetSdkVersion() < 23)
374 "Symbol file generation only supported on SDK 23+");
375
376 // If we already have symtab then we don't have to try and generate one
377 if (module_sp->GetSectionList()->FindSectionByName(ConstString(".symtab")) !=
378 nullptr)
379 return Status::FromErrorString("Symtab already available in the module");
380
383 if (error.Fail())
384 return error;
385 std::string tmpdir;
386 error = adb->Shell("mktemp --directory --tmpdir /data/local/tmp", seconds(5),
387 &tmpdir);
388 if (error.Fail() || tmpdir.empty())
390 "Failed to generate temporary directory on the device (%s)",
391 error.AsCString());
392 tmpdir = llvm::StringRef(tmpdir).trim().str();
393
394 // Create file remover for the temporary directory created on the device
395 std::unique_ptr<std::string, std::function<void(std::string *)>>
396 tmpdir_remover(&tmpdir, [&adb](std::string *s) {
397 StreamString command;
398 command.Printf("rm -rf %s", s->c_str());
399 Status error = adb->Shell(command.GetData(), seconds(5), nullptr);
400
402 if (log && error.Fail())
403 LLDB_LOGF(log, "Failed to remove temp directory: %s",
404 error.AsCString());
405 });
406
407 FileSpec symfile_platform_filespec(tmpdir);
408 symfile_platform_filespec.AppendPathComponent("symbolized.oat");
409
410 // Execute oatdump on the remote device to generate a file with symtab
411 StreamString command;
412 command.Printf("oatdump --symbolize=%s --output=%s",
413 module_sp->GetPlatformFileSpec().GetPath(false).c_str(),
414 symfile_platform_filespec.GetPath(false).c_str());
415 error = adb->Shell(command.GetData(), minutes(1), nullptr);
416 if (error.Fail())
417 return Status::FromErrorStringWithFormat("Oatdump failed: %s",
418 error.AsCString());
419
420 // Download the symbolfile from the remote device
421 return GetFile(symfile_platform_filespec, dst_file_spec);
422}
423
425 m_os_version = llvm::VersionTuple(GetSdkVersion());
426 return !m_os_version.empty();
427}
428
429llvm::StringRef
431 SymbolContextList matching_symbols;
432 std::vector<const char *> dl_open_names = {"__dl_dlopen", "dlopen"};
433 const char *dl_open_name = nullptr;
434 Target &target = process->GetTarget();
435 for (auto *name : dl_open_names) {
437 ConstString(name), eFunctionNameTypeFull, matching_symbols);
438 if (matching_symbols.GetSize()) {
439 dl_open_name = name;
440 break;
441 }
442 }
443 // Older platform versions have the dl function symbols mangled
444 if (dl_open_name == dl_open_names[0])
445 return R"(
446 extern "C" void* dlopen(const char*, int) asm("__dl_dlopen");
447 extern "C" void* dlsym(void*, const char*) asm("__dl_dlsym");
448 extern "C" int dlclose(void*) asm("__dl_dlclose");
449 extern "C" char* dlerror(void) asm("__dl_dlerror");
450 )";
451
453}
454
456 AdbClientUP adb = std::make_unique<AdbClient>(m_device_id);
457 error = adb->Connect();
458 return adb;
459}
460
462 return GetGlobalProperties().GetPropertyAtIndexAs<llvm::StringRef>(
463 ePropertyPlatformPackageName, "");
464}
465
466std::string PlatformAndroid::GetRunAs() {
467 llvm::StringRef run_as = GetPropertyPackageName();
468 if (!run_as.empty()) {
469 // When LLDB fails to pull file from a package directory due to security
470 // constraint, user needs to set the package name to
471 // 'platform.plugin.remote-android.package-name' property in order to run
472 // shell commands as the package user using 'run-as' (e.g. to get file with
473 // 'cat' and 'dd').
474 // https://cs.android.com/android/platform/superproject/+/master:
475 // system/core/run-as/run-as.cpp;l=39-61;
476 // drc=4a77a84a55522a3b122f9c63ef0d0b8a6a131627
477 return std::string("run-as '") + run_as.str() + "' ";
478 }
479 return run_as.str();
480}
481
482// Helper function to populate process status information from
483// /proc/[pid]/status
485 lldb::pid_t pid, ProcessInstanceInfo &process_info) {
486 // Read /proc/[pid]/status to get parent PID, UIDs, and GIDs
488 AdbClientUP status_adb = GetAdbClient(error);
489 if (error.Fail())
490 return;
491
492 std::string status_output;
493 StreamString status_cmd;
494 status_cmd.Printf(
495 "cat /proc/%llu/status 2>/dev/null | grep -E '^(PPid|Uid|Gid):'",
496 static_cast<unsigned long long>(pid));
497 Status status_error =
498 status_adb->Shell(status_cmd.GetData(), seconds(5), &status_output);
499
500 if (status_error.Fail() || status_output.empty())
501 return;
502
503 llvm::SmallVector<llvm::StringRef, 16> lines;
504 llvm::StringRef(status_output).split(lines, '\n');
505
506 for (llvm::StringRef line : lines) {
507 line = line.trim();
508 if (line.starts_with("PPid:")) {
509 llvm::StringRef ppid_str = line.substr(5).trim();
510 lldb::pid_t ppid;
511 if (llvm::to_integer(ppid_str, ppid))
512 process_info.SetParentProcessID(ppid);
513 } else if (line.starts_with("Uid:")) {
514 llvm::SmallVector<llvm::StringRef, 4> uid_parts;
515 line.substr(4).trim().split(uid_parts, '\t', -1, false);
516 if (uid_parts.size() >= 2) {
517 uint32_t uid, euid;
518 if (llvm::to_integer(uid_parts[0].trim(), uid))
519 process_info.SetUserID(uid);
520 if (llvm::to_integer(uid_parts[1].trim(), euid))
521 process_info.SetEffectiveUserID(euid);
522 }
523 } else if (line.starts_with("Gid:")) {
524 llvm::SmallVector<llvm::StringRef, 4> gid_parts;
525 line.substr(4).trim().split(gid_parts, '\t', -1, false);
526 if (gid_parts.size() >= 2) {
527 uint32_t gid, egid;
528 if (llvm::to_integer(gid_parts[0].trim(), gid))
529 process_info.SetGroupID(gid);
530 if (llvm::to_integer(gid_parts[1].trim(), egid))
531 process_info.SetEffectiveGroupID(egid);
532 }
534 }
535}
536
537// Helper function to populate command line arguments from /proc/[pid]/cmdline
539 lldb::pid_t pid, ProcessInstanceInfo &process_info) {
540 // Read /proc/[pid]/cmdline to get command line arguments
542 AdbClientUP cmdline_adb = GetAdbClient(error);
543 if (error.Fail())
544 return;
545
546 std::string cmdline_output;
547 StreamString cmdline_cmd;
548 cmdline_cmd.Printf("cat /proc/%llu/cmdline 2>/dev/null | tr '\\000' ' '",
549 static_cast<unsigned long long>(pid));
550 Status cmdline_error =
551 cmdline_adb->Shell(cmdline_cmd.GetData(), seconds(5), &cmdline_output);
552
553 if (cmdline_error.Fail() || cmdline_output.empty())
554 return;
555
556 cmdline_output = llvm::StringRef(cmdline_output).trim().str();
557 if (cmdline_output.empty())
558 return;
559
560 llvm::SmallVector<llvm::StringRef, 16> args;
561 llvm::StringRef(cmdline_output).split(args, ' ', -1, false);
562 if (args.empty())
563 return;
564
565 process_info.SetArg0(args[0]);
566 Args process_args;
567 for (size_t i = 1; i < args.size(); i++) {
568 if (!args[i].empty())
569 process_args.AppendArgument(args[i]);
571 process_info.SetArguments(process_args, false);
572}
573
574// Helper function to populate architecture from /proc/[pid]/exe
576 lldb::pid_t pid, ProcessInstanceInfo &process_info) {
577 // Read /proc/[pid]/exe to get executable path for architecture detection
579 AdbClientUP exe_adb = GetAdbClient(error);
580 if (error.Fail())
581 return;
582
583 std::string exe_output;
584 StreamString exe_cmd;
585 exe_cmd.Printf("readlink /proc/%llu/exe 2>/dev/null",
586 static_cast<unsigned long long>(pid));
587 Status exe_error = exe_adb->Shell(exe_cmd.GetData(), seconds(5), &exe_output);
588
589 if (exe_error.Fail() || exe_output.empty())
590 return;
591
592 exe_output = llvm::StringRef(exe_output).trim().str();
593
594 // Determine architecture from exe path
595 ArchSpec arch;
596 if (exe_output.find("64") != std::string::npos ||
597 exe_output.find("arm64") != std::string::npos ||
598 exe_output.find("aarch64") != std::string::npos) {
599 arch.SetTriple("aarch64-unknown-linux-android");
600 } else if (exe_output.find("x86_64") != std::string::npos) {
601 arch.SetTriple("x86_64-unknown-linux-android");
602 } else if (exe_output.find("x86") != std::string::npos ||
603 exe_output.find("i686") != std::string::npos) {
604 arch.SetTriple("i686-unknown-linux-android");
605 } else {
606 // Default to armv7 for 32-bit ARM (most common on Android)
607 arch.SetTriple("armv7-unknown-linux-android");
608 }
609
610 if (arch.IsValid())
611 process_info.SetArchitecture(arch);
612}
613
614uint32_t
616 ProcessInstanceInfoList &proc_infos) {
617 proc_infos.clear();
618
619 // When LLDB is running natively on an Android device (IsHost() == true),
620 // use the parent class's standard Linux /proc enumeration. IsHost() is only
621 // true when compiled for Android (#if defined(__ANDROID__)), so calling
622 // PlatformLinux methods is safe (Android is Linux-based).
623 if (IsHost())
624 return PlatformLinux::FindProcesses(match_info, proc_infos);
625
626 // Remote Android platform: implement process name lookup using 'pidof' over
627 // adb.
628
629 // LLDB stores the search name in GetExecutableFile() (even though it's
630 // actually a process name like "com.android.chrome" rather than an
631 // executable path). If no search name is provided, we can't use
632 // 'pidof', so return early with no results.
633 const ProcessInstanceInfo &match_process_info = match_info.GetProcessInfo();
634 if (!match_process_info.GetExecutableFile() ||
635 match_info.GetNameMatchType() == NameMatch::Ignore) {
636 return 0;
637 }
638
639 // Extract the process name to search for (typically an Android package name
640 // like "com.example.app" or binary name like "app_process64")
641 std::string process_name = match_process_info.GetExecutableFile().GetPath();
642 if (process_name.empty())
643 return 0;
644
645 // Use adb to find the process by name
648 if (error.Fail()) {
650 LLDB_LOGF(log, "PlatformAndroid::%s failed to get ADB client: %s",
651 __FUNCTION__, error.AsCString());
652 return 0;
653 }
654
655 // Use 'pidof' command to get PIDs for the process name.
656 // Quote the process name to handle special characters (spaces, etc.)
657 std::string pidof_output;
658 StreamString command;
659 command.Printf("pidof '%s'", process_name.c_str());
660 error = adb->Shell(command.GetData(), seconds(5), &pidof_output);
661
662 if (error.Fail()) {
664 LLDB_LOG(log, "PlatformAndroid::{} 'pidof {}' failed: {}", __FUNCTION__,
665 process_name.c_str(), error.AsCString());
666 return 0;
667 }
668
669 // Parse PIDs from pidof output.
670 // Note: pidof can return multiple PIDs (space-separated) if multiple
671 // instances of the same executable are running.
672 pidof_output = llvm::StringRef(pidof_output).trim().str();
673 if (pidof_output.empty()) {
674 Log *log = GetLog(LLDBLog::Platform);
675 LLDB_LOGF(log, "PlatformAndroid::%s no process found with name '%s'",
676 __FUNCTION__, process_name.c_str());
677 return 0;
678 }
679
680 // Split the output by whitespace to handle multiple PIDs
681 llvm::SmallVector<llvm::StringRef, 8> pid_strings;
682 llvm::StringRef(pidof_output).split(pid_strings, ' ', -1, false);
683
684 Log *log = GetLog(LLDBLog::Platform);
685
686 // Process each PID and gather information
687 uint32_t num_matches = 0;
688 for (llvm::StringRef pid_str : pid_strings) {
689 pid_str = pid_str.trim();
690 if (pid_str.empty())
691 continue;
692
693 lldb::pid_t pid;
694 if (!llvm::to_integer(pid_str, pid)) {
695 LLDB_LOGF(log, "PlatformAndroid::%s failed to parse PID from: '%s'",
696 __FUNCTION__, pid_str.str().c_str());
697 continue;
698 }
699
700 ProcessInstanceInfo process_info;
701 process_info.SetProcessID(pid);
702 process_info.GetExecutableFile().SetFile(process_name,
703 FileSpec::Style::posix);
704
705 // Populate additional process information
706 PopulateProcessStatusInfo(pid, process_info);
707 PopulateProcessCommandLine(pid, process_info);
708 PopulateProcessArchitecture(pid, process_info);
709
710 // Check if this process matches the criteria
711 if (match_info.Matches(process_info)) {
712 proc_infos.push_back(process_info);
713 num_matches++;
714
715 LLDB_LOGF(log, "PlatformAndroid::%s found process '%s' with PID %llu",
716 __FUNCTION__, process_name.c_str(),
717 static_cast<unsigned long long>(pid));
718 }
720
721 return num_matches;
722}
723
724std::unique_ptr<AdbSyncService> PlatformAndroid::GetSyncService(Status &error) {
725 auto sync_service = std::make_unique<AdbSyncService>(m_device_id);
726 error = sync_service->SetupSyncConnection();
727 if (error.Fail())
728 return nullptr;
729 return sync_service;
730}
static llvm::raw_ostream & error(Stream &strm)
static DynamicLoaderDarwinKernelProperties & GetGlobalProperties()
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:369
#define LLDB_LOGF(log,...)
Definition Log.h:376
static uint32_t g_initialize_count
#define LLDB_PLUGIN_DEFINE(PluginName)
virtual llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process)
An architecture specification class.
Definition ArchSpec.h:31
bool IsValid() const
Tests if this ArchSpec is valid.
Definition ArchSpec.h:366
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition ArchSpec.h:468
bool TripleEnvironmentWasSpecified() const
Definition ArchSpec.h:377
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition ArchSpec.cpp:741
bool TripleVendorWasSpecified() const
Definition ArchSpec.h:371
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition ArchSpec.cpp:548
A command line argument class.
Definition Args.h:33
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
Definition Args.cpp:332
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition Args.cpp:273
A uniqued constant string class.
Definition ConstString.h:40
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
A class to manage flag bits.
Definition Debugger.h:80
A file utility class.
Definition FileSpec.h:57
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition FileSpec.cpp:174
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
Definition FileSpec.cpp:425
bool IsRelative() const
Returns true if the filespec represents a relative path.
Definition FileSpec.cpp:514
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
ConstString GetPathAsConstString(bool denormalize=true) const
Get the full path as a ConstString.
Definition FileSpec.cpp:390
void FindFunctionSymbols(ConstString name, lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list)
llvm::VersionTuple m_os_version
Definition Platform.h:1008
static void SetHostPlatform(const lldb::PlatformSP &platform_sp)
Definition Platform.cpp:145
bool IsHost() const
Definition Platform.h:503
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static lldb::OptionValuePropertiesSP GetSettingForPlatformPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool CreateSettingForPlatformPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static bool UnregisterPlugin(ABICreateInstance create_callback)
void SetGroupID(uint32_t gid)
Definition ProcessInfo.h:60
void SetArchitecture(const ArchSpec &arch)
Definition ProcessInfo.h:66
void SetArg0(llvm::StringRef arg)
void SetArguments(const Args &args, bool first_arg_is_executable)
void SetProcessID(lldb::pid_t pid)
Definition ProcessInfo.h:70
FileSpec & GetExecutableFile()
Definition ProcessInfo.h:43
void SetUserID(uint32_t uid)
Definition ProcessInfo.h:58
bool Matches(const ProcessInstanceInfo &proc_info) const
ProcessInstanceInfo & GetProcessInfo()
void SetEffectiveGroupID(uint32_t gid)
void SetParentProcessID(lldb::pid_t pid)
void SetEffectiveUserID(uint32_t uid)
A plug-in interface definition class for debugging a process.
Definition Process.h:354
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1267
T GetPropertyAtIndexAs(uint32_t idx, T default_value, const ExecutionContext *exe_ctx=nullptr) const
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
bool Fail() const
Test for error condition.
Definition Status.cpp:294
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:137
const char * GetData() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1025
static llvm::Expected< std::string > ResolveDeviceID(llvm::StringRef device_id)
Resolves a device identifier to its canonical form.
virtual std::unique_ptr< AdbSyncService > GetSyncService(Status &error)
Status GetFile(const FileSpec &source, const FileSpec &destination) override
static llvm::StringRef GetPluginDescriptionStatic(bool is_host)
void PopulateProcessArchitecture(lldb::pid_t pid, ProcessInstanceInfo &process_info)
virtual AdbClientUP GetAdbClient(Status &error)
void PopulateProcessCommandLine(lldb::pid_t pid, ProcessInstanceInfo &process_info)
static llvm::StringRef GetPluginNameStatic(bool is_host)
Status PutFile(const FileSpec &source, const FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
Status DownloadSymbolFile(const lldb::ModuleSP &module_sp, const FileSpec &dst_file_spec) override
void PopulateProcessStatusInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info)
static void DebuggerInitialize(lldb_private::Debugger &debugger)
llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process) override
uint32_t GetDefaultMemoryCacheLineSize() override
Allow the platform to set preferred memory cache line size.
uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos) override
Attach to an existing process by process name.
Status DownloadModuleSlice(const FileSpec &src_file_spec, const uint64_t src_offset, const uint64_t src_size, const FileSpec &dst_file_spec) override
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
PlatformLinux(bool is_host)
Default Constructor.
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
std::vector< ProcessInstanceInfo > ProcessInstanceInfoList
Definition Host.h:32
std::shared_ptr< lldb_private::Platform > PlatformSP
uint64_t pid_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::Module > ModuleSP
static std::optional< URI > Parse(llvm::StringRef uri)
Definition UriParser.cpp:28
#define PATH_MAX