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