]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Target/MemoryRegionInfo.h
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / include / lldb / Target / MemoryRegionInfo.h
1 //===-- MemoryRegionInfo.h ---------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef lldb_MemoryRegionInfo_h
11 #define lldb_MemoryRegionInfo_h
12
13 #include "lldb/Core/RangeMap.h"
14 #include "lldb/Utility/Range.h"
15
16 namespace lldb_private
17 {
18     class MemoryRegionInfo
19     {
20     public:
21         typedef Range<lldb::addr_t, lldb::addr_t> RangeType;
22         
23         enum OptionalBool {
24             eDontKnow  = -1,
25             eNo         = 0,
26             eYes        = 1
27         };
28         
29         MemoryRegionInfo () :
30         m_range (),
31         m_read (eDontKnow),
32         m_write (eDontKnow),
33         m_execute (eDontKnow),
34         m_mapped (eDontKnow)
35         {
36         }
37         
38         ~MemoryRegionInfo ()
39         {
40         }
41         
42         RangeType &
43         GetRange()
44         {
45             return m_range;
46         }
47         
48         void
49         Clear()
50         {
51             m_range.Clear();
52             m_read = m_write = m_execute = eDontKnow;
53         }
54         
55         const RangeType &
56         GetRange() const
57         {
58             return m_range;
59         }
60         
61         OptionalBool
62         GetReadable () const
63         {
64             return m_read;
65         }
66         
67         OptionalBool
68         GetWritable () const
69         {
70             return m_write;
71         }
72         
73         OptionalBool
74         GetExecutable () const
75         {
76             return m_execute;
77         }
78         
79         OptionalBool
80         GetMapped () const
81         {
82             return m_mapped;
83         }
84         
85         void
86         SetReadable (OptionalBool val)
87         {
88             m_read = val;
89         }
90         
91         void
92         SetWritable (OptionalBool val)
93         {
94             m_write = val;
95         }
96         
97         void
98         SetExecutable (OptionalBool val)
99         {
100             m_execute = val;
101         }
102         
103         void
104         SetMapped (OptionalBool val)
105         {
106             m_mapped = val;
107         }
108
109         //----------------------------------------------------------------------
110         // Get permissions as a uint32_t that is a mask of one or more bits from
111         // the lldb::Permissions
112         //----------------------------------------------------------------------
113         uint32_t
114         GetLLDBPermissions() const
115         {
116             uint32_t permissions = 0;
117             if (m_read)
118                 permissions |= lldb::ePermissionsReadable;
119             if (m_write)
120                 permissions |= lldb::ePermissionsWritable;
121             if (m_execute)
122                 permissions |= lldb::ePermissionsExecutable;
123             return permissions;
124         }
125
126         //----------------------------------------------------------------------
127         // Set permissions from a uint32_t that contains one or more bits from
128         // the lldb::Permissions
129         //----------------------------------------------------------------------
130         void
131         SetLLDBPermissions(uint32_t permissions)
132         {
133             m_read = (permissions & lldb::ePermissionsReadable) ? eYes : eNo;
134             m_write = (permissions & lldb::ePermissionsWritable) ? eYes : eNo;
135             m_execute = (permissions & lldb::ePermissionsExecutable) ? eYes : eNo;
136         }
137
138         bool
139         operator == (const MemoryRegionInfo &rhs) const
140         {
141             return m_range == rhs.m_range &&
142                    m_read == rhs.m_read &&
143                    m_write == rhs.m_write &&
144                    m_execute == rhs.m_execute &&
145                    m_mapped == rhs.m_mapped;
146         }
147         
148         bool
149         operator != (const MemoryRegionInfo &rhs) const
150         {
151             return !(*this == rhs);
152         }
153         
154     protected:
155         RangeType m_range;
156         OptionalBool m_read;
157         OptionalBool m_write;
158         OptionalBool m_execute;
159         OptionalBool m_mapped;
160     };
161 }
162
163 #endif // #ifndef lldb_MemoryRegionInfo_h