1 //===-- MemoryRegionInfo.h ---------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef lldb_MemoryRegionInfo_h
12 #define lldb_MemoryRegionInfo_h
14 #include "lldb/Core/ConstString.h"
15 #include "lldb/Core/RangeMap.h"
16 #include "lldb/Utility/Range.h"
18 namespace lldb_private {
19 class MemoryRegionInfo {
21 typedef Range<lldb::addr_t, lldb::addr_t> RangeType;
23 enum OptionalBool { eDontKnow = -1, eNo = 0, eYes = 1 };
26 : m_range(), m_read(eDontKnow), m_write(eDontKnow), m_execute(eDontKnow),
27 m_mapped(eDontKnow) {}
29 ~MemoryRegionInfo() {}
31 RangeType &GetRange() { return m_range; }
35 m_read = m_write = m_execute = eDontKnow;
38 const RangeType &GetRange() const { return m_range; }
40 OptionalBool GetReadable() const { return m_read; }
42 OptionalBool GetWritable() const { return m_write; }
44 OptionalBool GetExecutable() const { return m_execute; }
46 OptionalBool GetMapped() const { return m_mapped; }
48 const ConstString &GetName() const { return m_name; }
50 void SetReadable(OptionalBool val) { m_read = val; }
52 void SetWritable(OptionalBool val) { m_write = val; }
54 void SetExecutable(OptionalBool val) { m_execute = val; }
56 void SetMapped(OptionalBool val) { m_mapped = val; }
58 void SetName(const char *name) { m_name = ConstString(name); }
60 //----------------------------------------------------------------------
61 // Get permissions as a uint32_t that is a mask of one or more bits from
62 // the lldb::Permissions
63 //----------------------------------------------------------------------
64 uint32_t GetLLDBPermissions() const {
65 uint32_t permissions = 0;
67 permissions |= lldb::ePermissionsReadable;
69 permissions |= lldb::ePermissionsWritable;
71 permissions |= lldb::ePermissionsExecutable;
75 //----------------------------------------------------------------------
76 // Set permissions from a uint32_t that contains one or more bits from
77 // the lldb::Permissions
78 //----------------------------------------------------------------------
79 void SetLLDBPermissions(uint32_t permissions) {
80 m_read = (permissions & lldb::ePermissionsReadable) ? eYes : eNo;
81 m_write = (permissions & lldb::ePermissionsWritable) ? eYes : eNo;
82 m_execute = (permissions & lldb::ePermissionsExecutable) ? eYes : eNo;
85 bool operator==(const MemoryRegionInfo &rhs) const {
86 return m_range == rhs.m_range && m_read == rhs.m_read &&
87 m_write == rhs.m_write && m_execute == rhs.m_execute &&
88 m_mapped == rhs.m_mapped;
91 bool operator!=(const MemoryRegionInfo &rhs) const { return !(*this == rhs); }
97 OptionalBool m_execute;
98 OptionalBool m_mapped;
103 #endif // #ifndef lldb_MemoryRegionInfo_h