[Lldb-commits] [lldb] [lldb][API] Add Find(Ranges)InMemory() to Process SB API (PR #95007)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 10 14:04:32 PDT 2024
================
@@ -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;
+ }
+
----------------
clayborg wrote:
Let the `lldb_private::Process::FindInMemory` handle this error so the error is always consistent instead of duplicating it here.
https://github.com/llvm/llvm-project/pull/95007
More information about the lldb-commits
mailing list