1 //===-- SBModuleSpec.h ------------------------------------------*- C++ -*-===//
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 #ifndef LLDB_SBModuleSpec_h_
10 #define LLDB_SBModuleSpec_h_
11 
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBFileSpec.h"
14 
15 namespace lldb {
16 
17 class LLDB_API SBModuleSpec {
18 public:
19   SBModuleSpec();
20 
21   SBModuleSpec(const SBModuleSpec &rhs);
22 
23   ~SBModuleSpec();
24 
25   const SBModuleSpec &operator=(const SBModuleSpec &rhs);
26 
27   explicit operator bool() const;
28 
29   bool IsValid() const;
30 
31   void Clear();
32 
33   //------------------------------------------------------------------
34   /// Get const accessor for the module file.
35   ///
36   /// This function returns the file for the module on the host system
37   /// that is running LLDB. This can differ from the path on the
38   /// platform since we might be doing remote debugging.
39   ///
40   /// \return
41   ///     A const reference to the file specification object.
42   //------------------------------------------------------------------
43   lldb::SBFileSpec GetFileSpec();
44 
45   void SetFileSpec(const lldb::SBFileSpec &fspec);
46 
47   //------------------------------------------------------------------
48   /// Get accessor for the module platform file.
49   ///
50   /// Platform file refers to the path of the module as it is known on
51   /// the remote system on which it is being debugged. For local
52   /// debugging this is always the same as Module::GetFileSpec(). But
53   /// remote debugging might mention a file '/usr/lib/liba.dylib'
54   /// which might be locally downloaded and cached. In this case the
55   /// platform file could be something like:
56   /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
57   /// The file could also be cached in a local developer kit directory.
58   ///
59   /// \return
60   ///     A const reference to the file specification object.
61   //------------------------------------------------------------------
62   lldb::SBFileSpec GetPlatformFileSpec();
63 
64   void SetPlatformFileSpec(const lldb::SBFileSpec &fspec);
65 
66   lldb::SBFileSpec GetSymbolFileSpec();
67 
68   void SetSymbolFileSpec(const lldb::SBFileSpec &fspec);
69 
70   const char *GetObjectName();
71 
72   void SetObjectName(const char *name);
73 
74   const char *GetTriple();
75 
76   void SetTriple(const char *triple);
77 
78   const uint8_t *GetUUIDBytes();
79 
80   size_t GetUUIDLength();
81 
82   bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len);
83 
84   bool GetDescription(lldb::SBStream &description);
85 
86 private:
87   friend class SBModuleSpecList;
88   friend class SBModule;
89   friend class SBTarget;
90 
91   std::unique_ptr<lldb_private::ModuleSpec> m_opaque_up;
92 };
93 
94 class SBModuleSpecList {
95 public:
96   SBModuleSpecList();
97 
98   SBModuleSpecList(const SBModuleSpecList &rhs);
99 
100   ~SBModuleSpecList();
101 
102   SBModuleSpecList &operator=(const SBModuleSpecList &rhs);
103 
104   static SBModuleSpecList GetModuleSpecifications(const char *path);
105 
106   void Append(const SBModuleSpec &spec);
107 
108   void Append(const SBModuleSpecList &spec_list);
109 
110   SBModuleSpec FindFirstMatchingSpec(const SBModuleSpec &match_spec);
111 
112   SBModuleSpecList FindMatchingSpecs(const SBModuleSpec &match_spec);
113 
114   size_t GetSize();
115 
116   SBModuleSpec GetSpecAtIndex(size_t i);
117 
118   bool GetDescription(lldb::SBStream &description);
119 
120 private:
121   std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_up;
122 };
123 
124 } // namespace lldb
125 
126 #endif // LLDB_SBModuleSpec_h_
127