-
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: llvm-lit -sv llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py Reviewers: clayborg Subscribers: lldb-commits Tasks: Tags:
- Loading branch information
Showing
27 changed files
with
681 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 @@ | ||
STRING_EXTENSION_OUTSIDE(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,25 @@ | ||
STRING_EXTENSION_OUTSIDE(SBAddressRangeList) | ||
|
||
%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 type(idx) == int: | ||
if idx >= self.GetSize(): | ||
raise IndexError("list index out of range") | ||
return self.GetAddressRangeAtIndex(idx) | ||
else: | ||
print("error: unsupported idx type: %s" % type(key)) | ||
return None | ||
%} | ||
#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,65 @@ | ||
//===-- 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); | ||
|
||
private: | ||
friend class SBAddressRangeList; | ||
friend class SBBlock; | ||
friend class SBFunction; | ||
|
||
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,58 @@ | ||
//===-- 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(); | ||
|
||
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); | ||
|
||
private: | ||
const AddressRangeListImpl *operator->() const; | ||
|
||
const AddressRangeListImpl &operator*() const; | ||
|
||
friend class SBBlock; | ||
friend class SBProcess; | ||
|
||
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
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.