forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SBAddressRange and SBAddressRangeList to SB API (llvm#92014)
This adds new SB API calls and classes to allow a user of the SB API to obtain an address ranges from SBFunction and SBBlock.
- Loading branch information
Showing
31 changed files
with
859 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,11 @@ | ||
%extend lldb::SBAddressRange { | ||
#ifdef SWIGPYTHON | ||
%pythoncode%{ | ||
def __repr__(self): | ||
import lldb | ||
stream = lldb.SBStream() | ||
self.GetDescription(stream, lldb.target if lldb.target else lldb.SBTarget()) | ||
return stream.GetData() | ||
%} | ||
#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
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,29 @@ | ||
%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') | ||
|
||
def __getitem__(self, idx): | ||
'''Get the address range at a given index in an lldb.SBAddressRangeList object.''' | ||
if not isinstance(idx, int): | ||
raise TypeError("unsupported index type: %s" % type(idx)) | ||
count = len(self) | ||
if not (-count <= idx < count): | ||
raise IndexError("list index out of range") | ||
idx %= count | ||
return self.GetAddressRangeAtIndex(idx) | ||
|
||
def __repr__(self): | ||
import lldb | ||
stream = lldb.SBStream() | ||
self.GetDescription(stream, lldb.target if lldb.target else lldb.SBTarget()) | ||
return stream.GetData() | ||
%} | ||
#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,66 @@ | ||
//===-- 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::SBAddress addr, lldb::addr_t byte_size); | ||
|
||
~SBAddressRange(); | ||
|
||
const lldb::SBAddressRange &operator=(const lldb::SBAddressRange &rhs); | ||
|
||
void Clear(); | ||
|
||
/// Check the address range refers to a valid base address and has a byte | ||
/// size greater than zero. | ||
/// | ||
/// \return | ||
/// True if the address range is valid, false otherwise. | ||
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; | ||
|
||
bool operator==(const SBAddressRange &rhs); | ||
|
||
bool operator!=(const SBAddressRange &rhs); | ||
|
||
bool GetDescription(lldb::SBStream &description, const SBTarget target); | ||
|
||
private: | ||
friend class SBAddressRangeList; | ||
friend class SBBlock; | ||
friend class SBFunction; | ||
friend class SBProcess; | ||
|
||
AddressRangeUP m_opaque_up; | ||
}; | ||
|
||
} // 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,54 @@ | ||
//===-- 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" | ||
|
||
namespace lldb_private { | ||
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(); | ||
|
||
SBAddressRange GetAddressRangeAtIndex(uint64_t idx); | ||
|
||
void Append(const lldb::SBAddressRange &addr_range); | ||
|
||
void Append(const lldb::SBAddressRangeList &addr_range_list); | ||
|
||
bool GetDescription(lldb::SBStream &description, const SBTarget &target); | ||
|
||
private: | ||
friend class SBBlock; | ||
friend class SBProcess; | ||
|
||
std::unique_ptr<lldb_private::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,51 @@ | ||
//===-- AddressRangeListImpl.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_CORE_ADDRESSRANGELISTIMPL_H | ||
#define LLDB_CORE_ADDRESSRANGELISTIMPL_H | ||
|
||
#include "lldb/Core/AddressRange.h" | ||
#include <cstddef> | ||
|
||
namespace lldb { | ||
class SBBlock; | ||
} | ||
|
||
namespace lldb_private { | ||
|
||
class AddressRangeListImpl { | ||
public: | ||
AddressRangeListImpl(); | ||
|
||
AddressRangeListImpl(const AddressRangeListImpl &rhs) = default; | ||
|
||
AddressRangeListImpl &operator=(const AddressRangeListImpl &rhs); | ||
|
||
size_t GetSize() const; | ||
|
||
void Reserve(size_t capacity); | ||
|
||
void Append(const AddressRange &sb_region); | ||
|
||
void Append(const AddressRangeListImpl &list); | ||
|
||
void Clear(); | ||
|
||
lldb_private::AddressRange GetAddressRangeAtIndex(size_t index); | ||
|
||
private: | ||
friend class lldb::SBBlock; | ||
|
||
AddressRanges &ref(); | ||
|
||
AddressRanges m_ranges; | ||
}; | ||
|
||
} // namespace lldb_private | ||
|
||
#endif // LLDB_CORE_ADDRESSRANGE_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
Oops, something went wrong.