[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 13 12:52:00 PDT 2024
================
@@ -0,0 +1,83 @@
+//===-- PostMortemProcess.cpp -----------------------------------*- C++ -*-===//
+//
+// 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/Target/PostMortemProcess.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/lldb-forward.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+lldb::addr_t PostMortemProcess::FindInMemory(lldb::addr_t low,
+ lldb::addr_t high,
+ const uint8_t *buf, size_t size) {
+ const size_t region_size = high - low;
+ if (region_size < size)
+ return LLDB_INVALID_ADDRESS;
+
+ llvm::ArrayRef<uint8_t> data = PeekMemory(low, high);
+ if (data.empty()) {
+ LLDB_LOG(GetLog(LLDBLog::Process),
+ "Failed to get contiguous memory region for search. low: 0x{}, "
+ "high: 0x{}. Failling back to Process::FindInMemory",
+ low, high);
+ // In an edge case when the search has to happen across non-contiguous
+ // memory, we will have to fall back on the Process::FindInMemory.
+ return Process::FindInMemory(low, high, buf, size);
+ }
+
+ return Process::FindInMemoryGeneric(data, low, high, buf, size);
+}
+
+llvm::ArrayRef<uint8_t> PostMortemProcess::PeekMemory(lldb::addr_t low,
+ lldb::addr_t high) {
+ return {};
+}
+
+llvm::ArrayRef<uint8_t>
+PostMortemProcess::DoPeekMemory(lldb::ModuleSP &core_module_sp,
+ VMRangeToFileOffset &core_aranges,
+ lldb::addr_t low, lldb::addr_t high) {
+
+ ObjectFile *core_objfile = core_module_sp->GetObjectFile();
+
+ if (core_objfile == nullptr) {
+ return {};
+ }
----------------
clayborg wrote:
remove {} from single statement if per llvm coding guidelines.
https://github.com/llvm/llvm-project/pull/102536
More information about the lldb-commits
mailing list