[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- SBAddress.cpp -----------------------------------------------------===//
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08: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-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBAddress.h"
|
2019-03-06 08:06:00 +08:00
|
|
|
#include "SBReproducerPrivate.h"
|
2019-03-06 08:05:55 +08:00
|
|
|
#include "Utils.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBProcess.h"
|
2011-09-24 08:52:29 +08:00
|
|
|
#include "lldb/API/SBSection.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Core/Address.h"
|
2011-03-31 09:08:07 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2015-03-04 03:23:09 +08:00
|
|
|
#include "lldb/Symbol/LineEntry.h"
|
2010-12-21 04:49:23 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-10-26 11:11:13 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
SBAddress::SBAddress() : m_opaque_up(new Address()) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress);
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2020-09-26 02:15:44 +08:00
|
|
|
SBAddress::SBAddress(const Address &address)
|
|
|
|
: m_opaque_up(std::make_unique<Address>(address)) {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-04 10:58:17 +08:00
|
|
|
SBAddress::SBAddress(lldb::SBSection section, lldb::addr_t offset)
|
2019-03-06 08:06:00 +08:00
|
|
|
: m_opaque_up(new Address(section.GetSP(), offset)) {
|
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t), section,
|
|
|
|
offset);
|
|
|
|
}
|
2012-02-04 10:58:17 +08:00
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
// Create an address by resolving a load address using the supplied target
|
|
|
|
SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target)
|
2019-02-13 14:25:41 +08:00
|
|
|
: m_opaque_up(new Address()) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &),
|
|
|
|
load_addr, target);
|
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
SetLoadAddress(load_addr, target);
|
|
|
|
}
|
|
|
|
|
2020-02-18 14:57:06 +08:00
|
|
|
SBAddress::~SBAddress() = default;
|
2011-07-23 00:46:35 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const SBAddress &SBAddress::operator=(const SBAddress &rhs) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(const lldb::SBAddress &,
|
|
|
|
SBAddress, operator=,(const lldb::SBAddress &), rhs);
|
|
|
|
|
2019-03-06 08:05:55 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2019-04-04 05:31:22 +08:00
|
|
|
return LLDB_RECORD_RESULT(*this);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2017-05-04 19:34:42 +08: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 18:18:46 +08:00
|
|
|
bool SBAddress::operator!=(const SBAddress &rhs) const {
|
|
|
|
LLDB_RECORD_METHOD_CONST(bool, SBAddress, operator!=,(const SBAddress &),
|
|
|
|
&rhs);
|
|
|
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool SBAddress::IsValid() const {
|
2019-03-06 08:06:00 +08: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 21:58:46 +08:00
|
|
|
return this->operator bool();
|
|
|
|
}
|
|
|
|
SBAddress::operator bool() const {
|
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool);
|
2019-03-06 08:06:00 +08:00
|
|
|
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
return m_opaque_up != nullptr && m_opaque_up->IsValid();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 08:06:00 +08:00
|
|
|
void SBAddress::Clear() {
|
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear);
|
|
|
|
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<Address>();
|
2019-03-06 08:06:00 +08:00
|
|
|
}
|
2010-09-11 02:31:35 +08:00
|
|
|
|
2012-02-04 10:58:17 +08:00
|
|
|
void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBAddress, SetAddress,
|
|
|
|
(lldb::SBSection, lldb::addr_t), section, offset);
|
|
|
|
|
2012-02-04 10:58:17 +08:00
|
|
|
Address &addr = ref();
|
2012-02-24 09:59:29 +08:00
|
|
|
addr.SetSection(section.GetSP());
|
2012-02-04 10:58:17 +08:00
|
|
|
addr.SetOffset(offset);
|
|
|
|
}
|
|
|
|
|
2020-09-26 02:15:44 +08:00
|
|
|
void SBAddress::SetAddress(const Address &address) { ref() = address; }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
lldb::addr_t SBAddress::GetFileAddress() const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
return m_opaque_up->GetFileAddress();
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
|
|
|
}
|
|
|
|
|
2010-09-15 07:36:40 +08:00
|
|
|
lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress,
|
|
|
|
(const lldb::SBTarget &), target);
|
|
|
|
|
2014-04-04 12:06:10 +08:00
|
|
|
lldb::addr_t addr = LLDB_INVALID_ADDRESS;
|
|
|
|
TargetSP target_sp(target.GetSP());
|
|
|
|
if (target_sp) {
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid()) {
|
2014-04-04 12:06:10 +08:00
|
|
|
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
|
2019-02-13 14:25:41 +08:00
|
|
|
addr = m_opaque_up->GetLoadAddress(target_sp.get());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-12-21 04:49:23 +08:00
|
|
|
|
|
|
|
return addr;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
|
2010-12-21 04:49:23 +08:00
|
|
|
void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(void, SBAddress, SetLoadAddress,
|
|
|
|
(lldb::addr_t, lldb::SBTarget &), load_addr, target);
|
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
// Create the address object if we don't already have one
|
2016-09-07 04:57:50 +08:00
|
|
|
ref();
|
2014-11-01 05:30:59 +08:00
|
|
|
if (target.IsValid())
|
2011-07-23 00:46:35 +08:00
|
|
|
*this = target.ResolveLoadAddress(load_addr);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Clear();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2018-05-01 00:49:04 +08: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 14:25:41 +08:00
|
|
|
if (!m_opaque_up->IsValid())
|
|
|
|
m_opaque_up->SetOffset(load_addr);
|
2011-07-23 00:46:35 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool SBAddress::OffsetAddress(addr_t offset) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t), offset);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid()) {
|
|
|
|
addr_t addr_offset = m_opaque_up->GetOffset();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (addr_offset != LLDB_INVALID_ADDRESS) {
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->SetOffset(addr_offset + offset);
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
lldb::SBSection SBAddress::GetSection() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBAddress, GetSection);
|
|
|
|
|
2011-09-24 08:52:29 +08:00
|
|
|
lldb::SBSection sb_section;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_section.SetSP(m_opaque_up->GetSection());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_section);
|
2011-09-24 08:52:29 +08:00
|
|
|
}
|
|
|
|
|
2012-01-29 14:07:39 +08:00
|
|
|
lldb::addr_t SBAddress::GetOffset() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBAddress, GetOffset);
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
return m_opaque_up->GetOffset();
|
2012-01-29 14:07:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2011-09-24 08:52:29 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
Address *SBAddress::operator->() { return m_opaque_up.get(); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
const Address *SBAddress::operator->() const { return m_opaque_up.get(); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
Address &SBAddress::ref() {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
if (m_opaque_up == nullptr)
|
2020-06-25 07:25:05 +08:00
|
|
|
m_opaque_up = std::make_unique<Address>();
|
2019-02-13 14:25:41 +08:00
|
|
|
return *m_opaque_up;
|
2010-09-11 02:31:35 +08:00
|
|
|
}
|
|
|
|
|
2011-07-23 00:46:35 +08:00
|
|
|
const Address &SBAddress::ref() const {
|
2018-05-01 00:49:04 +08: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 14:25:41 +08:00
|
|
|
assert(m_opaque_up.get());
|
|
|
|
return *m_opaque_up;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
Address *SBAddress::get() { return m_opaque_up.get(); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool SBAddress::GetDescription(SBStream &description) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &),
|
|
|
|
description);
|
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
// Call "ref()" on the stream to make sure it creates a backing stream in
|
|
|
|
// case there isn't one already...
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid()) {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
m_opaque_up->Dump(&strm, nullptr, Address::DumpStyleResolvedDescription,
|
2012-04-05 04:36:48 +08:00
|
|
|
Address::DumpStyleModuleWithFileAddress, 4);
|
2010-09-20 13:20:02 +08:00
|
|
|
} else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString("No value");
|
2010-09-20 13:20:02 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-03-31 09:08:07 +08:00
|
|
|
|
|
|
|
SBModule SBAddress::GetModule() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBAddress, GetModule);
|
|
|
|
|
2011-03-31 09:08:07 +08:00
|
|
|
SBModule sb_module;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_module.SetSP(m_opaque_up->GetModule());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_module);
|
2011-03-31 09:08:07 +08:00
|
|
|
}
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext,
|
|
|
|
(uint32_t), resolve_scope);
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBSymbolContext sb_sc;
|
2018-10-26 04:45:19 +08:00
|
|
|
SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
m_opaque_up->CalculateSymbolContext(&sb_sc.ref(), scope);
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_sc);
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBCompileUnit SBAddress::GetCompileUnit() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBAddress, GetCompileUnit);
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBCompileUnit sb_comp_unit;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_comp_unit.reset(m_opaque_up->CalculateSymbolContextCompileUnit());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_comp_unit);
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBFunction SBAddress::GetFunction() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBAddress, GetFunction);
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBFunction sb_function;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_function.reset(m_opaque_up->CalculateSymbolContextFunction());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_function);
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBBlock SBAddress::GetBlock() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBAddress, GetBlock);
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBBlock sb_block;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_block.SetPtr(m_opaque_up->CalculateSymbolContextBlock());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_block);
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBSymbol SBAddress::GetSymbol() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBAddress, GetSymbol);
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBSymbol sb_symbol;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid())
|
|
|
|
sb_symbol.reset(m_opaque_up->CalculateSymbolContextSymbol());
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_symbol);
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBLineEntry SBAddress::GetLineEntry() {
|
2019-03-06 08:06:00 +08:00
|
|
|
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBAddress, GetLineEntry);
|
|
|
|
|
2011-08-13 05:40:01 +08:00
|
|
|
SBLineEntry sb_line_entry;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->IsValid()) {
|
2011-08-13 05:40:01 +08:00
|
|
|
LineEntry line_entry;
|
2019-02-13 14:25:41 +08:00
|
|
|
if (m_opaque_up->CalculateSymbolContextLineEntry(line_entry))
|
2011-08-13 05:40:01 +08:00
|
|
|
sb_line_entry.SetLineEntry(line_entry);
|
|
|
|
}
|
2019-03-06 08:06:00 +08:00
|
|
|
return LLDB_RECORD_RESULT(sb_line_entry);
|
2011-08-13 05:40:01 +08:00
|
|
|
}
|
2019-03-20 01:13:13 +08: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 18:18:46 +08:00
|
|
|
LLDB_REGISTER_METHOD_CONST(bool,
|
|
|
|
SBAddress, operator!=,(const lldb::SBAddress &));
|
2019-03-20 01:13:13 +08: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, ());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|