-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This adds new SB API calls and classes to allow a user of the SB API to obtain an address range from SBFunction and SBBlock. Test Plan: Reviewers: clayborg Subscribers: lldb-commits Tasks: Tags:
- Loading branch information
Showing
23 changed files
with
533 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%feature("docstring", | ||
"API clients can get address range information." | ||
) lldb::SBAddressRange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
%feature("docstring", | ||
"Represents a list of :py:class:`SBAddressRange`." | ||
) lldb::SBAddressRangeList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%extend lldb::SBAddressRangeList { | ||
#ifdef SWIGPYTHON | ||
%pythoncode%{ | ||
def __len__(self): | ||
'''Return the number of address ranges in a lldb.SBAddressRangeList object.''' | ||
return self.GetSize() | ||
|
||
def __iter__(self): | ||
'''Iterate over all the address ranges in a lldb.SBAddressRangeList object.''' | ||
return lldb_iter(self, 'GetSize', 'GetAddressRangeAtIndex') | ||
%} | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//===-- SBAddressRange.h ----------------------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_API_SBADDRESSRANGE_H | ||
#define LLDB_API_SBADDRESSRANGE_H | ||
|
||
#include "lldb/API/SBDefines.h" | ||
|
||
namespace lldb { | ||
|
||
class LLDB_API SBAddressRange { | ||
public: | ||
SBAddressRange(); | ||
|
||
SBAddressRange(const lldb::SBAddressRange &rhs); | ||
|
||
SBAddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size); | ||
|
||
~SBAddressRange(); | ||
|
||
const lldb::SBAddressRange &operator=(const lldb::SBAddressRange &rhs); | ||
|
||
void Clear(); | ||
|
||
bool IsValid() const; | ||
|
||
/// Get the base address of the range. | ||
/// | ||
/// \return | ||
/// Base address object. | ||
lldb::SBAddress GetBaseAddress() const; | ||
|
||
/// Get the byte size of this range. | ||
/// | ||
/// \return | ||
/// The size in bytes of this address range. | ||
lldb::addr_t GetByteSize() const; | ||
|
||
protected: | ||
friend class SBAddressRangeList; | ||
friend class SBBlock; | ||
friend class SBFunction; | ||
|
||
lldb_private::AddressRange &ref(); | ||
|
||
const lldb_private::AddressRange &ref() const; | ||
|
||
private: | ||
AddressRangeUP m_opaque_up; | ||
}; | ||
|
||
#ifndef SWIG | ||
bool LLDB_API operator==(const SBAddressRange &lhs, const SBAddressRange &rhs); | ||
#endif | ||
|
||
} // namespace lldb | ||
|
||
#endif // LLDB_API_SBADDRESSRANGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//===-- SBAddressRangeList.h ------------------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLDB_API_SBADDRESSRANGELIST_H | ||
#define LLDB_API_SBADDRESSRANGELIST_H | ||
|
||
#include <memory> | ||
|
||
#include "lldb/API/SBDefines.h" | ||
|
||
class AddressRangeListImpl; | ||
|
||
namespace lldb { | ||
|
||
class LLDB_API SBAddressRangeList { | ||
public: | ||
SBAddressRangeList(); | ||
|
||
SBAddressRangeList(const lldb::SBAddressRangeList &rhs); | ||
|
||
~SBAddressRangeList(); | ||
|
||
const lldb::SBAddressRangeList &operator=(const lldb::SBAddressRangeList &rhs); | ||
|
||
uint32_t GetSize() const; | ||
|
||
void Clear(); | ||
|
||
bool GetAddressRangeAtIndex(uint64_t idx, SBAddressRange &addr_range); | ||
|
||
void Append(const lldb::SBAddressRange &addr_range); | ||
|
||
void Append(const lldb::SBAddressRangeList &addr_range_list); | ||
|
||
protected: | ||
const AddressRangeListImpl *operator->() const; | ||
|
||
const AddressRangeListImpl &operator*() const; | ||
|
||
private: | ||
friend class SBProcess; | ||
|
||
lldb_private::AddressRanges &ref(); | ||
|
||
const lldb_private::AddressRanges &ref() const; | ||
|
||
std::unique_ptr<AddressRangeListImpl> m_opaque_up; | ||
}; | ||
|
||
} // namespace lldb | ||
|
||
#endif // LLDB_API_SBADDRESSRANGELIST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//===-- SBAddressRange.cpp ------------------------------------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "lldb/API/SBAddressRange.h" | ||
#include "lldb/API/SBAddress.h" | ||
#include "lldb/Core/AddressRange.h" | ||
#include "lldb/Utility/Instrumentation.h" | ||
#include "Utils.h" | ||
#include <cstddef> | ||
#include <memory> | ||
|
||
using namespace lldb; | ||
using namespace lldb_private; | ||
|
||
SBAddressRange::SBAddressRange() | ||
: m_opaque_up(std::make_unique<AddressRange>()) { | ||
LLDB_INSTRUMENT_VA(this); | ||
} | ||
|
||
SBAddressRange::SBAddressRange(const SBAddressRange &rhs) { | ||
LLDB_INSTRUMENT_VA(this, rhs); | ||
|
||
m_opaque_up = clone(rhs.m_opaque_up); | ||
} | ||
|
||
SBAddressRange::SBAddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size) | ||
: m_opaque_up(std::make_unique<AddressRange>(file_addr, byte_size)) { | ||
LLDB_INSTRUMENT_VA(this, file_addr, byte_size); | ||
} | ||
|
||
SBAddressRange::~SBAddressRange() = default; | ||
|
||
const SBAddressRange &SBAddressRange::operator=(const SBAddressRange &rhs) { | ||
LLDB_INSTRUMENT_VA(this, rhs); | ||
|
||
if (this != &rhs) | ||
m_opaque_up = clone(rhs.m_opaque_up); | ||
return *this; | ||
} | ||
|
||
void SBAddressRange::Clear() { | ||
LLDB_INSTRUMENT_VA(this); | ||
|
||
m_opaque_up.reset(); | ||
} | ||
|
||
bool SBAddressRange::IsValid() const { | ||
return m_opaque_up && m_opaque_up->IsValid(); | ||
} | ||
|
||
lldb::SBAddress SBAddressRange::GetBaseAddress() const { | ||
LLDB_INSTRUMENT_VA(this); | ||
|
||
assert(m_opaque_up.get() && "AddressRange is NULL"); | ||
return lldb::SBAddress(m_opaque_up->GetBaseAddress()); | ||
} | ||
|
||
lldb::addr_t SBAddressRange::GetByteSize() const { | ||
LLDB_INSTRUMENT_VA(this); | ||
|
||
assert(m_opaque_up.get() && "AddressRange is NULL"); | ||
return m_opaque_up->GetByteSize(); | ||
} | ||
|
||
AddressRange &SBAddressRange::ref() { | ||
assert(m_opaque_up.get() && "AddressRange is NULL"); | ||
return *m_opaque_up; | ||
} | ||
|
||
const AddressRange &SBAddressRange::ref() const { | ||
assert(m_opaque_up.get() && "AddressRange is NULL"); | ||
return *m_opaque_up; | ||
} |
Oops, something went wrong.