2010-06-08 16:52:24 +00:00
|
|
|
//===-- SBAddress.cpp -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBAddress.h"
|
2019-03-06 00:06:00 +00:00
|
|
|
#include "SBReproducerPrivate.h"
|
2019-03-06 00:05:55 +00:00
|
|
|
#include "Utils.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2011-09-24 00:52:29 +00:00
|
|
|
#include "lldb/API/SBSection.h"
|
2010-09-20 05:20:02 +00:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Core/Address.h"
|
2011-03-31 01:08:07 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
2015-03-03 19:23:09 +00:00
|
|
|
#include "lldb/Symbol/LineEntry.h"
|
2010-12-20 20:49:23 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-10-26 03:11:13 +00:00
|
|
|
using namespace lldb_private;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
SBAddress::SBAddress() : m_opaque_up(new Address()) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress);
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBAddress::SBAddress(const Address *lldb_object_ptr)
|
2019-02-13 06:25:41 +00:00
|
|
|
: m_opaque_up(new Address()) {
|
2016-09-06 20:57:50 +00:00
|
|
|
if (lldb_object_ptr)
|
2019-03-06 00:05:55 +00:00
|
|
|
m_opaque_up = llvm::make_unique<Address>(*lldb_object_ptr);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs);
|
|
|
|
|
2019-03-06 00:05:55 +00:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBAddress::SBAddress(lldb::SBSection section, lldb::addr_t offset)
|
2019-03-06 00:06:00 +00:00
|
|
|
: m_opaque_up(new Address(section.GetSP(), offset)) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t), section,
|
|
|
|
offset);
|
|
|
|
}
|
2012-02-04 02:58:17 +00:00
|
|
|
|
2011-07-22 16:46:35 +00:00
|
|
|
// Create an address by resolving a load address using the supplied target
|
2016-09-06 20:57:50 +00:00
|
|
|
SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target)
|
2019-02-13 06:25:41 +00:00
|
|
|
: m_opaque_up(new Address()) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &),
|
|
|
|
load_addr, target);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SetLoadAddress(load_addr, target);
|
2011-07-22 16:46:35 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBAddress::~SBAddress() {}
|
2011-07-22 16:46:35 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
const SBAddress &SBAddress::operator=(const SBAddress &rhs) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBAddress &,
|
|
|
|
SBAddress, operator=,(const lldb::SBAddress &), rhs);
|
|
|
|
|
2019-03-06 00:05:55 +00:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2016-09-06 20:57:50 +00:00
|
|
|
return *this;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 11:34:42 +00:00
|
|
|
bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
|
|
|
|
if (lhs.IsValid() && rhs.IsValid())
|
|
|
|
return lhs.ref() == rhs.ref();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Make operator==s consistent between c++ and python APIs
Summary:
modify-python-lldb.py had code to insert python equality operators to
some classes. Some of those classes already had c++ equality operators,
and some didn't.
This makes the situation more consistent, by removing all equality
handilng from modify-python-lldb. Instead, I add c++ operators to
classes where they were missing, and expose them in the swig interface
files so that they are available to python too.
The only tricky case was the SBAddress class, which had an operator==
defined as a free function, which is not handled by swig. This function
cannot be removed without breaking ABI, and we cannot add an extra
operator== member, as that would make equality comparisons ambiguous.
For this class, I define a python __eq__ function by hand and have it
delegate to the operator!=, which I have defined as a member function.
This isn't fully NFC, as the semantics of some equality functions in
python changes slightly, but I believe it changes for the better (e.g.,
previously SBBreakpoint.__eq__ would consider two breakpoints with the
same ID as equal, even if they belonged to different targets; now they
are only equal if they belong to the same target).
Reviewers: jingham, clayborg, zturner
Subscribers: jdoerfert, JDevlieghere, lldb-commits
Differential Revision: https://reviews.llvm.org/D59819
llvm-svn: 357463
2019-04-02 10:18:46 +00:00
|
|
|
bool SBAddress::operator!=(const SBAddress &rhs) const {
|
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBAddress, operator!=,(const SBAddress &),
|
|
|
|
&rhs);
|
|
|
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
bool SBAddress::IsValid() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, IsValid);
|
Add "operator bool" to SB APIs
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.
This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.
In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.
Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille
Subscribers: jdoerfert, lldb-commits
Differential Revision: https://reviews.llvm.org/D58792
llvm-svn: 355824
2019-03-11 13:58:46 +00:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBAddress::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool);
|
2019-03-06 00:06:00 +00:00
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
return m_opaque_up != NULL && m_opaque_up->IsValid();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2019-03-06 00:06:00 +00:00
|
|
|
void SBAddress::Clear() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear);
|
|
|
|
|
|
|
|
m_opaque_up.reset(new Address());
|
|
|
|
}
|
2010-09-10 18:31:35 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBAddress, SetAddress,
|
|
|
|
(lldb::SBSection, lldb::addr_t), section, offset);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
Address &addr = ref();
|
|
|
|
addr.SetSection(section.GetSP());
|
|
|
|
addr.SetOffset(offset);
|
2012-02-04 02:58:17 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
void SBAddress::SetAddress(const Address *lldb_object_ptr) {
|
|
|
|
if (lldb_object_ptr)
|
|
|
|
ref() = *lldb_object_ptr;
|
|
|
|
else
|
2019-02-13 06:25:41 +00:00
|
|
|
m_opaque_up.reset(new Address());
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldb::addr_t SBAddress::GetFileAddress() const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress);
|
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
return m_opaque_up->GetFileAddress();
|
2016-09-06 20:57:50 +00:00
|
|
|
else
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress,
|
|
|
|
(const lldb::SBTarget &), target);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldb::addr_t addr = LLDB_INVALID_ADDRESS;
|
|
|
|
TargetSP target_sp(target.GetSP());
|
|
|
|
if (target_sp) {
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid()) {
|
2016-09-06 20:57:50 +00:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2019-02-13 06:25:41 +00:00
|
|
|
addr = m_opaque_up->GetLoadAddress(target_sp.get());
|
2010-10-26 03:11:13 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-12-20 20:49:23 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(void, SBAddress, SetLoadAddress,
|
|
|
|
(lldb::addr_t, lldb::SBTarget &), load_addr, target);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
// Create the address object if we don't already have one
|
|
|
|
ref();
|
|
|
|
if (target.IsValid())
|
|
|
|
*this = target.ResolveLoadAddress(load_addr);
|
|
|
|
else
|
2019-02-13 06:25:41 +00:00
|
|
|
m_opaque_up->Clear();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Check if we weren't were able to resolve a section offset address. If we
|
|
|
|
// weren't it is ok, the load address might be a location on the stack or
|
|
|
|
// heap, so we should just have an address with no section and a valid offset
|
2019-02-13 06:25:41 +00:00
|
|
|
if (!m_opaque_up->IsValid())
|
|
|
|
m_opaque_up->SetOffset(load_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SBAddress::OffsetAddress(addr_t offset) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t), offset);
|
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid()) {
|
|
|
|
addr_t addr_offset = m_opaque_up->GetOffset();
|
2016-09-06 20:57:50 +00:00
|
|
|
if (addr_offset != LLDB_INVALID_ADDRESS) {
|
2019-02-13 06:25:41 +00:00
|
|
|
m_opaque_up->SetOffset(addr_offset + offset);
|
2016-09-06 20:57:50 +00:00
|
|
|
return true;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
return false;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldb::SBSection SBAddress::GetSection() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBAddress, GetSection);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldb::SBSection sb_section;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_section.SetSP(m_opaque_up->GetSection());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_section);
|
2011-09-24 00:52:29 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
lldb::addr_t SBAddress::GetOffset() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBAddress, GetOffset);
|
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
return m_opaque_up->GetOffset();
|
2016-09-06 20:57:50 +00:00
|
|
|
return 0;
|
2012-01-29 06:07:39 +00:00
|
|
|
}
|
2011-09-24 00:52:29 +00:00
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
Address *SBAddress::operator->() { return m_opaque_up.get(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
const Address *SBAddress::operator->() const { return m_opaque_up.get(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
Address &SBAddress::ref() {
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up == NULL)
|
|
|
|
m_opaque_up.reset(new Address());
|
|
|
|
return *m_opaque_up;
|
2010-09-10 18:31:35 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
const Address &SBAddress::ref() const {
|
2018-04-30 16:49:04 +00:00
|
|
|
// This object should already have checked with "IsValid()" prior to calling
|
|
|
|
// this function. In case you didn't we will assert and die to let you know.
|
2019-02-13 06:25:41 +00:00
|
|
|
assert(m_opaque_up.get());
|
|
|
|
return *m_opaque_up;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
2019-02-13 06:25:41 +00:00
|
|
|
Address *SBAddress::get() { return m_opaque_up.get(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
bool SBAddress::GetDescription(SBStream &description) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &),
|
|
|
|
description);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
// Call "ref()" on the stream to make sure it creates a backing stream in
|
|
|
|
// case there isn't one already...
|
|
|
|
Stream &strm = description.ref();
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid()) {
|
|
|
|
m_opaque_up->Dump(&strm, NULL, Address::DumpStyleResolvedDescription,
|
2016-09-06 20:57:50 +00:00
|
|
|
Address::DumpStyleModuleWithFileAddress, 4);
|
|
|
|
StreamString sstrm;
|
2019-02-13 06:25:41 +00:00
|
|
|
// m_opaque_up->Dump (&sstrm, NULL,
|
2016-09-06 20:57:50 +00:00
|
|
|
// Address::DumpStyleResolvedDescription, Address::DumpStyleInvalid,
|
|
|
|
// 4);
|
|
|
|
// if (sstrm.GetData())
|
|
|
|
// strm.Printf (" (%s)", sstrm.GetData());
|
|
|
|
} else
|
|
|
|
strm.PutCString("No value");
|
2010-09-20 05:20:02 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
return true;
|
2010-09-20 05:20:02 +00:00
|
|
|
}
|
2011-03-31 01:08:07 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBModule SBAddress::GetModule() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBAddress, GetModule);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBModule sb_module;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_module.SetSP(m_opaque_up->GetModule());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_module);
|
2011-03-31 01:08:07 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext,
|
|
|
|
(uint32_t), resolve_scope);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBSymbolContext sb_sc;
|
2018-10-25 20:45:19 +00:00
|
|
|
SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
m_opaque_up->CalculateSymbolContext(&sb_sc.ref(), scope);
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc);
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBCompileUnit SBAddress::GetCompileUnit() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBAddress, GetCompileUnit);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBCompileUnit sb_comp_unit;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_comp_unit.reset(m_opaque_up->CalculateSymbolContextCompileUnit());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_comp_unit);
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBFunction SBAddress::GetFunction() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBAddress, GetFunction);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBFunction sb_function;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_function.reset(m_opaque_up->CalculateSymbolContextFunction());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_function);
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBBlock SBAddress::GetBlock() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBAddress, GetBlock);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBBlock sb_block;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_block.SetPtr(m_opaque_up->CalculateSymbolContextBlock());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_block);
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBSymbol SBAddress::GetSymbol() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBAddress, GetSymbol);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBSymbol sb_symbol;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_symbol.reset(m_opaque_up->CalculateSymbolContextSymbol());
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_symbol);
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBLineEntry SBAddress::GetLineEntry() {
|
2019-03-06 00:06:00 +00:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBAddress, GetLineEntry);
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
SBLineEntry sb_line_entry;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->IsValid()) {
|
2016-09-06 20:57:50 +00:00
|
|
|
LineEntry line_entry;
|
2019-02-13 06:25:41 +00:00
|
|
|
if (m_opaque_up->CalculateSymbolContextLineEntry(line_entry))
|
2016-09-06 20:57:50 +00:00
|
|
|
sb_line_entry.SetLineEntry(line_entry);
|
|
|
|
}
|
2019-03-06 00:06:00 +00:00
|
|
|
return LLDB_RECORD_RESULT(sb_line_entry);
|
2011-08-12 21:40:01 +00:00
|
|
|
}
|
2019-03-19 17:13:13 +00:00
|
|
|
|
|
|
|
namespace lldb_private {
|
|
|
|
namespace repro {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void RegisterMethods<SBAddress>(Registry &R) {
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBAddress, ());
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t));
|
|
|
|
LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &));
|
|
|
|
LLDB_REGISTER_METHOD(const lldb::SBAddress &,
|
|
|
|
SBAddress, operator=,(const lldb::SBAddress &));
|
Make operator==s consistent between c++ and python APIs
Summary:
modify-python-lldb.py had code to insert python equality operators to
some classes. Some of those classes already had c++ equality operators,
and some didn't.
This makes the situation more consistent, by removing all equality
handilng from modify-python-lldb. Instead, I add c++ operators to
classes where they were missing, and expose them in the swig interface
files so that they are available to python too.
The only tricky case was the SBAddress class, which had an operator==
defined as a free function, which is not handled by swig. This function
cannot be removed without breaking ABI, and we cannot add an extra
operator== member, as that would make equality comparisons ambiguous.
For this class, I define a python __eq__ function by hand and have it
delegate to the operator!=, which I have defined as a member function.
This isn't fully NFC, as the semantics of some equality functions in
python changes slightly, but I believe it changes for the better (e.g.,
previously SBBreakpoint.__eq__ would consider two breakpoints with the
same ID as equal, even if they belonged to different targets; now they
are only equal if they belong to the same target).
Reviewers: jingham, clayborg, zturner
Subscribers: jdoerfert, JDevlieghere, lldb-commits
Differential Revision: https://reviews.llvm.org/D59819
llvm-svn: 357463
2019-04-02 10:18:46 +00:00
|
|
|
LLDB_REGISTER_METHOD_CONST(bool,
|
|
|
|
SBAddress, operator!=,(const lldb::SBAddress &));
|
2019-03-19 17:13:13 +00:00
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBAddress, IsValid, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(bool, SBAddress, operator bool, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBAddress, Clear, ());
|
|
|
|
LLDB_REGISTER_METHOD(void, SBAddress, SetAddress,
|
|
|
|
(lldb::SBSection, lldb::addr_t));
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetFileAddress, ());
|
|
|
|
LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress,
|
|
|
|
(const lldb::SBTarget &));
|
|
|
|
LLDB_REGISTER_METHOD(void, SBAddress, SetLoadAddress,
|
|
|
|
(lldb::addr_t, lldb::SBTarget &));
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSection, SBAddress, GetSection, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::addr_t, SBAddress, GetOffset, ());
|
|
|
|
LLDB_REGISTER_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBModule, SBAddress, GetModule, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext,
|
|
|
|
(uint32_t));
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBAddress, GetCompileUnit, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBFunction, SBAddress, GetFunction, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBBlock, SBAddress, GetBlock, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBSymbol, SBAddress, GetSymbol, ());
|
|
|
|
LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBAddress, GetLineEntry, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|