llvm-project/lldb/source/Core/AddressRangeListImpl.cpp
Pavel Labath 59bb9b915e
[lldb] Expose discontinuous functions through SBFunction::GetRanges (#117532)
SBFunction::GetEndAddress doesn't really make sense for discontinuous
functions, so I'm declaring it deprecated. GetStartAddress sort of makes
sense, if one uses it to find the functions entry point, so I'm keeping
that undeprecated.

I've made the test a Shell tests because these make it easier to create
discontinuous functions regardless of the host os and architecture. They
do make testing the python API harder, but I think I've managed to come
up with something not entirely unreasonable.
2024-12-03 10:14:33 +01:00

43 lines
1.2 KiB
C++

//===-- AddressRangeListImpl.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/Core/AddressRangeListImpl.h"
using namespace lldb;
using namespace lldb_private;
AddressRangeListImpl::AddressRangeListImpl() : m_ranges() {}
size_t AddressRangeListImpl::GetSize() const { return m_ranges.size(); }
void AddressRangeListImpl::Reserve(size_t capacity) {
m_ranges.reserve(capacity);
}
void AddressRangeListImpl::Append(const AddressRange &sb_region) {
m_ranges.emplace_back(sb_region);
}
void AddressRangeListImpl::Append(const AddressRangeListImpl &list) {
Reserve(GetSize() + list.GetSize());
for (const auto &range : list.m_ranges)
Append(range);
}
void AddressRangeListImpl::Clear() { m_ranges.clear(); }
lldb_private::AddressRange
AddressRangeListImpl::GetAddressRangeAtIndex(size_t index) {
if (index >= GetSize())
return AddressRange();
return m_ranges[index];
}
AddressRanges &AddressRangeListImpl::ref() { return m_ranges; }