================ @@ -810,6 +809,65 @@ const char *SBProcess::GetBroadcasterClass() { return ConstString(Process::GetStaticBroadcasterClass()).AsCString(); } +lldb::SBAddressRangeList +SBProcess::FindRangesInMemory(const void *buf, uint64_t size, + SBAddressRangeList &ranges, uint32_t alignment, + uint32_t max_matches, SBError &error) { + LLDB_INSTRUMENT_VA(this, buf, size, ranges, alignment, max_matches, error); + + Log *log = GetLog(LLDBLog::Process); + lldb::SBAddressRangeList matches; + + ProcessSP process_sp(GetSP()); + if (!process_sp) { + LLDB_LOGF(log, "SBProcess::%s SBProcess is invalid.", __FUNCTION__); + return matches; + } + Process::StopLocker stop_locker; + if (!stop_locker.TryLock(&process_sp->GetRunLock())) { + LLDB_LOGF( + log, + "SBProcess::%s Cannot find process in memory while process is running.", + __FUNCTION__); + return matches; + } + std::lock_guard<std::recursive_mutex> guard( + process_sp->GetTarget().GetAPIMutex()); + matches.m_opaque_up->ref() = process_sp->FindRangesInMemory( + reinterpret_cast<const uint8_t *>(buf), size, ranges.m_opaque_up->ref(), + alignment, max_matches, error.ref()); + return matches; +} + +lldb::addr_t SBProcess::FindInMemory(const void *buf, uint64_t size, + SBAddressRange &range, uint32_t alignment, + SBError &error) { + LLDB_INSTRUMENT_VA(this, buf, size, range, alignment, error); + + if (!range.IsValid()) { + error.SetErrorStringWithFormat("range is invalid"); + return LLDB_INVALID_ADDRESS; + } + + ProcessSP process_sp(GetSP()); + + if (!process_sp) { + error.SetErrorStringWithFormat("SBProcess is invalid"); ---------------- clayborg wrote:
No need for the `WithFormat` variant: ``` error.SetErrorString("SBProcess is invalid"); ``` https://github.com/llvm/llvm-project/pull/95007 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits