Howard Hellyer | 26036843 | 2016-06-23 08:35:37 +0000 | [diff] [blame^] | 1 | //===-- SBMemoryRegionInfo.cpp ----------------------------------*- 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 | #include "lldb/API/SBDefines.h" |
| 11 | #include "lldb/API/SBError.h" |
| 12 | #include "lldb/API/SBMemoryRegionInfo.h" |
| 13 | #include "lldb/API/SBStream.h" |
| 14 | #include "lldb/Core/StreamString.h" |
| 15 | #include "lldb/Target/MemoryRegionInfo.h" |
| 16 | |
| 17 | using namespace lldb; |
| 18 | using namespace lldb_private; |
| 19 | |
| 20 | |
| 21 | SBMemoryRegionInfo::SBMemoryRegionInfo () : |
| 22 | m_opaque_ap (new MemoryRegionInfo()) |
| 23 | { |
| 24 | } |
| 25 | |
| 26 | SBMemoryRegionInfo::SBMemoryRegionInfo (const MemoryRegionInfo *lldb_object_ptr) : |
| 27 | m_opaque_ap (new MemoryRegionInfo()) |
| 28 | { |
| 29 | if (lldb_object_ptr) |
| 30 | ref() = *lldb_object_ptr; |
| 31 | } |
| 32 | |
| 33 | SBMemoryRegionInfo::SBMemoryRegionInfo(const SBMemoryRegionInfo &rhs) : |
| 34 | m_opaque_ap (new MemoryRegionInfo()) |
| 35 | { |
| 36 | ref() = rhs.ref(); |
| 37 | } |
| 38 | |
| 39 | const SBMemoryRegionInfo & |
| 40 | SBMemoryRegionInfo::operator = (const SBMemoryRegionInfo &rhs) |
| 41 | { |
| 42 | if (this != &rhs) |
| 43 | { |
| 44 | ref() = rhs.ref(); |
| 45 | } |
| 46 | return *this; |
| 47 | } |
| 48 | |
| 49 | SBMemoryRegionInfo::~SBMemoryRegionInfo () |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | SBMemoryRegionInfo::Clear() |
| 55 | { |
| 56 | m_opaque_ap->Clear(); |
| 57 | } |
| 58 | |
| 59 | bool |
| 60 | SBMemoryRegionInfo::operator == (const SBMemoryRegionInfo &rhs) const |
| 61 | { |
| 62 | return ref() == rhs.ref(); |
| 63 | } |
| 64 | |
| 65 | bool |
| 66 | SBMemoryRegionInfo::operator != (const SBMemoryRegionInfo &rhs) const |
| 67 | { |
| 68 | return ref() != rhs.ref(); |
| 69 | } |
| 70 | |
| 71 | MemoryRegionInfo & |
| 72 | SBMemoryRegionInfo::ref() |
| 73 | { |
| 74 | return *m_opaque_ap; |
| 75 | } |
| 76 | |
| 77 | const MemoryRegionInfo & |
| 78 | SBMemoryRegionInfo::ref() const |
| 79 | { |
| 80 | return *m_opaque_ap; |
| 81 | } |
| 82 | |
| 83 | lldb::addr_t |
| 84 | SBMemoryRegionInfo::GetRegionBase () { |
| 85 | return m_opaque_ap->GetRange().GetRangeBase(); |
| 86 | } |
| 87 | |
| 88 | lldb::addr_t |
| 89 | SBMemoryRegionInfo::GetRegionEnd () { |
| 90 | return m_opaque_ap->GetRange().GetRangeEnd(); |
| 91 | } |
| 92 | |
| 93 | bool |
| 94 | SBMemoryRegionInfo::IsReadable () { |
| 95 | return m_opaque_ap->GetReadable() == MemoryRegionInfo::eYes; |
| 96 | } |
| 97 | |
| 98 | bool |
| 99 | SBMemoryRegionInfo::IsWritable () { |
| 100 | return m_opaque_ap->GetWritable() == MemoryRegionInfo::eYes; |
| 101 | } |
| 102 | |
| 103 | bool |
| 104 | SBMemoryRegionInfo::IsExecutable () { |
| 105 | return m_opaque_ap->GetExecutable() == MemoryRegionInfo::eYes; |
| 106 | } |
| 107 | |
| 108 | bool |
| 109 | SBMemoryRegionInfo::GetDescription (SBStream &description) |
| 110 | { |
| 111 | Stream &strm = description.ref(); |
| 112 | const addr_t load_addr = m_opaque_ap->GetRange().base; |
| 113 | |
| 114 | strm.Printf ("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 " ", load_addr, load_addr + m_opaque_ap->GetRange().size); |
| 115 | strm.Printf (m_opaque_ap->GetReadable() ? "R" : "-"); |
| 116 | strm.Printf (m_opaque_ap->GetWritable() ? "W" : "-"); |
| 117 | strm.Printf (m_opaque_ap->GetExecutable() ? "X" : "-"); |
| 118 | strm.Printf ("]"); |
| 119 | |
| 120 | return true; |
| 121 | } |