1 //===-- SBMemoryRegionInfo.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_API_SBMEMORYREGIONINFO_H
10 #define LLDB_API_SBMEMORYREGIONINFO_H
11 
12 #include "lldb/API/SBData.h"
13 #include "lldb/API/SBDefines.h"
14 
15 namespace lldb {
16 
17 class LLDB_API SBMemoryRegionInfo {
18 public:
19   SBMemoryRegionInfo();
20 
21   SBMemoryRegionInfo(const lldb::SBMemoryRegionInfo &rhs);
22 
23   ~SBMemoryRegionInfo();
24 
25   const lldb::SBMemoryRegionInfo &
26   operator=(const lldb::SBMemoryRegionInfo &rhs);
27 
28   void Clear();
29 
30   /// Get the base address of this memory range.
31   ///
32   /// \return
33   ///     The base address of this memory range.
34   lldb::addr_t GetRegionBase();
35 
36   /// Get the end address of this memory range.
37   ///
38   /// \return
39   ///     The base address of this memory range.
40   lldb::addr_t GetRegionEnd();
41 
42   /// Check if this memory address is marked readable to the process.
43   ///
44   /// \return
45   ///     true if this memory address is marked readable
46   bool IsReadable();
47 
48   /// Check if this memory address is marked writable to the process.
49   ///
50   /// \return
51   ///     true if this memory address is marked writable
52   bool IsWritable();
53 
54   /// Check if this memory address is marked executable to the process.
55   ///
56   /// \return
57   ///     true if this memory address is marked executable
58   bool IsExecutable();
59 
60   /// Check if this memory address is mapped into the process address
61   /// space.
62   ///
63   /// \return
64   ///     true if this memory address is in the process address space.
65   bool IsMapped();
66 
67   /// Returns the name of the memory region mapped at the given
68   /// address.
69   ///
70   /// \return
71   ///     In case of memory mapped files it is the absolute path of
72   ///     the file otherwise it is a name associated with the memory
73   ///     region. If no name can be determined the returns nullptr.
74   const char *GetName();
75 
76   /// Returns whether this memory region has a list of memory pages
77   /// that have been modified -- that are dirty.
78   ///
79   /// \return
80   ///     True if the dirty page list is available.
81   bool HasDirtyMemoryPageList();
82 
83   /// Returns the number of modified pages -- dirty pages -- in this
84   /// memory region.
85   ///
86   /// \return
87   ///     The number of dirty page entries will be returned.  If
88   ///     there are no dirty pages in this memory region, 0 will
89   ///     be returned.  0 will also be returned if the dirty page
90   ///     list is not available for this memory region -- you must
91   ///     use HasDirtyMemoryPageList() to check for that.
92   uint32_t GetNumDirtyPages();
93 
94   /// Returns the address of a memory page that has been modified in
95   /// this region.
96   ///
97   /// \return
98   ///     Returns the address for his dirty page in the list.
99   ///     If this memory region does not have a dirty page list,
100   ///     LLDB_INVALID_ADDRESS is returned.
101   addr_t GetDirtyPageAddressAtIndex(uint32_t idx);
102 
103   /// Returns the size of a memory page in this region.
104   ///
105   /// \return
106   ///     Returns the size of the memory pages in this region,
107   ///     or 0 if this information is unavailable.
108   int GetPageSize();
109 
110   bool operator==(const lldb::SBMemoryRegionInfo &rhs) const;
111 
112   bool operator!=(const lldb::SBMemoryRegionInfo &rhs) const;
113 
114   bool GetDescription(lldb::SBStream &description);
115 
116 private:
117   friend class SBProcess;
118   friend class SBMemoryRegionInfoList;
119 
120   lldb_private::MemoryRegionInfo &ref();
121 
122   const lldb_private::MemoryRegionInfo &ref() const;
123 
124   // Unused.
125   SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr);
126 
127   lldb::MemoryRegionInfoUP m_opaque_up;
128 };
129 
130 } // namespace lldb
131 
132 #endif // LLDB_API_SBMEMORYREGIONINFO_H
133