Skip to content

Commit a32b719

Browse files
Revert commits that add TestFind(Ranges)InMemory.py (llvm#96560)
Reverting to unblock macOS buildbots which are currently failing on these tests. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/6377/
1 parent 16903ac commit a32b719

File tree

11 files changed

+6
-660
lines changed

11 files changed

+6
-660
lines changed

lldb/bindings/python/python-typemaps.swig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ AND call SWIG_fail at the same time, because it will result in a double free.
257257
}
258258
// For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput.
259259
%typemap(in) (const void *buf, size_t size),
260-
(const void *data, size_t data_len),
261-
(const void *buf, uint64_t size) {
260+
(const void *data, size_t data_len) {
262261
if (PythonString::Check($input)) {
263262
PythonString str(PyRefType::Borrowed, $input);
264263
$1 = (void *)str.GetString().data();

lldb/include/lldb/API/SBProcess.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,6 @@ class LLDB_API SBProcess {
209209

210210
lldb::addr_t ReadPointerFromMemory(addr_t addr, lldb::SBError &error);
211211

212-
lldb::SBAddressRangeList FindRangesInMemory(const void *buf, uint64_t size,
213-
const SBAddressRangeList &ranges,
214-
uint32_t alignment,
215-
uint32_t max_matches,
216-
SBError &error);
217-
218-
lldb::addr_t FindInMemory(const void *buf, uint64_t size,
219-
const SBAddressRange &range, uint32_t alignment,
220-
SBError &error);
221-
222212
// Events
223213
static lldb::StateType GetStateFromEvent(const lldb::SBEvent &event);
224214

lldb/include/lldb/Core/AddressRangeListImpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#include <cstddef>
1414

1515
namespace lldb {
16-
class SBAddressRangeList;
1716
class SBBlock;
18-
class SBProcess;
1917
}
2018

2119
namespace lldb_private {
@@ -41,9 +39,7 @@ class AddressRangeListImpl {
4139
lldb_private::AddressRange GetAddressRangeAtIndex(size_t index);
4240

4341
private:
44-
friend class lldb::SBAddressRangeList;
4542
friend class lldb::SBBlock;
46-
friend class lldb::SBProcess;
4743

4844
AddressRanges &ref();
4945

lldb/include/lldb/Target/Process.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,15 +2685,6 @@ void PruneThreadPlans();
26852685
lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high,
26862686
const uint8_t *buf, size_t size);
26872687

2688-
AddressRanges FindRangesInMemory(const uint8_t *buf, uint64_t size,
2689-
const AddressRanges &ranges,
2690-
size_t alignment, size_t max_matches,
2691-
Status &error);
2692-
2693-
lldb::addr_t FindInMemory(const uint8_t *buf, uint64_t size,
2694-
const AddressRange &range, size_t alignment,
2695-
Status &error);
2696-
26972688
protected:
26982689
friend class Trace;
26992690

@@ -2809,11 +2800,6 @@ void PruneThreadPlans();
28092800
virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
28102801
Status &error) = 0;
28112802

2812-
virtual void DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr,
2813-
const uint8_t *buf, size_t size,
2814-
AddressRanges &matches, size_t alignment,
2815-
size_t max_matches);
2816-
28172803
/// DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has
28182804
/// removed non address bits from load_addr. Override this method in
28192805
/// subclasses of Process.

lldb/source/API/SBProcess.cpp

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "lldb/lldb-defines.h"
1515
#include "lldb/lldb-types.h"
1616

17-
#include "lldb/Core/AddressRangeListImpl.h"
1817
#include "lldb/Core/Debugger.h"
1918
#include "lldb/Core/Module.h"
2019
#include "lldb/Core/PluginManager.h"
@@ -27,7 +26,6 @@
2726
#include "lldb/Target/Target.h"
2827
#include "lldb/Target/Thread.h"
2928
#include "lldb/Utility/Args.h"
30-
#include "lldb/Utility/LLDBLog.h"
3129
#include "lldb/Utility/ProcessInfo.h"
3230
#include "lldb/Utility/State.h"
3331
#include "lldb/Utility/Stream.h"
@@ -322,8 +320,8 @@ void SBProcess::ReportEventState(const SBEvent &event, FileSP out) const {
322320
if (process_sp) {
323321
StreamFile stream(out);
324322
const StateType event_state = SBProcess::GetStateFromEvent(event);
325-
stream.Printf("Process %" PRIu64 " %s\n", process_sp->GetID(),
326-
SBDebugger::StateAsCString(event_state));
323+
stream.Printf("Process %" PRIu64 " %s\n",
324+
process_sp->GetID(), SBDebugger::StateAsCString(event_state));
327325
}
328326
}
329327

@@ -380,6 +378,7 @@ bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) {
380378
ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id);
381379
}
382380

381+
383382
return ret_val;
384383
}
385384

@@ -547,6 +546,7 @@ ByteOrder SBProcess::GetByteOrder() const {
547546
if (process_sp)
548547
byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
549548

549+
550550
return byteOrder;
551551
}
552552

@@ -558,6 +558,7 @@ uint32_t SBProcess::GetAddressByteSize() const {
558558
if (process_sp)
559559
size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
560560

561+
561562
return size;
562563
}
563564

@@ -809,55 +810,6 @@ const char *SBProcess::GetBroadcasterClass() {
809810
return ConstString(Process::GetStaticBroadcasterClass()).AsCString();
810811
}
811812

812-
lldb::SBAddressRangeList SBProcess::FindRangesInMemory(
813-
const void *buf, uint64_t size, const SBAddressRangeList &ranges,
814-
uint32_t alignment, uint32_t max_matches, SBError &error) {
815-
LLDB_INSTRUMENT_VA(this, buf, size, ranges, alignment, max_matches, error);
816-
817-
lldb::SBAddressRangeList matches;
818-
819-
ProcessSP process_sp(GetSP());
820-
if (!process_sp) {
821-
error.SetErrorString("SBProcess is invalid");
822-
return matches;
823-
}
824-
Process::StopLocker stop_locker;
825-
if (!stop_locker.TryLock(&process_sp->GetRunLock())) {
826-
error.SetErrorString("process is running");
827-
return matches;
828-
}
829-
std::lock_guard<std::recursive_mutex> guard(
830-
process_sp->GetTarget().GetAPIMutex());
831-
matches.m_opaque_up->ref() = process_sp->FindRangesInMemory(
832-
reinterpret_cast<const uint8_t *>(buf), size, ranges.ref().ref(),
833-
alignment, max_matches, error.ref());
834-
return matches;
835-
}
836-
837-
lldb::addr_t SBProcess::FindInMemory(const void *buf, uint64_t size,
838-
const SBAddressRange &range,
839-
uint32_t alignment, SBError &error) {
840-
LLDB_INSTRUMENT_VA(this, buf, size, range, alignment, error);
841-
842-
ProcessSP process_sp(GetSP());
843-
844-
if (!process_sp) {
845-
error.SetErrorString("SBProcess is invalid");
846-
return LLDB_INVALID_ADDRESS;
847-
}
848-
849-
Process::StopLocker stop_locker;
850-
if (!stop_locker.TryLock(&process_sp->GetRunLock())) {
851-
error.SetErrorString("process is running");
852-
return LLDB_INVALID_ADDRESS;
853-
}
854-
855-
std::lock_guard<std::recursive_mutex> guard(
856-
process_sp->GetTarget().GetAPIMutex());
857-
return process_sp->FindInMemory(reinterpret_cast<const uint8_t *>(buf), size,
858-
range.ref(), alignment, error.ref());
859-
}
860-
861813
size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
862814
SBError &sb_error) {
863815
LLDB_INSTRUMENT_VA(this, addr, dst, dst_len, sb_error);

lldb/source/Target/Process.cpp

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,129 +2007,6 @@ size_t Process::ReadMemory(addr_t addr, void *buf, size_t size, Status &error) {
20072007
}
20082008
}
20092009

2010-
void Process::DoFindInMemory(lldb::addr_t start_addr, lldb::addr_t end_addr,
2011-
const uint8_t *buf, size_t size,
2012-
AddressRanges &matches, size_t alignment,
2013-
size_t max_matches) {
2014-
// Inputs are already validated in FindInMemory() functions.
2015-
assert(buf != nullptr);
2016-
assert(size > 0);
2017-
assert(alignment > 0);
2018-
assert(max_matches > 0);
2019-
assert(start_addr != LLDB_INVALID_ADDRESS);
2020-
assert(end_addr != LLDB_INVALID_ADDRESS);
2021-
assert(start_addr < end_addr);
2022-
2023-
lldb::addr_t start = llvm::alignTo(start_addr, alignment);
2024-
while (matches.size() < max_matches && (start + size) < end_addr) {
2025-
const lldb::addr_t found_addr = FindInMemory(start, end_addr, buf, size);
2026-
if (found_addr == LLDB_INVALID_ADDRESS)
2027-
break;
2028-
2029-
if (found_addr % alignment) {
2030-
// We need to check the alignment because the FindInMemory uses a special
2031-
// algorithm to efficiently search mememory but doesn't support alignment.
2032-
start = llvm::alignTo(start + 1, alignment);
2033-
continue;
2034-
}
2035-
2036-
matches.emplace_back(found_addr, size);
2037-
start = found_addr + alignment;
2038-
}
2039-
}
2040-
2041-
AddressRanges Process::FindRangesInMemory(const uint8_t *buf, uint64_t size,
2042-
const AddressRanges &ranges,
2043-
size_t alignment, size_t max_matches,
2044-
Status &error) {
2045-
AddressRanges matches;
2046-
if (buf == nullptr) {
2047-
error.SetErrorString("buffer is null");
2048-
return matches;
2049-
}
2050-
if (size == 0) {
2051-
error.SetErrorString("buffer size is zero");
2052-
return matches;
2053-
}
2054-
if (ranges.empty()) {
2055-
error.SetErrorString("empty ranges");
2056-
return matches;
2057-
}
2058-
if (alignment == 0) {
2059-
error.SetErrorString("alignment must be greater than zero");
2060-
return matches;
2061-
}
2062-
if (max_matches == 0) {
2063-
error.SetErrorString("max_matches must be greater than zero");
2064-
return matches;
2065-
}
2066-
2067-
int resolved_ranges = 0;
2068-
Target &target = GetTarget();
2069-
for (size_t i = 0; i < ranges.size(); ++i) {
2070-
if (matches.size() >= max_matches)
2071-
break;
2072-
const AddressRange &range = ranges[i];
2073-
if (range.IsValid() == false)
2074-
continue;
2075-
2076-
const lldb::addr_t start_addr =
2077-
range.GetBaseAddress().GetLoadAddress(&target);
2078-
if (start_addr == LLDB_INVALID_ADDRESS)
2079-
continue;
2080-
2081-
++resolved_ranges;
2082-
const lldb::addr_t end_addr = start_addr + range.GetByteSize();
2083-
DoFindInMemory(start_addr, end_addr, buf, size, matches, alignment,
2084-
max_matches);
2085-
}
2086-
2087-
if (resolved_ranges > 0)
2088-
error.Clear();
2089-
else
2090-
error.SetErrorString("unable to resolve any ranges");
2091-
2092-
return matches;
2093-
}
2094-
2095-
lldb::addr_t Process::FindInMemory(const uint8_t *buf, uint64_t size,
2096-
const AddressRange &range, size_t alignment,
2097-
Status &error) {
2098-
if (buf == nullptr) {
2099-
error.SetErrorString("buffer is null");
2100-
return LLDB_INVALID_ADDRESS;
2101-
}
2102-
if (size == 0) {
2103-
error.SetErrorString("buffer size is zero");
2104-
return LLDB_INVALID_ADDRESS;
2105-
}
2106-
if (!range.IsValid()) {
2107-
error.SetErrorString("range is invalid");
2108-
return LLDB_INVALID_ADDRESS;
2109-
}
2110-
if (alignment == 0) {
2111-
error.SetErrorString("alignment must be greater than zero");
2112-
return LLDB_INVALID_ADDRESS;
2113-
}
2114-
2115-
Target &target = GetTarget();
2116-
const lldb::addr_t start_addr =
2117-
range.GetBaseAddress().GetLoadAddress(&target);
2118-
if (start_addr == LLDB_INVALID_ADDRESS) {
2119-
error.SetErrorString("range load address is invalid");
2120-
return LLDB_INVALID_ADDRESS;
2121-
}
2122-
const lldb::addr_t end_addr = start_addr + range.GetByteSize();
2123-
2124-
AddressRanges matches;
2125-
DoFindInMemory(start_addr, end_addr, buf, size, matches, alignment, 1);
2126-
if (matches.empty())
2127-
return LLDB_INVALID_ADDRESS;
2128-
2129-
error.Clear();
2130-
return matches[0].GetBaseAddress().GetLoadAddress(&target);
2131-
}
2132-
21332010
size_t Process::ReadCStringFromMemory(addr_t addr, std::string &out_str,
21342011
Status &error) {
21352012
char buf[256];

lldb/test/API/python_api/find_in_memory/Makefile

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)