LLDB  mainline
SBMemoryRegionInfo.cpp
Go to the documentation of this file.
1 //===-- SBMemoryRegionInfo.cpp ----------------------------------*- 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 
10 #include "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBError.h"
14 #include "lldb/API/SBStream.h"
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 
23 }
24 
26  : m_opaque_up(new MemoryRegionInfo()) {
27  if (lldb_object_ptr)
28  ref() = *lldb_object_ptr;
29 }
30 
32  : m_opaque_up() {
34  (const lldb::SBMemoryRegionInfo &), rhs);
35  m_opaque_up = clone(rhs.m_opaque_up);
36 }
37 
42  SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &), rhs);
43 
44  if (this != &rhs)
45  m_opaque_up = clone(rhs.m_opaque_up);
46  return LLDB_RECORD_RESULT(*this);
47 }
48 
50 
53 
54  m_opaque_up->Clear();
55 }
56 
59  bool, SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &),
60  rhs);
61 
62  return ref() == rhs.ref();
63 }
64 
67  bool, SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &),
68  rhs);
69 
70  return ref() != rhs.ref();
71 }
72 
73 MemoryRegionInfo &SBMemoryRegionInfo::ref() { return *m_opaque_up; }
74 
75 const MemoryRegionInfo &SBMemoryRegionInfo::ref() const { return *m_opaque_up; }
76 
79 
80  return m_opaque_up->GetRange().GetRangeBase();
81 }
82 
85 
86  return m_opaque_up->GetRange().GetRangeEnd();
87 }
88 
91 
92  return m_opaque_up->GetReadable() == MemoryRegionInfo::eYes;
93 }
94 
97 
98  return m_opaque_up->GetWritable() == MemoryRegionInfo::eYes;
99 }
100 
103 
104  return m_opaque_up->GetExecutable() == MemoryRegionInfo::eYes;
105 }
106 
109 
110  return m_opaque_up->GetMapped() == MemoryRegionInfo::eYes;
111 }
112 
115 
116  return m_opaque_up->GetName().AsCString();
117 }
118 
121  (lldb::SBStream &), description);
122 
123  Stream &strm = description.ref();
124  const addr_t load_addr = m_opaque_up->GetRange().base;
125 
126  strm.Printf("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 " ", load_addr,
127  load_addr + m_opaque_up->GetRange().size);
128  strm.Printf(m_opaque_up->GetReadable() ? "R" : "-");
129  strm.Printf(m_opaque_up->GetWritable() ? "W" : "-");
130  strm.Printf(m_opaque_up->GetExecutable() ? "X" : "-");
131  strm.Printf("]");
132 
133  return true;
134 }
135 
136 namespace lldb_private {
137 namespace repro {
138 
139 template <>
143  (const lldb::SBMemoryRegionInfo &));
145  const lldb::SBMemoryRegionInfo &,
146  SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &));
149  bool,
150  SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &));
152  bool,
153  SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &));
160  LLDB_REGISTER_METHOD(const char *, SBMemoryRegionInfo, GetName, ());
162  (lldb::SBStream &));
163 }
164 
165 }
166 }
bool operator!=(const lldb::SBMemoryRegionInfo &rhs) const
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
bool IsMapped()
Check if this memory address is mapped into the process address space.
bool GetDescription(lldb::SBStream &description)
lldb::addr_t GetRegionBase()
Get the base address of this memory range.
const lldb::SBMemoryRegionInfo & operator=(const lldb::SBMemoryRegionInfo &rhs)
const char * GetName()
Returns the name of the memory region mapped at the given address.
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
bool IsWritable()
Check if this memory address is marked writable to the process.
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
lldb::addr_t GetRegionEnd()
Get the end address of this memory range.
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
bool operator==(const lldb::SBMemoryRegionInfo &rhs) const
uint64_t addr_t
Definition: lldb-types.h:83
Definition: SBAddress.h:15
void RegisterMethods< SBMemoryRegionInfo >(Registry &R)
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
bool IsExecutable()
Check if this memory address is marked executable to the process.
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
bool IsReadable()
Check if this memory address is marked readable to the process.