]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h
MFV r320924:
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / MemoryRegionInfo.h
1 //===-- MemoryRegionInfo.h ---------------------------------------*- C++
2 //-*-===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #ifndef lldb_MemoryRegionInfo_h
12 #define lldb_MemoryRegionInfo_h
13
14 #include "lldb/Core/ConstString.h"
15 #include "lldb/Core/RangeMap.h"
16 #include "lldb/Utility/Range.h"
17
18 namespace lldb_private {
19 class MemoryRegionInfo {
20 public:
21   typedef Range<lldb::addr_t, lldb::addr_t> RangeType;
22
23   enum OptionalBool { eDontKnow = -1, eNo = 0, eYes = 1 };
24
25   MemoryRegionInfo()
26       : m_range(), m_read(eDontKnow), m_write(eDontKnow), m_execute(eDontKnow),
27         m_mapped(eDontKnow) {}
28
29   ~MemoryRegionInfo() {}
30
31   RangeType &GetRange() { return m_range; }
32
33   void Clear() {
34     m_range.Clear();
35     m_read = m_write = m_execute = eDontKnow;
36   }
37
38   const RangeType &GetRange() const { return m_range; }
39
40   OptionalBool GetReadable() const { return m_read; }
41
42   OptionalBool GetWritable() const { return m_write; }
43
44   OptionalBool GetExecutable() const { return m_execute; }
45
46   OptionalBool GetMapped() const { return m_mapped; }
47
48   const ConstString &GetName() const { return m_name; }
49
50   void SetReadable(OptionalBool val) { m_read = val; }
51
52   void SetWritable(OptionalBool val) { m_write = val; }
53
54   void SetExecutable(OptionalBool val) { m_execute = val; }
55
56   void SetMapped(OptionalBool val) { m_mapped = val; }
57
58   void SetName(const char *name) { m_name = ConstString(name); }
59
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;
66     if (m_read)
67       permissions |= lldb::ePermissionsReadable;
68     if (m_write)
69       permissions |= lldb::ePermissionsWritable;
70     if (m_execute)
71       permissions |= lldb::ePermissionsExecutable;
72     return permissions;
73   }
74
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;
83   }
84
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;
89   }
90
91   bool operator!=(const MemoryRegionInfo &rhs) const { return !(*this == rhs); }
92
93 protected:
94   RangeType m_range;
95   OptionalBool m_read;
96   OptionalBool m_write;
97   OptionalBool m_execute;
98   OptionalBool m_mapped;
99   ConstString m_name;
100 };
101 }
102
103 #endif // #ifndef lldb_MemoryRegionInfo_h