LLDB mainline
PlatformPOSIX.cpp
Go to the documentation of this file.
1//===-- PlatformPOSIX.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 "PlatformPOSIX.h"
10
13#include "lldb/Core/Debugger.h"
14#include "lldb/Core/Module.h"
19#include "lldb/Host/File.h"
22#include "lldb/Host/Host.h"
23#include "lldb/Host/HostInfo.h"
27#include "lldb/Target/Process.h"
28#include "lldb/Target/Thread.h"
32#include "lldb/Utility/Log.h"
35#include "llvm/ADT/ScopeExit.h"
36#include <optional>
37
38using namespace lldb;
39using namespace lldb_private;
40
41/// Default Constructor
43 : RemoteAwarePlatform(is_host), // This is the local host platform
44 m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
45 m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
46 m_option_group_platform_caching(new OptionGroupPlatformCaching()) {}
47
48/// Destructor.
49///
50/// The destructor is virtual since this class is designed to be
51/// inherited from by the plug-in instance.
53
56 auto iter = m_options.find(&interpreter), end = m_options.end();
57 if (iter == end) {
58 std::unique_ptr<lldb_private::OptionGroupOptions> options(
59 new OptionGroupOptions());
60 options->Append(m_option_group_platform_rsync.get());
61 options->Append(m_option_group_platform_ssh.get());
62 options->Append(m_option_group_platform_caching.get());
63 m_options[&interpreter] = std::move(options);
64 }
65
66 return m_options.at(&interpreter).get();
67}
68
69static uint32_t chown_file(Platform *platform, const char *path,
70 uint32_t uid = UINT32_MAX,
71 uint32_t gid = UINT32_MAX) {
72 if (!platform || !path || *path == 0)
73 return UINT32_MAX;
74
75 if (uid == UINT32_MAX && gid == UINT32_MAX)
76 return 0; // pretend I did chown correctly - actually I just didn't care
77
78 StreamString command;
79 command.PutCString("chown ");
80 if (uid != UINT32_MAX)
81 command.Printf("%d", uid);
82 if (gid != UINT32_MAX)
83 command.Printf(":%d", gid);
84 command.Printf("%s", path);
85 int status;
86 platform->RunShellCommand(command.GetData(), FileSpec(), &status, nullptr,
87 nullptr, std::chrono::seconds(10));
88 return status;
89}
90
93 const lldb_private::FileSpec &destination, uint32_t uid,
94 uint32_t gid) {
95 Log *log = GetLog(LLDBLog::Platform);
96
97 if (IsHost()) {
98 if (source == destination)
99 return Status();
100 // cp src dst
101 // chown uid:gid dst
102 std::string src_path(source.GetPath());
103 if (src_path.empty())
104 return Status::FromErrorString("unable to get file path for source");
105 std::string dst_path(destination.GetPath());
106 if (dst_path.empty())
107 return Status::FromErrorString("unable to get file path for destination");
108 StreamString command;
109 command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
110 int status;
111 RunShellCommand(command.GetData(), FileSpec(), &status, nullptr, nullptr,
112 std::chrono::seconds(10));
113 if (status != 0)
114 return Status::FromErrorString("unable to perform copy");
115 if (uid == UINT32_MAX && gid == UINT32_MAX)
116 return Status();
117 if (chown_file(this, dst_path.c_str(), uid, gid) != 0)
118 return Status::FromErrorString("unable to perform chown");
119 return Status();
120 } else if (m_remote_platform_sp) {
121 if (GetSupportsRSync()) {
122 std::string src_path(source.GetPath());
123 if (src_path.empty())
124 return Status::FromErrorString("unable to get file path for source");
125 std::string dst_path(destination.GetPath());
126 if (dst_path.empty())
128 "unable to get file path for destination");
129 StreamString command;
131 if (!GetRSyncPrefix())
132 command.Printf("rsync %s %s %s", GetRSyncOpts(), src_path.c_str(),
133 dst_path.c_str());
134 else
135 command.Printf("rsync %s %s %s%s", GetRSyncOpts(), src_path.c_str(),
136 GetRSyncPrefix(), dst_path.c_str());
137 } else
138 command.Printf("rsync %s %s %s:%s", GetRSyncOpts(), src_path.c_str(),
139 GetHostname(), dst_path.c_str());
140 LLDB_LOGF(log, "[PutFile] Running command: %s\n", command.GetData());
141 int retcode;
142 Host::RunShellCommand(command.GetData(), FileSpec(), &retcode, nullptr,
143 nullptr, std::chrono::minutes(1));
144 if (retcode == 0) {
145 // Don't chown a local file for a remote system
146 // if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
147 // return Status::FromErrorString("unable to perform
148 // chown");
149 return Status();
150 }
151 // if we are still here rsync has failed - let's try the slow way before
152 // giving up
153 }
154 }
155 return Platform::PutFile(source, destination, uid, gid);
156}
157
159 const lldb_private::FileSpec &source, // remote file path
160 const lldb_private::FileSpec &destination) // local file path
161{
162 Log *log = GetLog(LLDBLog::Platform);
163
164 // Check the args, first.
165 std::string src_path(source.GetPath());
166 if (src_path.empty())
167 return Status::FromErrorString("unable to get file path for source");
168 std::string dst_path(destination.GetPath());
169 if (dst_path.empty())
170 return Status::FromErrorString("unable to get file path for destination");
171 if (IsHost()) {
172 if (source == destination)
174 "local scenario->source and destination are the same file "
175 "path: no operation performed");
176 // cp src dst
177 StreamString cp_command;
178 cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
179 int status;
180 RunShellCommand(cp_command.GetData(), FileSpec(), &status, nullptr, nullptr,
181 std::chrono::seconds(10));
182 if (status != 0)
183 return Status::FromErrorString("unable to perform copy");
184 return Status();
185 } else if (m_remote_platform_sp) {
186 if (GetSupportsRSync()) {
187 StreamString command;
189 if (!GetRSyncPrefix())
190 command.Printf("rsync %s %s %s", GetRSyncOpts(), src_path.c_str(),
191 dst_path.c_str());
192 else
193 command.Printf("rsync %s %s%s %s", GetRSyncOpts(), GetRSyncPrefix(),
194 src_path.c_str(), dst_path.c_str());
195 } else
196 command.Printf("rsync %s %s:%s %s", GetRSyncOpts(),
197 m_remote_platform_sp->GetHostname(), src_path.c_str(),
198 dst_path.c_str());
199 LLDB_LOGF(log, "[GetFile] Running command: %s\n", command.GetData());
200 int retcode;
201 Host::RunShellCommand(command.GetData(), FileSpec(), &retcode, nullptr,
202 nullptr, std::chrono::minutes(1));
203 if (retcode == 0)
204 return Status();
205 // If we are here, rsync has failed - let's try the slow way before
206 // giving up
207 }
208 // open src and dst
209 // read/write, read/write, read/write, ...
210 // close src
211 // close dst
212 LLDB_LOGF(log, "[GetFile] Using block by block transfer....\n");
215 lldb::eFilePermissionsFileDefault, error);
216
217 if (fd_src == UINT64_MAX)
218 return Status::FromErrorString("unable to open source file");
219
220 uint32_t permissions = 0;
221 error = GetFilePermissions(source, permissions);
222
223 if (permissions == 0)
224 permissions = lldb::eFilePermissionsFileDefault;
225
229 permissions, error);
230
231 if (fd_dst == UINT64_MAX) {
232 if (error.Success())
233 error = Status::FromErrorString("unable to open destination file");
234 }
235
236 if (error.Success()) {
237 lldb::WritableDataBufferSP buffer_sp(new DataBufferHeap(1024, 0));
238 uint64_t offset = 0;
239 error.Clear();
240 while (error.Success()) {
241 const uint64_t n_read = ReadFile(fd_src, offset, buffer_sp->GetBytes(),
242 buffer_sp->GetByteSize(), error);
243 if (error.Fail())
244 break;
245 if (n_read == 0)
246 break;
247 if (FileCache::GetInstance().WriteFile(fd_dst, offset,
248 buffer_sp->GetBytes(), n_read,
249 error) != n_read) {
250 if (!error.Fail())
251 error =
252 Status::FromErrorString("unable to write to destination file");
253 break;
254 }
255 offset += n_read;
256 }
257 }
258 // Ignore the close error of src.
259 if (fd_src != UINT64_MAX)
260 CloseFile(fd_src, error);
261 // And close the dst file descriptot.
262 if (fd_dst != UINT64_MAX &&
264 if (!error.Fail())
265 error = Status::FromErrorString("unable to close destination file");
266 }
267 return error;
268 }
269 return Platform::GetFile(source, destination);
270}
271
273 StreamString stream;
274 if (GetSupportsRSync()) {
275 stream.PutCString("rsync");
276 if ((GetRSyncOpts() && *GetRSyncOpts()) ||
278 stream.Printf(", options: ");
279 if (GetRSyncOpts() && *GetRSyncOpts())
280 stream.Printf("'%s' ", GetRSyncOpts());
281 stream.Printf(", prefix: ");
282 if (GetRSyncPrefix() && *GetRSyncPrefix())
283 stream.Printf("'%s' ", GetRSyncPrefix());
285 stream.Printf("ignore remote-hostname ");
286 }
287 }
288 if (GetSupportsSSH()) {
289 stream.PutCString("ssh");
290 if (GetSSHOpts() && *GetSSHOpts())
291 stream.Printf(", options: '%s' ", GetSSHOpts());
292 }
294 stream.Printf("cache dir: %s", GetLocalCacheDirectory());
295 if (stream.GetSize())
296 return std::string(stream.GetString());
297 else
298 return "";
299}
300
303 return m_remote_platform_sp->GetRemoteUnixSignals();
305}
306
309 if (IsHost()) {
311 "can't connect to the host platform '{0}', always connected",
312 GetPluginName());
313 } else {
317 /*force=*/true, nullptr);
318
319 if (m_remote_platform_sp && error.Success())
320 error = m_remote_platform_sp->ConnectRemote(args);
321 else
323 "failed to create a 'remote-gdb-server' platform");
324
325 if (error.Fail())
326 m_remote_platform_sp.reset();
327 }
328
329 if (error.Success() && m_remote_platform_sp) {
333 if (m_option_group_platform_rsync->m_rsync) {
334 SetSupportsRSync(true);
335 SetRSyncOpts(m_option_group_platform_rsync->m_rsync_opts.c_str());
336 SetRSyncPrefix(m_option_group_platform_rsync->m_rsync_prefix.c_str());
338 m_option_group_platform_rsync->m_ignores_remote_hostname);
339 }
340 if (m_option_group_platform_ssh->m_ssh) {
341 SetSupportsSSH(true);
342 SetSSHOpts(m_option_group_platform_ssh->m_ssh_opts.c_str());
343 }
345 m_option_group_platform_caching->m_cache_dir.c_str());
346 }
347 }
348
349 return error;
350}
351
354
355 if (IsHost()) {
357 "can't disconnect from the host platform '{0}', always connected",
358 GetPluginName());
359 } else {
361 error = m_remote_platform_sp->DisconnectRemote();
362 else
363 error =
364 Status::FromErrorString("the platform is not currently connected");
365 }
366 return error;
367}
368
370 Debugger &debugger, Target *target,
371 Status &error) {
372 lldb::ProcessSP process_sp;
373 Log *log = GetLog(LLDBLog::Platform);
374
375 if (IsHost()) {
376 if (target == nullptr) {
377 TargetSP new_target_sp;
378
379 error = debugger.GetTargetList().CreateTarget(
380 debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
381 target = new_target_sp.get();
382 LLDB_LOGF(log, "PlatformPOSIX::%s created new target", __FUNCTION__);
383 } else {
384 error.Clear();
385 LLDB_LOGF(log, "PlatformPOSIX::%s target already existed, setting target",
386 __FUNCTION__);
387 }
388
389 if (target && error.Success()) {
390 if (log) {
391 ModuleSP exe_module_sp = target->GetExecutableModule();
392 LLDB_LOGF(log, "PlatformPOSIX::%s set selected target to %p %s",
393 __FUNCTION__, (void *)target,
394 exe_module_sp ? exe_module_sp->GetFileSpec().GetPath().c_str()
395 : "<null>");
396 }
397
398 process_sp =
399 target->CreateProcess(attach_info.GetListenerForProcess(debugger),
400 "gdb-remote", nullptr, true);
401
402 if (process_sp) {
403 ListenerSP listener_sp = attach_info.GetHijackListener();
404 if (listener_sp == nullptr) {
405 listener_sp =
406 Listener::MakeListener("lldb.PlatformPOSIX.attach.hijack");
407 attach_info.SetHijackListener(listener_sp);
408 }
409 process_sp->HijackProcessEvents(listener_sp);
410 process_sp->SetShadowListener(attach_info.GetShadowListener());
411 error = process_sp->Attach(attach_info);
412 }
413 }
414 } else {
416 process_sp =
417 m_remote_platform_sp->Attach(attach_info, debugger, target, error);
418 else
419 error =
420 Status::FromErrorString("the platform is not currently connected");
421 }
422 return process_sp;
423}
424
426 Debugger &debugger, Target &target,
427 Status &error) {
428 Log *log = GetLog(LLDBLog::Platform);
429 LLDB_LOG(log, "target {0}", &target);
430
431 ProcessSP process_sp;
432
433 if (!IsHost()) {
435 process_sp = m_remote_platform_sp->DebugProcess(launch_info, debugger,
436 target, error);
437 else
438 error =
439 Status::FromErrorString("the platform is not currently connected");
440 return process_sp;
441 }
442
443 //
444 // For local debugging, we'll insist on having ProcessGDBRemote create the
445 // process.
446 //
447
448 // Make sure we stop at the entry point
449 launch_info.GetFlags().Set(eLaunchFlagDebug);
450
451 // We always launch the process we are going to debug in a separate process
452 // group, since then we can handle ^C interrupts ourselves w/o having to
453 // worry about the target getting them as well.
454 launch_info.SetLaunchInSeparateProcessGroup(true);
455
456 // Now create the gdb-remote process.
457 LLDB_LOG(log, "having target create process with gdb-remote plugin");
458 process_sp = target.CreateProcess(launch_info.GetListener(), "gdb-remote",
459 nullptr, true);
460
461 if (!process_sp) {
463 "CreateProcess() failed for gdb-remote process");
464 LLDB_LOG(log, "error: {0}", error);
465 return process_sp;
466 }
467
468 LLDB_LOG(log, "successfully created process");
469
470 process_sp->HijackProcessEvents(launch_info.GetHijackListener());
471 process_sp->SetShadowListener(launch_info.GetShadowListener());
472
473 // Log file actions.
474 if (log) {
475 LLDB_LOG(log, "launching process with the following file actions:");
476 StreamString stream;
477 size_t i = 0;
478 const FileAction *file_action;
479 while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
480 file_action->Dump(stream);
481 LLDB_LOG(log, "{0}", stream.GetData());
482 stream.Clear();
483 }
484 }
485
486 // Do the launch.
487 error = process_sp->Launch(launch_info);
488 if (error.Success()) {
489 // Hook up process PTY if we have one (which we should for local debugging
490 // with llgs).
491 int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
492 if (pty_fd != PseudoTerminal::invalid_fd) {
493 process_sp->SetSTDIOFileDescriptor(pty_fd);
494 LLDB_LOG(log, "hooked up STDIO pty to process");
495 } else
496 LLDB_LOG(log, "not using process STDIO pty");
497 } else {
498 LLDB_LOG(log, "{0}", error);
499 // FIXME figure out appropriate cleanup here. Do we delete the process?
500 // Does our caller do that?
501 }
502
503 return process_sp;
504}
505
507 m_trap_handlers.push_back(ConstString("_sigtramp"));
508}
509
511 lldb_private::Process *process, const char *expr_cstr,
512 llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp) {
513 DynamicLoader *loader = process->GetDynamicLoader();
514 if (loader) {
515 Status error = loader->CanLoadImage();
516 if (error.Fail())
517 return error;
518 }
519
521 if (!thread_sp)
522 return Status::FromErrorString("Selected thread isn't valid");
523
524 StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
525 if (!frame_sp)
526 return Status::FromErrorString("Frame 0 isn't valid");
527
528 ExecutionContext exe_ctx;
529 frame_sp->CalculateExecutionContext(exe_ctx);
530 EvaluateExpressionOptions expr_options;
531 expr_options.SetUnwindOnError(true);
532 expr_options.SetIgnoreBreakpoints(true);
535 expr_options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
536 // don't do the work to trap them.
537 expr_options.SetTimeout(process->GetUtilityExpressionTimeout());
538
540 exe_ctx, expr_options, expr_cstr, expr_prefix, result_valobj_sp);
541 if (result != eExpressionCompleted)
542 return result_valobj_sp ? result_valobj_sp->GetError().Clone()
543 : Status("unknown error");
544
545 if (result_valobj_sp->GetError().Fail())
546 return result_valobj_sp->GetError().Clone();
547 return Status();
548}
549
550std::unique_ptr<UtilityFunction>
552 Status &error) {
553 // Remember to prepend this with the prefix from
554 // GetLibdlFunctionDeclarations. The returned values are all in
555 // __lldb_dlopen_result for consistency. The wrapper returns a void * but
556 // doesn't use it because UtilityFunctions don't work with void returns at
557 // present.
558 //
559 // Use lazy binding so as to not make dlopen()'s success conditional on
560 // forcing every symbol in the library.
561 //
562 // In general, the debugger should allow programs to load & run with
563 // libraries as far as they can, instead of defaulting to being super-picky
564 // about unavailable symbols.
565 //
566 // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
567 // and other POSIX OSes.
568 static const char *dlopen_wrapper_code = R"(
569 const int RTLD_LAZY = 1;
570
571 struct __lldb_dlopen_result {
572 void *image_ptr;
573 const char *error_str;
574 };
575
576 extern "C" void *memcpy(void *, const void *, size_t size);
577 extern "C" size_t strlen(const char *);
578
579
580 void * __lldb_dlopen_wrapper (const char *name,
581 const char *path_strings,
582 char *buffer,
583 __lldb_dlopen_result *result_ptr)
584 {
585 // This is the case where the name is the full path:
586 if (!path_strings) {
587 result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
588 if (result_ptr->image_ptr)
589 result_ptr->error_str = nullptr;
590 else
591 result_ptr->error_str = dlerror();
592 return nullptr;
593 }
594
595 // This is the case where we have a list of paths:
596 size_t name_len = strlen(name);
597 while (path_strings && path_strings[0] != '\0') {
598 size_t path_len = strlen(path_strings);
599 memcpy((void *) buffer, (void *) path_strings, path_len);
600 buffer[path_len] = '/';
601 char *target_ptr = buffer+path_len+1;
602 memcpy((void *) target_ptr, (void *) name, name_len + 1);
603 result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
604 if (result_ptr->image_ptr) {
605 result_ptr->error_str = nullptr;
606 break;
607 }
608 result_ptr->error_str = dlerror();
609 path_strings = path_strings + path_len + 1;
610 }
611 return nullptr;
612 }
613 )";
614
615 static const char *dlopen_wrapper_name = "__lldb_dlopen_wrapper";
616 Process *process = exe_ctx.GetProcessSP().get();
617 // Insert the dlopen shim defines into our generic expression:
618 std::string expr(std::string(GetLibdlFunctionDeclarations(process)));
619 expr.append(dlopen_wrapper_code);
620 Status utility_error;
621 DiagnosticManager diagnostics;
622
623 auto utility_fn_or_error = process->GetTarget().CreateUtilityFunction(
624 std::move(expr), dlopen_wrapper_name, eLanguageTypeC_plus_plus, exe_ctx);
625 if (!utility_fn_or_error) {
626 std::string error_str = llvm::toString(utility_fn_or_error.takeError());
628 "dlopen error: could not create utility function: %s",
629 error_str.c_str());
630 return nullptr;
631 }
632 std::unique_ptr<UtilityFunction> dlopen_utility_func_up =
633 std::move(*utility_fn_or_error);
634
635 Value value;
636 ValueList arguments;
637 FunctionCaller *do_dlopen_function = nullptr;
638
639 // Fetch the clang types we will need:
640 TypeSystemClangSP scratch_ts_sp =
642 if (!scratch_ts_sp)
643 return nullptr;
644
645 CompilerType clang_void_pointer_type =
646 scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
647 CompilerType clang_char_pointer_type =
648 scratch_ts_sp->GetBasicType(eBasicTypeChar).GetPointerType();
649
650 // We are passing four arguments, the basename, the list of places to look,
651 // a buffer big enough for all the path + name combos, and
652 // a pointer to the storage we've made for the result:
653 value.SetValueType(Value::ValueType::Scalar);
654 value.SetCompilerType(clang_void_pointer_type);
655 arguments.PushValue(value);
656 value.SetCompilerType(clang_char_pointer_type);
657 arguments.PushValue(value);
658 arguments.PushValue(value);
659 arguments.PushValue(value);
660
661 do_dlopen_function = dlopen_utility_func_up->MakeFunctionCaller(
662 clang_void_pointer_type, arguments, exe_ctx.GetThreadSP(), utility_error);
663 if (utility_error.Fail()) {
665 "dlopen error: could not make function caller: %s",
666 utility_error.AsCString());
667 return nullptr;
668 }
669
670 do_dlopen_function = dlopen_utility_func_up->GetFunctionCaller();
671 if (!do_dlopen_function) {
672 error =
673 Status::FromErrorString("dlopen error: could not get function caller.");
674 return nullptr;
675 }
676
677 // We made a good utility function, so cache it in the process:
678 return dlopen_utility_func_up;
679}
680
682 const lldb_private::FileSpec &remote_file,
683 const std::vector<std::string> *paths,
685 lldb_private::FileSpec *loaded_image) {
686 if (loaded_image)
687 loaded_image->Clear();
688
689 std::string path;
690 path = remote_file.GetPath(false);
691
692 ThreadSP thread_sp = process->GetThreadList().GetExpressionExecutionThread();
693 if (!thread_sp) {
695 "dlopen error: no thread available to call dlopen.");
697 }
698
699 DiagnosticManager diagnostics;
700
701 ExecutionContext exe_ctx;
702 thread_sp->CalculateExecutionContext(exe_ctx);
703
704 Status utility_error;
705 UtilityFunction *dlopen_utility_func;
706 ValueList arguments;
707 FunctionCaller *do_dlopen_function = nullptr;
708
709 // The UtilityFunction is held in the Process. Platforms don't track the
710 // lifespan of the Targets that use them, we can't put this in the Platform.
711 dlopen_utility_func = process->GetLoadImageUtilityFunction(
712 this, [&]() -> std::unique_ptr<UtilityFunction> {
713 return MakeLoadImageUtilityFunction(exe_ctx, error);
714 });
715 // If we couldn't make it, the error will be in error, so we can exit here.
716 if (!dlopen_utility_func)
718
719 do_dlopen_function = dlopen_utility_func->GetFunctionCaller();
720 if (!do_dlopen_function) {
721 error =
722 Status::FromErrorString("dlopen error: could not get function caller.");
724 }
725 arguments = do_dlopen_function->GetArgumentValues();
726
727 // Now insert the path we are searching for and the result structure into the
728 // target.
729 uint32_t permissions = ePermissionsReadable|ePermissionsWritable;
730 size_t path_len = path.size() + 1;
731 lldb::addr_t path_addr = process->AllocateMemory(path_len,
732 permissions,
733 utility_error);
734 if (path_addr == LLDB_INVALID_ADDRESS) {
736 "dlopen error: could not allocate memory for path: %s",
737 utility_error.AsCString());
739 }
740
741 // Make sure we deallocate the input string memory:
742 auto path_cleanup = llvm::make_scope_exit([process, path_addr] {
743 // Deallocate the buffer.
744 process->DeallocateMemory(path_addr);
745 });
746
747 process->WriteMemory(path_addr, path.c_str(), path_len, utility_error);
748 if (utility_error.Fail()) {
750 "dlopen error: could not write path string: %s",
751 utility_error.AsCString());
753 }
754
755 // Make space for our return structure. It is two pointers big: the token
756 // and the error string.
757 const uint32_t addr_size = process->GetAddressByteSize();
758 lldb::addr_t return_addr = process->CallocateMemory(2*addr_size,
759 permissions,
760 utility_error);
761 if (utility_error.Fail()) {
763 "dlopen error: could not allocate memory for path: %s",
764 utility_error.AsCString());
766 }
767
768 // Make sure we deallocate the result structure memory
769 auto return_cleanup = llvm::make_scope_exit([process, return_addr] {
770 // Deallocate the buffer
771 process->DeallocateMemory(return_addr);
772 });
773
774 // This will be the address of the storage for paths, if we are using them,
775 // or nullptr to signal we aren't.
776 lldb::addr_t path_array_addr = 0x0;
777 std::optional<llvm::detail::scope_exit<std::function<void()>>>
778 path_array_cleanup;
779
780 // This is the address to a buffer large enough to hold the largest path
781 // conjoined with the library name we're passing in. This is a convenience
782 // to avoid having to call malloc in the dlopen function.
783 lldb::addr_t buffer_addr = 0x0;
784 std::optional<llvm::detail::scope_exit<std::function<void()>>> buffer_cleanup;
785
786 // Set the values into our args and write them to the target:
787 if (paths != nullptr) {
788 // First insert the paths into the target. This is expected to be a
789 // continuous buffer with the strings laid out null terminated and
790 // end to end with an empty string terminating the buffer.
791 // We also compute the buffer's required size as we go.
792 size_t buffer_size = 0;
793 std::string path_array;
794 for (auto path : *paths) {
795 // Don't insert empty paths, they will make us abort the path
796 // search prematurely.
797 if (path.empty())
798 continue;
799 size_t path_size = path.size();
800 path_array.append(path);
801 path_array.push_back('\0');
802 if (path_size > buffer_size)
803 buffer_size = path_size;
804 }
805 path_array.push_back('\0');
806
807 path_array_addr = process->AllocateMemory(path_array.size(),
808 permissions,
809 utility_error);
810 if (path_array_addr == LLDB_INVALID_ADDRESS) {
812 "dlopen error: could not allocate memory for path array: %s",
813 utility_error.AsCString());
815 }
816
817 // Make sure we deallocate the paths array.
818 path_array_cleanup.emplace([process, path_array_addr]() {
819 // Deallocate the path array.
820 process->DeallocateMemory(path_array_addr);
821 });
822
823 process->WriteMemory(path_array_addr, path_array.data(),
824 path_array.size(), utility_error);
825
826 if (utility_error.Fail()) {
828 "dlopen error: could not write path array: %s",
829 utility_error.AsCString());
831 }
832 // Now make spaces in the target for the buffer. We need to add one for
833 // the '/' that the utility function will insert and one for the '\0':
834 buffer_size += path.size() + 2;
835
836 buffer_addr = process->AllocateMemory(buffer_size,
837 permissions,
838 utility_error);
839 if (buffer_addr == LLDB_INVALID_ADDRESS) {
841 "dlopen error: could not allocate memory for buffer: %s",
842 utility_error.AsCString());
844 }
845
846 // Make sure we deallocate the buffer memory:
847 buffer_cleanup.emplace([process, buffer_addr]() {
848 // Deallocate the buffer.
849 process->DeallocateMemory(buffer_addr);
850 });
851 }
852
853 arguments.GetValueAtIndex(0)->GetScalar() = path_addr;
854 arguments.GetValueAtIndex(1)->GetScalar() = path_array_addr;
855 arguments.GetValueAtIndex(2)->GetScalar() = buffer_addr;
856 arguments.GetValueAtIndex(3)->GetScalar() = return_addr;
857
858 lldb::addr_t func_args_addr = LLDB_INVALID_ADDRESS;
859
860 diagnostics.Clear();
861 if (!do_dlopen_function->WriteFunctionArguments(exe_ctx,
862 func_args_addr,
863 arguments,
864 diagnostics)) {
865 error = Status::FromError(diagnostics.GetAsError(
867 "dlopen error: could not write function arguments:"));
869 }
870
871 // Make sure we clean up the args structure. We can't reuse it because the
872 // Platform lives longer than the process and the Platforms don't get a
873 // signal to clean up cached data when a process goes away.
874 auto args_cleanup =
875 llvm::make_scope_exit([do_dlopen_function, &exe_ctx, func_args_addr] {
876 do_dlopen_function->DeallocateFunctionResults(exe_ctx, func_args_addr);
877 });
878
879 // Now run the caller:
882 options.SetLanguage(eLanguageTypeC_plus_plus);
883 options.SetIgnoreBreakpoints(true);
884 options.SetUnwindOnError(true);
885 options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
886 // don't do the work to trap them.
887 options.SetTimeout(process->GetUtilityExpressionTimeout());
888 options.SetIsForUtilityExpr(true);
889
890 Value return_value;
891 // Fetch the clang types we will need:
892 TypeSystemClangSP scratch_ts_sp =
894 if (!scratch_ts_sp) {
895 error =
896 Status::FromErrorString("dlopen error: Unable to get TypeSystemClang");
898 }
899
900 CompilerType clang_void_pointer_type =
901 scratch_ts_sp->GetBasicType(eBasicTypeVoid).GetPointerType();
902
903 return_value.SetCompilerType(clang_void_pointer_type);
904
905 ExpressionResults results = do_dlopen_function->ExecuteFunction(
906 exe_ctx, &func_args_addr, options, diagnostics, return_value);
907 if (results != eExpressionCompleted) {
908 error = Status::FromError(diagnostics.GetAsError(
910 "dlopen error: failed executing dlopen wrapper function:"));
912 }
913
914 // Read the dlopen token from the return area:
915 lldb::addr_t token = process->ReadPointerFromMemory(return_addr,
916 utility_error);
917 if (utility_error.Fail()) {
919 "dlopen error: could not read the return struct: %s",
920 utility_error.AsCString());
922 }
923
924 // The dlopen succeeded!
925 if (token != 0x0) {
926 if (loaded_image && buffer_addr != 0x0)
927 {
928 // Capture the image which was loaded. We leave it in the buffer on
929 // exit from the dlopen function, so we can just read it from there:
930 std::string name_string;
931 process->ReadCStringFromMemory(buffer_addr, name_string, utility_error);
932 if (utility_error.Success())
933 loaded_image->SetFile(name_string, llvm::sys::path::Style::posix);
934 }
935 return process->AddImageToken(token);
936 }
937
938 // We got an error, lets read in the error string:
939 std::string dlopen_error_str;
940 lldb::addr_t error_addr
941 = process->ReadPointerFromMemory(return_addr + addr_size, utility_error);
942 if (utility_error.Fail()) {
944 "dlopen error: could not read error string: %s",
945 utility_error.AsCString());
947 }
948
949 size_t num_chars = process->ReadCStringFromMemory(error_addr + addr_size,
950 dlopen_error_str,
951 utility_error);
952 if (utility_error.Success() && num_chars > 0)
953 error = Status::FromErrorStringWithFormat("dlopen error: %s",
954 dlopen_error_str.c_str());
955 else
956 error =
957 Status::FromErrorStringWithFormat("dlopen failed for unknown reasons.");
958
960}
961
963 uint32_t image_token) {
964 const addr_t image_addr = process->GetImagePtrFromToken(image_token);
965 if (image_addr == LLDB_INVALID_IMAGE_TOKEN)
966 return Status::FromErrorString("Invalid image token");
967
968 StreamString expr;
969 expr.Printf("dlclose((void *)0x%" PRIx64 ")", image_addr);
970 llvm::StringRef prefix = GetLibdlFunctionDeclarations(process);
971 lldb::ValueObjectSP result_valobj_sp;
972 Status error = EvaluateLibdlExpression(process, expr.GetData(), prefix,
973 result_valobj_sp);
974 if (error.Fail())
975 return error;
976
977 if (result_valobj_sp->GetError().Fail())
978 return result_valobj_sp->GetError().Clone();
979
980 Scalar scalar;
981 if (result_valobj_sp->ResolveValue(scalar)) {
982 if (scalar.UInt(1))
983 return Status::FromErrorStringWithFormat("expression failed: \"%s\"",
984 expr.GetData());
985 process->ResetImageToken(image_token);
986 }
987 return Status();
988}
989
990llvm::StringRef
992 return R"(
993 extern "C" void* dlopen(const char*, int);
994 extern "C" void* dlsym(void*, const char*);
995 extern "C" int dlclose(void*);
996 extern "C" char* dlerror(void);
997 )";
998}
999
1001 if (basename.IsEmpty())
1002 return basename;
1003
1004 StreamString stream;
1005 stream.Printf("lib%s.so", basename.GetCString());
1006 return ConstString(stream.GetString());
1007}
static llvm::raw_ostream & error(Stream &strm)
#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 chown_file(Platform *platform, const char *path, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX)
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, lldb_private::Status &error) override
Attach to an existing process using a process ID.
std::map< lldb_private::CommandInterpreter *, std::unique_ptr< lldb_private::OptionGroupOptions > > m_options
Definition: PlatformPOSIX.h:82
lldb::ProcessSP DebugProcess(lldb_private::ProcessLaunchInfo &launch_info, lldb_private::Debugger &debugger, lldb_private::Target &target, lldb_private::Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
lldb_private::Status GetFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination) override
PlatformPOSIX(bool is_host)
Default Constructor.
lldb_private::Status ConnectRemote(lldb_private::Args &args) override
lldb_private::Status DisconnectRemote() override
lldb_private::Status UnloadImage(lldb_private::Process *process, uint32_t image_token) override
lldb_private::Status EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp)
lldb_private::Status PutFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
std::unique_ptr< lldb_private::UtilityFunction > MakeLoadImageUtilityFunction(lldb_private::ExecutionContext &exe_ctx, lldb_private::Status &error)
std::unique_ptr< lldb_private::OptionGroupPlatformRSync > m_option_group_platform_rsync
Definition: PlatformPOSIX.h:74
~PlatformPOSIX() override
Destructor.
lldb_private::OptionGroupOptions * GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override
std::unique_ptr< lldb_private::OptionGroupPlatformCaching > m_option_group_platform_caching
Definition: PlatformPOSIX.h:78
std::string GetPlatformSpecificConnectionInformation() override
const lldb::UnixSignalsSP & GetRemoteUnixSignals() override
std::unique_ptr< lldb_private::OptionGroupPlatformSSH > m_option_group_platform_ssh
Definition: PlatformPOSIX.h:76
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override
virtual llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process)
uint32_t DoLoadImage(lldb_private::Process *process, const lldb_private::FileSpec &remote_file, const std::vector< std::string > *paths, lldb_private::Status &error, lldb_private::FileSpec *loaded_image) override
A command line argument class.
Definition: Args.h:33
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
A uniqued constant string class.
Definition: ConstString.h:40
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:304
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
A subclass of DataBuffer that stores a data buffer on the heap.
A class to manage flag bits.
Definition: Debugger.h:80
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:198
llvm::Error GetAsError(lldb::ExpressionResults result, llvm::Twine message={}) const
Returns an ExpressionError with arg as error code.
A plug-in interface definition class for dynamic loaders.
Definition: DynamicLoader.h:54
virtual Status CanLoadImage()=0
Ask if it is ok to try and load or unload an shared library (image).
void SetUnwindOnError(bool unwind=false)
Definition: Target.h:359
void SetExecutionPolicy(ExecutionPolicy policy=eExecutionPolicyAlways)
Definition: Target.h:325
void SetLanguage(lldb::LanguageType language_type)
Definition: Target.h:331
void SetTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:380
void SetIgnoreBreakpoints(bool ignore=false)
Definition: Target.h:363
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
void Dump(Stream &stream) const
Definition: FileAction.cpp:72
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error)
Definition: FileCache.cpp:26
static FileCache & GetInstance()
Definition: FileCache.cpp:19
A file utility class.
Definition: FileSpec.h:56
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:174
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 Clear()
Clears the object state.
Definition: FileSpec.cpp:259
@ eOpenOptionReadOnly
Definition: File.h:51
@ eOpenOptionWriteOnly
Definition: File.h:52
@ eOpenOptionCanCreate
Definition: File.h:56
@ eOpenOptionTruncate
Definition: File.h:57
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
Encapsulates a function that can be called.
ValueList GetArgumentValues() const
void DeallocateFunctionResults(ExecutionContext &exe_ctx, lldb::addr_t args_addr)
Deallocate the arguments structure.
lldb::ExpressionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager, Value &results)
Run the function this FunctionCaller was created with.
bool WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager)
Insert the default function argument struct.
static Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout, bool run_in_shell=true, bool hide_stderr=false)
Run a shell command.
static lldb::ListenerSP MakeListener(const char *name)
Definition: Listener.cpp:376
A plug-in interface definition class for debug platform that includes many platform abilities such as...
Definition: Platform.h:76
virtual void SetSupportsSSH(bool flag)
Definition: Platform.h:653
std::vector< ConstString > m_trap_handlers
Definition: Platform.h:1021
virtual const char * GetRSyncPrefix()
Definition: Platform.h:645
virtual void SetIgnoresRemoteHostname(bool flag)
Definition: Platform.h:661
virtual Status PutFile(const FileSpec &source, const FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX)
Definition: Platform.cpp:1120
virtual void SetSupportsRSync(bool flag)
Definition: Platform.h:639
virtual bool GetSupportsSSH()
Definition: Platform.h:651
virtual void SetSSHOpts(const char *opts)
Definition: Platform.h:657
virtual const char * GetLocalCacheDirectory()
Definition: Platform.cpp:1289
virtual const char * GetRSyncOpts()
Definition: Platform.h:641
virtual void SetLocalCacheDirectory(const char *local)
Definition: Platform.cpp:1285
virtual void SetRSyncOpts(const char *opts)
Definition: Platform.h:643
virtual void SetRSyncPrefix(const char *prefix)
Definition: Platform.h:647
virtual bool GetIgnoresRemoteHostname()
Definition: Platform.h:659
bool IsRemote() const
Definition: Platform.h:506
virtual Status GetFile(const FileSpec &source, const FileSpec &destination)
Definition: Platform.cpp:1206
virtual bool GetSupportsRSync()
Definition: Platform.h:637
bool IsHost() const
Definition: Platform.h:502
virtual lldb_private::Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout)
Definition: Platform.cpp:1245
virtual const lldb::UnixSignalsSP & GetRemoteUnixSignals()
Definition: Platform.cpp:1794
virtual const char * GetSSHOpts()
Definition: Platform.h:655
virtual llvm::StringRef GetPluginName()=0
lldb::ListenerSP GetListenerForProcess(Debugger &debugger)
Definition: Process.cpp:2936
void SetHijackListener(const lldb::ListenerSP &listener_sp)
Definition: ProcessInfo.h:110
lldb::ListenerSP GetHijackListener() const
Definition: ProcessInfo.h:108
lldb::ListenerSP GetListener() const
Definition: ProcessInfo.h:102
lldb::ListenerSP GetShadowListener() const
Definition: ProcessInfo.h:114
const FileAction * GetFileActionAtIndex(size_t idx) const
void SetLaunchInSeparateProcessGroup(bool separate)
std::chrono::seconds GetUtilityExpressionTimeout() const
Definition: Process.cpp:321
A plug-in interface definition class for debugging a process.
Definition: Process.h:343
UtilityFunction * GetLoadImageUtilityFunction(Platform *platform, llvm::function_ref< std::unique_ptr< UtilityFunction >()> factory)
Get the cached UtilityFunction that assists in loading binary images into the process.
Definition: Process.cpp:6350
void ResetImageToken(size_t token)
Definition: Process.cpp:6131
lldb::addr_t CallocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process, this also clears the allocated memory.
Definition: Process.cpp:2441
ThreadList & GetThreadList()
Definition: Process.h:2182
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process.
Definition: Process.cpp:2417
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
Definition: Process.cpp:2142
size_t AddImageToken(lldb::addr_t image_ptr)
Definition: Process.cpp:6120
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Definition: Process.cpp:2239
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
Definition: Process.cpp:2489
lldb::addr_t GetImagePtrFromToken(size_t token) const
Definition: Process.cpp:6125
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3615
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
Definition: Process.cpp:2275
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
Definition: Process.cpp:2830
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1246
int ReleasePrimaryFileDescriptor()
Release the primary file descriptor.
@ invalid_fd
Invalid file descriptor value.
A base class for platforms which automatically want to be able to forward operations to a remote plat...
uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error) override
uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error) override
bool CloseFile(lldb::user_id_t fd, Status &error) override
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags, uint32_t mode, Status &error) override
Status RunShellCommand(llvm::StringRef command, const FileSpec &working_dir, int *status_ptr, int *signo_ptr, std::string *command_output, const Timeout< std::micro > &timeout) override
Status GetFilePermissions(const FileSpec &file_spec, uint32_t &file_permissions) override
unsigned int UInt(unsigned int fail_value=0) const
Definition: Scalar.cpp:321
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
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
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:195
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition: Status.h:151
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition: Status.cpp:137
bool Success() const
Test for success condition.
Definition: Status.cpp:304
const char * GetData() const
Definition: StreamString.h:45
llvm::StringRef GetString() const
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
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::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1504
const lldb::ProcessSP & CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect)
Definition: Target.cpp:285
llvm::Expected< std::unique_ptr< UtilityFunction > > CreateUtilityFunction(std::string expression, std::string name, lldb::LanguageType language, ExecutionContext &exe_ctx)
Creates and installs a UtilityFunction for the given language.
Definition: Target.cpp:2706
lldb::ThreadSP GetExpressionExecutionThread()
Definition: ThreadList.cpp:59
static lldb::ExpressionResults Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Evaluate one expression in the scratch context of the target passed in the exe_ctx and return its res...
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
FunctionCaller * GetFunctionCaller()
void PushValue(const Value &value)
Definition: Value.cpp:687
Value * GetValueAtIndex(size_t idx)
Definition: Value.cpp:691
const Scalar & GetScalar() const
Definition: Value.h:112
void SetCompilerType(const CompilerType &compiler_type)
Definition: Value.cpp:268
void SetValueType(ValueType value_type)
Definition: Value.h:89
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
#define UINT64_MAX
Definition: lldb-defines.h:23
#define LLDB_INVALID_IMAGE_TOKEN
Definition: lldb-defines.h:85
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
#define UINT32_MAX
Definition: lldb-defines.h:19
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
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
Definition: lldb-forward.h:424
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:450
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:484
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
Definition: lldb-forward.h:480
@ eLanguageTypeC_plus_plus
ISO C++:1998.
ExpressionResults
The results of expression evaluation.
@ eExpressionCompleted
@ eExpressionSetupError
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:389
std::shared_ptr< lldb_private::Listener > ListenerSP
Definition: lldb-forward.h:368
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
Definition: lldb-forward.h:470
uint64_t user_id_t
Definition: lldb-types.h:82
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
Definition: lldb-forward.h:337
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:448
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:373