LLDB  mainline
PlatformQemuUser.h
Go to the documentation of this file.
1 //===-- PlatformQemuUser.h ------------------------------------------------===//
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/Host/Host.h"
10 #include "lldb/Host/HostInfo.h"
11 #include "lldb/Target/Platform.h"
12 
13 namespace lldb_private {
14 
15 class PlatformQemuUser : public Platform {
16 public:
17  static void Initialize();
18  static void Terminate();
19 
20  static llvm::StringRef GetPluginNameStatic() { return "qemu-user"; }
21  static llvm::StringRef GetPluginDescriptionStatic();
22 
23  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
24  llvm::StringRef GetDescription() override {
26  }
27 
29  return HostInfo::GetUserIDResolver();
30  }
31 
32  std::vector<ArchSpec>
33  GetSupportedArchitectures(const ArchSpec &process_host_arch) override;
34 
35  lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
36  Debugger &debugger, Target &target,
37  Status &error) override;
38 
39  lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
40  Target *target, Status &status) override {
41  status.SetErrorString("Not supported");
42  return nullptr;
43  }
44 
45  bool IsConnected() const override { return true; }
46 
48 
49  Environment GetEnvironment() override;
50 
52  lldb::addr_t length, unsigned prot,
53  unsigned flags, lldb::addr_t fd,
54  lldb::addr_t offset) override {
55  return Platform::GetHostPlatform()->GetMmapArgumentList(
56  arch, addr, length, prot, flags, fd, offset);
57  }
58 
59 private:
60  static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
61  static void DebuggerInitialize(Debugger &debugger);
62 
63  PlatformQemuUser() : Platform(/*is_host=*/true) {}
64 };
65 
66 } // namespace lldb_private
lldb_private::PlatformQemuUser::GetUserIDResolver
UserIDResolver & GetUserIDResolver() override
Definition: PlatformQemuUser.h:28
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::MmapArgList
llvm::SmallVector< lldb::addr_t, 6 > MmapArgList
Definition: Platform.h:58
Host.h
lldb_private::PlatformQemuUser::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: PlatformQemuUser.cpp:79
lldb_private::PlatformQemuUser::GetPluginName
llvm::StringRef GetPluginName() override
Definition: PlatformQemuUser.h:23
lldb_private::PlatformQemuUser::CreateInstance
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
Definition: PlatformQemuUser.cpp:103
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::Target
Definition: Target.h:467
lldb_private::PlatformQemuUser::GetEnvironment
Environment GetEnvironment() override
Definition: PlatformQemuUser.cpp:239
Platform.h
lldb_private::Platform::GetHostPlatform
static lldb::PlatformSP GetHostPlatform()
Get the native host platform plug-in.
Definition: Platform.cpp:136
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ProcessLaunchInfo
Definition: ProcessLaunchInfo.h:31
lldb_private::PlatformQemuUser::GetMmapArgumentList
MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr, lldb::addr_t length, unsigned prot, unsigned flags, lldb::addr_t fd, lldb::addr_t offset) override
Definition: PlatformQemuUser.h:51
lldb_private::PlatformQemuUser::GetSupportedArchitectures
std::vector< ArchSpec > GetSupportedArchitectures(const ArchSpec &process_host_arch) override
Get the platform's supported architectures in the order in which they should be searched.
Definition: PlatformQemuUser.cpp:110
lldb_private::PlatformQemuUser::IsConnected
bool IsConnected() const override
Definition: PlatformQemuUser.h:45
lldb_private::PlatformQemuUser::Initialize
static void Initialize()
Definition: PlatformQemuUser.cpp:83
lldb_private::Debugger
Definition: Debugger.h:74
HostInfo.h
lldb_private::ProcessAttachInfo
Definition: Process.h:113
lldb_private::UserIDResolver
An abstract interface for things that know how to map numeric user/group IDs into names.
Definition: UserIDResolver.h:23
lldb_private::PlatformQemuUser::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: PlatformQemuUser.h:20
lldb_private::Status
Definition: Status.h:44
lldb_private::PlatformQemuUser::GetDescription
llvm::StringRef GetDescription() override
Definition: PlatformQemuUser.h:24
lldb_private::PlatformQemuUser
Definition: PlatformQemuUser.h:15
lldb_private::PlatformQemuUser::DebuggerInitialize
static void DebuggerInitialize(Debugger &debugger)
Definition: PlatformQemuUser.cpp:93
lldb_private::Status::SetErrorString
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
lldb_private::PlatformQemuUser::Terminate
static void Terminate()
Definition: PlatformQemuUser.cpp:89
lldb_private::PlatformQemuUser::PlatformQemuUser
PlatformQemuUser()
Definition: PlatformQemuUser.h:63
lldb_private::Environment
Definition: Environment.h:18
lldb_private::Platform
Definition: Platform.h:71
lldb_private::PlatformQemuUser::Attach
lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Status &status) override
Attach to an existing process using a process ID.
Definition: PlatformQemuUser.h:39
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::PlatformQemuUser::DebugProcess
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target &target, Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
Definition: PlatformQemuUser.cpp:162
lldb_private::PlatformQemuUser::CalculateTrapHandlerSymbolNames
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
Definition: PlatformQemuUser.h:47