================
@@ -810,6 +809,112 @@ 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) {
+ LLDB_INSTRUMENT_VA(this, buf, size, ranges, alignment, max_matches);
+
+ Log *log = GetLog(LLDBLog::Process);
+ lldb::SBAddressRangeList matches;
+
+ if (alignment == 0) {
+ LLDB_LOGF(log, "SBProcess::%s allignmet is 0, Must be greater than 0.",
+ __FUNCTION__);
+ return matches;
+ }
+
+ if (buf == nullptr) {
+ LLDB_LOGF(log, "SBProcess::%s provided 'buffer' is nullptr.",
__FUNCTION__);
+ return matches;
+ }
+
+ if (size == 0) {
+ LLDB_LOGF(log, "SBProcess::%s buffer size is 0.", __FUNCTION__);
+ return matches;
+ }
+
+ if (ranges.GetSize() == 0) {
+ LLDB_LOGF(log, "SBProcess::%s provided 'range' is invalid.", __FUNCTION__);
+ return 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());
+ lldb::SBError error;
+ error.ref() = process_sp->FindInMemory(
+ matches.m_opaque_up->ref(), static_cast<const uint8_t *>(buf), size,
+ ranges.m_opaque_up->ref(), alignment, max_matches);
+ if (error.Fail()) {
+ LLDB_LOGF(log, "SBProcess::%s failed to find pattern in memory.",
+ __FUNCTION__);
+ }
+ return matches;
+}
+
+lldb::addr_t SBProcess::FindInMemory(const void *buf, uint64_t size,
+ SBAddressRange &range,
+ uint32_t alignment) {
+ LLDB_INSTRUMENT_VA(this, buf, size, range, alignment);
+
+ Log *log = GetLog(LLDBLog::Process);
+
+ if (alignment == 0) {
+ LLDB_LOGF(log, "SBProcess::%s allignmet is 0, Must be greater than 0.",
+ __FUNCTION__);
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ if (buf == nullptr) {
+ LLDB_LOGF(log, "SBProcess::%s provided 'buffer' is nullptr.",
__FUNCTION__);
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ if (size == 0) {
+ LLDB_LOGF(log, "SBProcess::%s buffer size is 0.", __FUNCTION__);
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ if (!range.IsValid()) {
+ LLDB_LOGF(log, "SBProcess::%s provided 'range' is invalid.", __FUNCTION__);
+ return LLDB_INVALID_ADDRESS;
+ }
----------------
clayborg wrote:
Only do this checking down in `lldb_private::Process`
https://github.com/llvm/llvm-project/pull/95007
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits