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