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> GetSupportedArchitectures() override;
33 
34   lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
35                                Debugger &debugger, Target &target,
36                                Status &error) override;
37 
38   lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
39                          Target *target, Status &status) override {
40     status.SetErrorString("Not supported");
41     return nullptr;
42   }
43 
44   bool IsConnected() const override { return true; }
45 
46   void CalculateTrapHandlerSymbolNames() override {}
47 
48   Environment GetEnvironment() override;
49 
50   MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr,
51                                   lldb::addr_t length, unsigned prot,
52                                   unsigned flags, lldb::addr_t fd,
53                                   lldb::addr_t offset) override {
54     return Platform::GetHostPlatform()->GetMmapArgumentList(
55         arch, addr, length, prot, flags, fd, offset);
56   }
57 
58 private:
59   static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
60   static void DebuggerInitialize(Debugger &debugger);
61 
62   PlatformQemuUser() : Platform(/*is_host=*/false) {}
63 };
64 
65 } // namespace lldb_private
66