[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)
Miro Bucko via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 9 09:53:09 PDT 2024
================
@@ -2835,6 +2835,34 @@ void PruneThreadPlans();
AddressRanges &matches, size_t alignment,
size_t max_matches);
+ template <typename IT>
+ lldb::addr_t FindInMemoryGeneric(IT &&iterator, 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;
+
+ std::vector<size_t> bad_char_heuristic(256, size);
+
+ for (size_t idx = 0; idx < size - 1; idx++) {
+ decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx];
+ bad_char_heuristic[bcu_idx] = size - idx - 1;
+ }
+ for (size_t s = 0; s <= (region_size - size);) {
+ int64_t j = size - 1;
+ while (j >= 0 && buf[j] == iterator[s + j])
+ j--;
+ if (j < 0)
+ return low + s;
+ else
+ s += bad_char_heuristic[iterator[s + size - 1]];
+ }
+
+ return LLDB_INVALID_ADDRESS;
+ }
+
----------------
mbucko wrote:
Yes, there are two usecases.Process uses ProcessMemoryIterator class as the iterator which then uses m_process.ReadMemory() to access the data. Then, the PostMortemProcess uses a raw pointer to the memory
https://github.com/llvm/llvm-project/pull/102536
More information about the lldb-commits
mailing list