Raphael Isemann | 8081428 | 2020-01-24 08:23:27 +0100 | [diff] [blame] | 1 | //===-- SBAddress.cpp -----------------------------------------------------===// |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "lldb/API/SBAddress.h" |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 10 | #include "SBReproducerPrivate.h" |
Jonas Devlieghere | bd4bf82 | 2019-03-06 00:05:55 +0000 | [diff] [blame] | 11 | #include "Utils.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | #include "lldb/API/SBProcess.h" |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 13 | #include "lldb/API/SBSection.h" |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 14 | #include "lldb/API/SBStream.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Core/Address.h" |
Greg Clayton | 05d2b7f | 2011-03-31 01:08:07 +0000 | [diff] [blame] | 16 | #include "lldb/Core/Module.h" |
Zachary Turner | 32abc6e | 2015-03-03 19:23:09 +0000 | [diff] [blame] | 17 | #include "lldb/Symbol/LineEntry.h" |
Greg Clayton | af67cec | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 18 | #include "lldb/Target/Target.h" |
Zachary Turner | bf9a773 | 2017-02-02 21:39:50 +0000 | [diff] [blame] | 19 | #include "lldb/Utility/StreamString.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace lldb; |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 22 | using namespace lldb_private; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 24 | SBAddress::SBAddress() : m_opaque_up(new Address()) { |
| 25 | LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress); |
| 26 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 27 | |
Jonas Devlieghere | 6cd4a4c | 2020-09-25 11:15:44 -0700 | [diff] [blame] | 28 | SBAddress::SBAddress(const Address &address) |
| 29 | : m_opaque_up(std::make_unique<Address>(address)) {} |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 30 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 31 | SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 32 | LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs); |
| 33 | |
Jonas Devlieghere | bd4bf82 | 2019-03-06 00:05:55 +0000 | [diff] [blame] | 34 | m_opaque_up = clone(rhs.m_opaque_up); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 37 | SBAddress::SBAddress(lldb::SBSection section, lldb::addr_t offset) |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 38 | : m_opaque_up(new Address(section.GetSP(), offset)) { |
| 39 | LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t), section, |
| 40 | offset); |
| 41 | } |
Greg Clayton | 819134a | 2012-02-04 02:58:17 +0000 | [diff] [blame] | 42 | |
Greg Clayton | 00e6fbf | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 43 | // Create an address by resolving a load address using the supplied target |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 44 | SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target) |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 45 | : m_opaque_up(new Address()) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 46 | LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &), |
| 47 | load_addr, target); |
| 48 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 49 | SetLoadAddress(load_addr, target); |
Greg Clayton | 00e6fbf | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Jonas Devlieghere | 866b7a6 | 2020-02-17 22:57:06 -0800 | [diff] [blame] | 52 | SBAddress::~SBAddress() = default; |
Greg Clayton | 00e6fbf | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 54 | const SBAddress &SBAddress::operator=(const SBAddress &rhs) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 55 | LLDB_RECORD_METHOD(const lldb::SBAddress &, |
| 56 | SBAddress, operator=,(const lldb::SBAddress &), rhs); |
| 57 | |
Jonas Devlieghere | bd4bf82 | 2019-03-06 00:05:55 +0000 | [diff] [blame] | 58 | if (this != &rhs) |
| 59 | m_opaque_up = clone(rhs.m_opaque_up); |
Jonas Devlieghere | 306809f | 2019-04-03 21:31:22 +0000 | [diff] [blame] | 60 | return LLDB_RECORD_RESULT(*this); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Nitesh Jain | dd12594 | 2017-05-04 11:34:42 +0000 | [diff] [blame] | 63 | bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { |
| 64 | if (lhs.IsValid() && rhs.IsValid()) |
| 65 | return lhs.ref() == rhs.ref(); |
| 66 | return false; |
| 67 | } |
| 68 | |
Pavel Labath | 4bc0500 | 2019-04-02 10:18:46 +0000 | [diff] [blame] | 69 | bool SBAddress::operator!=(const SBAddress &rhs) const { |
| 70 | LLDB_RECORD_METHOD_CONST(bool, SBAddress, operator!=,(const SBAddress &), |
| 71 | &rhs); |
| 72 | |
| 73 | return !(*this == rhs); |
| 74 | } |
| 75 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | bool SBAddress::IsValid() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 77 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, IsValid); |
Pavel Labath | 7f5237b | 2019-03-11 13:58:46 +0000 | [diff] [blame] | 78 | return this->operator bool(); |
| 79 | } |
| 80 | SBAddress::operator bool() const { |
| 81 | LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 82 | |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 83 | return m_opaque_up != nullptr && m_opaque_up->IsValid(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 86 | void SBAddress::Clear() { |
| 87 | LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear); |
| 88 | |
Jonas Devlieghere | 1c0bbe4 | 2020-06-24 16:25:05 -0700 | [diff] [blame] | 89 | m_opaque_up = std::make_unique<Address>(); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 90 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 91 | |
| 92 | void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 93 | LLDB_RECORD_METHOD(void, SBAddress, SetAddress, |
| 94 | (lldb::SBSection, lldb::addr_t), section, offset); |
| 95 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 96 | Address &addr = ref(); |
| 97 | addr.SetSection(section.GetSP()); |
| 98 | addr.SetOffset(offset); |
| 99 | } |
| 100 | |
Jonas Devlieghere | 6cd4a4c | 2020-09-25 11:15:44 -0700 | [diff] [blame] | 101 | void SBAddress::SetAddress(const Address &address) { ref() = address; } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 102 | |
| 103 | lldb::addr_t SBAddress::GetFileAddress() const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 104 | LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress); |
| 105 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 106 | if (m_opaque_up->IsValid()) |
| 107 | return m_opaque_up->GetFileAddress(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 108 | else |
| 109 | return LLDB_INVALID_ADDRESS; |
| 110 | } |
| 111 | |
| 112 | lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 113 | LLDB_RECORD_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress, |
| 114 | (const lldb::SBTarget &), target); |
| 115 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 116 | lldb::addr_t addr = LLDB_INVALID_ADDRESS; |
| 117 | TargetSP target_sp(target.GetSP()); |
| 118 | if (target_sp) { |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 119 | if (m_opaque_up->IsValid()) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 120 | std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 121 | addr = m_opaque_up->GetLoadAddress(target_sp.get()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 125 | return addr; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 128 | void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 129 | LLDB_RECORD_METHOD(void, SBAddress, SetLoadAddress, |
| 130 | (lldb::addr_t, lldb::SBTarget &), load_addr, target); |
| 131 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 132 | // Create the address object if we don't already have one |
| 133 | ref(); |
| 134 | if (target.IsValid()) |
| 135 | *this = target.ResolveLoadAddress(load_addr); |
| 136 | else |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 137 | m_opaque_up->Clear(); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 138 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 139 | // Check if we weren't were able to resolve a section offset address. If we |
| 140 | // weren't it is ok, the load address might be a location on the stack or |
| 141 | // heap, so we should just have an address with no section and a valid offset |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 142 | if (!m_opaque_up->IsValid()) |
| 143 | m_opaque_up->SetOffset(load_addr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | bool SBAddress::OffsetAddress(addr_t offset) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 147 | LLDB_RECORD_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t), offset); |
| 148 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 149 | if (m_opaque_up->IsValid()) { |
| 150 | addr_t addr_offset = m_opaque_up->GetOffset(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 151 | if (addr_offset != LLDB_INVALID_ADDRESS) { |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 152 | m_opaque_up->SetOffset(addr_offset + offset); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 153 | return true; |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 154 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 155 | } |
| 156 | return false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 159 | lldb::SBSection SBAddress::GetSection() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 160 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBAddress, GetSection); |
| 161 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 162 | lldb::SBSection sb_section; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 163 | if (m_opaque_up->IsValid()) |
| 164 | sb_section.SetSP(m_opaque_up->GetSection()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 165 | return LLDB_RECORD_RESULT(sb_section); |
Greg Clayton | 00e6fbf | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 168 | lldb::addr_t SBAddress::GetOffset() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 169 | LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBAddress, GetOffset); |
| 170 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 171 | if (m_opaque_up->IsValid()) |
| 172 | return m_opaque_up->GetOffset(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 173 | return 0; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 176 | Address *SBAddress::operator->() { return m_opaque_up.get(); } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 177 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 178 | const Address *SBAddress::operator->() const { return m_opaque_up.get(); } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 179 | |
| 180 | Address &SBAddress::ref() { |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 181 | if (m_opaque_up == nullptr) |
Jonas Devlieghere | 1c0bbe4 | 2020-06-24 16:25:05 -0700 | [diff] [blame] | 182 | m_opaque_up = std::make_unique<Address>(); |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 183 | return *m_opaque_up; |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 184 | } |
| 185 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 186 | const Address &SBAddress::ref() const { |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 187 | // This object should already have checked with "IsValid()" prior to calling |
| 188 | // this function. In case you didn't we will assert and die to let you know. |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 189 | assert(m_opaque_up.get()); |
| 190 | return *m_opaque_up; |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 191 | } |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 192 | |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 193 | Address *SBAddress::get() { return m_opaque_up.get(); } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 194 | |
| 195 | bool SBAddress::GetDescription(SBStream &description) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 196 | LLDB_RECORD_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &), |
| 197 | description); |
| 198 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 199 | // Call "ref()" on the stream to make sure it creates a backing stream in |
| 200 | // case there isn't one already... |
| 201 | Stream &strm = description.ref(); |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 202 | if (m_opaque_up->IsValid()) { |
Konrad Kleine | 248a130 | 2019-05-23 11:14:47 +0000 | [diff] [blame] | 203 | m_opaque_up->Dump(&strm, nullptr, Address::DumpStyleResolvedDescription, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 204 | Address::DumpStyleModuleWithFileAddress, 4); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 205 | } else |
| 206 | strm.PutCString("No value"); |
| 207 | |
| 208 | return true; |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 209 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 210 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 211 | SBModule SBAddress::GetModule() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 212 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBAddress, GetModule); |
| 213 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 214 | SBModule sb_module; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 215 | if (m_opaque_up->IsValid()) |
| 216 | sb_module.SetSP(m_opaque_up->GetModule()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 217 | return LLDB_RECORD_RESULT(sb_module); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 220 | SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 221 | LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext, |
| 222 | (uint32_t), resolve_scope); |
| 223 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 224 | SBSymbolContext sb_sc; |
Zachary Turner | 991e445 | 2018-10-25 20:45:19 +0000 | [diff] [blame] | 225 | SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 226 | if (m_opaque_up->IsValid()) |
| 227 | m_opaque_up->CalculateSymbolContext(&sb_sc.ref(), scope); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 228 | return LLDB_RECORD_RESULT(sb_sc); |
Greg Clayton | 0996003 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 231 | SBCompileUnit SBAddress::GetCompileUnit() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 232 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBAddress, GetCompileUnit); |
| 233 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 234 | SBCompileUnit sb_comp_unit; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 235 | if (m_opaque_up->IsValid()) |
| 236 | sb_comp_unit.reset(m_opaque_up->CalculateSymbolContextCompileUnit()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 237 | return LLDB_RECORD_RESULT(sb_comp_unit); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 240 | SBFunction SBAddress::GetFunction() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 241 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBAddress, GetFunction); |
| 242 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 243 | SBFunction sb_function; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 244 | if (m_opaque_up->IsValid()) |
| 245 | sb_function.reset(m_opaque_up->CalculateSymbolContextFunction()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 246 | return LLDB_RECORD_RESULT(sb_function); |
Caroline Tice | 750cd17 | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 247 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 248 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 249 | SBBlock SBAddress::GetBlock() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 250 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBAddress, GetBlock); |
| 251 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 252 | SBBlock sb_block; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 253 | if (m_opaque_up->IsValid()) |
| 254 | sb_block.SetPtr(m_opaque_up->CalculateSymbolContextBlock()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 255 | return LLDB_RECORD_RESULT(sb_block); |
Caroline Tice | dde9cff | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 256 | } |
Greg Clayton | 05d2b7f | 2011-03-31 01:08:07 +0000 | [diff] [blame] | 257 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 258 | SBSymbol SBAddress::GetSymbol() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 259 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBAddress, GetSymbol); |
| 260 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 261 | SBSymbol sb_symbol; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 262 | if (m_opaque_up->IsValid()) |
| 263 | sb_symbol.reset(m_opaque_up->CalculateSymbolContextSymbol()); |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 264 | return LLDB_RECORD_RESULT(sb_symbol); |
Greg Clayton | 05d2b7f | 2011-03-31 01:08:07 +0000 | [diff] [blame] | 265 | } |
| 266 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 267 | SBLineEntry SBAddress::GetLineEntry() { |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 268 | LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBAddress, GetLineEntry); |
| 269 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 270 | SBLineEntry sb_line_entry; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 271 | if (m_opaque_up->IsValid()) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 272 | LineEntry line_entry; |
Jonas Devlieghere | d5b4403 | 2019-02-13 06:25:41 +0000 | [diff] [blame] | 273 | if (m_opaque_up->CalculateSymbolContextLineEntry(line_entry)) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 274 | sb_line_entry.SetLineEntry(line_entry); |
| 275 | } |
Jonas Devlieghere | baf5664 | 2019-03-06 00:06:00 +0000 | [diff] [blame] | 276 | return LLDB_RECORD_RESULT(sb_line_entry); |
Greg Clayton | 7e9b1fd | 2011-08-12 21:40:01 +0000 | [diff] [blame] | 277 | } |
Michal Gorny | ae211ec | 2019-03-19 17:13:13 +0000 | [diff] [blame] | 278 | |
| 279 | namespace lldb_private { |
| 280 | namespace repro { |
| 281 | |
| 282 | template <> |
| 283 | void RegisterMethods<SBAddress>(Registry &R) { |
| 284 | LLDB_REGISTER_CONSTRUCTOR(SBAddress, ()); |
| 285 | LLDB_REGISTER_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &)); |
| 286 | LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t)); |
| 287 | LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &)); |
| 288 | LLDB_REGISTER_METHOD(const lldb::SBAddress &, |
| 289 | SBAddress, operator=,(const lldb::SBAddress &)); |
Pavel Labath | 4bc0500 | 2019-04-02 10:18:46 +0000 | [diff] [blame] | 290 | LLDB_REGISTER_METHOD_CONST(bool, |
| 291 | SBAddress, operator!=,(const lldb::SBAddress &)); |
Michal Gorny | ae211ec | 2019-03-19 17:13:13 +0000 | [diff] [blame] | 292 | LLDB_REGISTER_METHOD_CONST(bool, SBAddress, IsValid, ()); |
| 293 | LLDB_REGISTER_METHOD_CONST(bool, SBAddress, operator bool, ()); |
| 294 | LLDB_REGISTER_METHOD(void, SBAddress, Clear, ()); |
| 295 | LLDB_REGISTER_METHOD(void, SBAddress, SetAddress, |
| 296 | (lldb::SBSection, lldb::addr_t)); |
| 297 | LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetFileAddress, ()); |
| 298 | LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress, |
| 299 | (const lldb::SBTarget &)); |
| 300 | LLDB_REGISTER_METHOD(void, SBAddress, SetLoadAddress, |
| 301 | (lldb::addr_t, lldb::SBTarget &)); |
| 302 | LLDB_REGISTER_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t)); |
| 303 | LLDB_REGISTER_METHOD(lldb::SBSection, SBAddress, GetSection, ()); |
| 304 | LLDB_REGISTER_METHOD(lldb::addr_t, SBAddress, GetOffset, ()); |
| 305 | LLDB_REGISTER_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &)); |
| 306 | LLDB_REGISTER_METHOD(lldb::SBModule, SBAddress, GetModule, ()); |
| 307 | LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext, |
| 308 | (uint32_t)); |
| 309 | LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBAddress, GetCompileUnit, ()); |
| 310 | LLDB_REGISTER_METHOD(lldb::SBFunction, SBAddress, GetFunction, ()); |
| 311 | LLDB_REGISTER_METHOD(lldb::SBBlock, SBAddress, GetBlock, ()); |
| 312 | LLDB_REGISTER_METHOD(lldb::SBSymbol, SBAddress, GetSymbol, ()); |
| 313 | LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBAddress, GetLineEntry, ()); |
| 314 | } |
| 315 | |
| 316 | } |
| 317 | } |