-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Add AddressRange to SB API #92014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add AddressRange to SB API #92014
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 { | ||
mbucko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#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 | ||
bulbazord marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stream = lldb.SBStream() | ||
self.GetDescription(stream, lldb.target if lldb.target else lldb.SBTarget()) | ||
return stream.GetData() | ||
%} | ||
mbucko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
mbucko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// 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 hidden or 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); | ||
bulbazord marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.