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 {
25     return GetPluginDescriptionStatic();
26   }
27 
28   UserIDResolver &GetUserIDResolver() override {
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 
47   void CalculateTrapHandlerSymbolNames() override {}
48 
49   Environment GetEnvironment() override;
50 
51   MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr,
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
67