179129Smsmith//===-- SBMemoryRegionInfo.h ------------------------------------*- C++ -*-===//
279129Smsmith//
379129Smsmith// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
479129Smsmith// See https://llvm.org/LICENSE.txt for license information.
579129Smsmith// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
679129Smsmith//
779129Smsmith//===----------------------------------------------------------------------===//
879129Smsmith
979129Smsmith#ifndef LLDB_API_SBMEMORYREGIONINFO_H
1079129Smsmith#define LLDB_API_SBMEMORYREGIONINFO_H
1179129Smsmith
1279129Smsmith#include "lldb/API/SBData.h"
1379129Smsmith#include "lldb/API/SBDefines.h"
1479129Smsmith
1579129Smsmithnamespace lldb {
1679129Smsmith
1779129Smsmithclass LLDB_API SBMemoryRegionInfo {
1879129Smsmithpublic:
1979129Smsmith  SBMemoryRegionInfo();
2079129Smsmith
2179129Smsmith  SBMemoryRegionInfo(const lldb::SBMemoryRegionInfo &rhs);
2279129Smsmith
2379129Smsmith  SBMemoryRegionInfo(const char *name, lldb::addr_t begin, lldb::addr_t end,
2479129Smsmith                     uint32_t permissions, bool mapped,
2579129Smsmith                     bool stack_memory = false);
2679129Smsmith
2779129Smsmith  ~SBMemoryRegionInfo();
28239340Sjkim
2979129Smsmith  const lldb::SBMemoryRegionInfo &
3079129Smsmith  operator=(const lldb::SBMemoryRegionInfo &rhs);
3179129Smsmith
3279129Smsmith  void Clear();
3379129Smsmith
3479129Smsmith  /// Get the base address of this memory range.
35115697Sru  ///
3679129Smsmith  /// \return
37115697Sru  ///     The base address of this memory range.
38156159Swkoszek  lldb::addr_t GetRegionBase();
3979129Smsmith
4079129Smsmith  /// Get the end address of this memory range.
4179129Smsmith  ///
4279129Smsmith  /// \return
4379129Smsmith  ///     The base address of this memory range.
4479129Smsmith  lldb::addr_t GetRegionEnd();
4579129Smsmith
4679129Smsmith  /// Check if this memory address is marked readable to the process.
4779129Smsmith  ///
4879129Smsmith  /// \return
4982373Smsmith  ///     true if this memory address is marked readable
5082373Smsmith  bool IsReadable();
5182373Smsmith
52138840Sru  /// Check if this memory address is marked writable to the process.
53138840Sru  ///
54138840Sru  /// \return
55138826Snjl  ///     true if this memory address is marked writable
56148066Shrs  bool IsWritable();
57138826Snjl
58138826Snjl  /// Check if this memory address is marked executable to the process.
59138826Snjl  ///
60160825Snjl  /// \return
61160825Snjl  ///     true if this memory address is marked executable
62160825Snjl  bool IsExecutable();
63160825Snjl
64138826Snjl  /// Check if this memory address is mapped into the process address
65204918Sjkim  /// space.
66204918Sjkim  ///
67204918Sjkim  /// \return
68204918Sjkim  ///     true if this memory address is in the process address space.
69160825Snjl  bool IsMapped();
70160825Snjl
71138826Snjl  /// Returns the name of the memory region mapped at the given
72138826Snjl  /// address.
73138826Snjl  ///
74138826Snjl  /// \return
75138826Snjl  ///     In case of memory mapped files it is the absolute path of
76138826Snjl  ///     the file otherwise it is a name associated with the memory
77138826Snjl  ///     region. If no name can be determined the returns nullptr.
78161033Syar  const char *GetName();
79161033Syar
80161033Syar  /// Returns whether this memory region has a list of memory pages
81138826Snjl  /// that have been modified -- that are dirty.
82138826Snjl  ///
83240340Savg  /// \return
84240340Savg  ///     True if the dirty page list is available.
85240340Savg  bool HasDirtyMemoryPageList();
86240340Savg
87240340Savg  /// Returns the number of modified pages -- dirty pages -- in this
88240340Savg  /// memory region.
89138826Snjl  ///
90138826Snjl  /// \return
91138826Snjl  ///     The number of dirty page entries will be returned.  If
92161033Syar  ///     there are no dirty pages in this memory region, 0 will
93161033Syar  ///     be returned.  0 will also be returned if the dirty page
94161033Syar  ///     list is not available for this memory region -- you must
95161033Syar  ///     use HasDirtyMemoryPageList() to check for that.
96161033Syar  uint32_t GetNumDirtyPages();
97161033Syar
98161033Syar  /// Returns the address of a memory page that has been modified in
99161033Syar  /// this region.
100161033Syar  ///
101161033Syar  /// \return
102161033Syar  ///     Returns the address for his dirty page in the list.
103138826Snjl  ///     If this memory region does not have a dirty page list,
104161033Syar  ///     LLDB_INVALID_ADDRESS is returned.
105161033Syar  addr_t GetDirtyPageAddressAtIndex(uint32_t idx);
106161033Syar
107161033Syar  /// Returns the size of a memory page in this region.
108161033Syar  ///
109161033Syar  /// \return
110138826Snjl  ///     Returns the size of the memory pages in this region,
111138826Snjl  ///     or 0 if this information is unavailable.
112160825Snjl  int GetPageSize();
113160825Snjl
114160825Snjl  bool operator==(const lldb::SBMemoryRegionInfo &rhs) const;
115160825Snjl
116160825Snjl  bool operator!=(const lldb::SBMemoryRegionInfo &rhs) const;
117160825Snjl
118160825Snjl  bool GetDescription(lldb::SBStream &description);
119160825Snjl
120160825Snjlprivate:
121160825Snjl  friend class SBProcess;
122160962Snjl  friend class SBMemoryRegionInfoList;
123161033Syar
124160962Snjl  friend class lldb_private::ScriptInterpreter;
125161033Syar
126161033Syar  lldb_private::MemoryRegionInfo &ref();
127161033Syar
128160825Snjl  const lldb_private::MemoryRegionInfo &ref() const;
129160962Snjl
130161033Syar  // Unused.
131160962Snjl  SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr);
132160962Snjl
133161033Syar  lldb::MemoryRegionInfoUP m_opaque_up;
134160962Snjl};
135160825Snjl
136160825Snjl} // namespace lldb
137160825Snjl
138160825Snjl#endif // LLDB_API_SBMEMORYREGIONINFO_H
139160825Snjl