aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectMemory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectMemory.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp61
1 files changed, 2 insertions, 59 deletions
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index b78a049..1c13484 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -977,35 +977,6 @@ public:
Options *GetOptions() override { return &m_option_group; }
protected:
- class ProcessMemoryIterator {
- public:
- ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
- : m_process_sp(process_sp), m_base_addr(base) {
- lldbassert(process_sp.get() != nullptr);
- }
-
- bool IsValid() { return m_is_valid; }
-
- uint8_t operator[](lldb::addr_t offset) {
- if (!IsValid())
- return 0;
-
- uint8_t retval = 0;
- Status error;
- if (0 ==
- m_process_sp->ReadMemory(m_base_addr + offset, &retval, 1, error)) {
- m_is_valid = false;
- return 0;
- }
-
- return retval;
- }
-
- private:
- ProcessSP m_process_sp;
- lldb::addr_t m_base_addr;
- bool m_is_valid = true;
- };
void DoExecute(Args &command, CommandReturnObject &result) override {
// No need to check "process" for validity as eCommandRequiresProcess
// ensures it is valid
@@ -1106,8 +1077,8 @@ protected:
found_location = low_addr;
bool ever_found = false;
while (count) {
- found_location = FastSearch(found_location, high_addr, buffer.GetBytes(),
- buffer.GetByteSize());
+ found_location = process->FindInMemory(
+ found_location, high_addr, buffer.GetBytes(), buffer.GetByteSize());
if (found_location == LLDB_INVALID_ADDRESS) {
if (!ever_found) {
result.AppendMessage("data not found within the range.\n");
@@ -1144,34 +1115,6 @@ protected:
result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
}
- lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
- size_t buffer_size) {
- const size_t region_size = high - low;
-
- if (region_size < buffer_size)
- return LLDB_INVALID_ADDRESS;
-
- std::vector<size_t> bad_char_heuristic(256, buffer_size);
- ProcessSP process_sp = m_exe_ctx.GetProcessSP();
- ProcessMemoryIterator iterator(process_sp, low);
-
- for (size_t idx = 0; idx < buffer_size - 1; idx++) {
- decltype(bad_char_heuristic)::size_type bcu_idx = buffer[idx];
- bad_char_heuristic[bcu_idx] = buffer_size - idx - 1;
- }
- for (size_t s = 0; s <= (region_size - buffer_size);) {
- int64_t j = buffer_size - 1;
- while (j >= 0 && buffer[j] == iterator[s + j])
- j--;
- if (j < 0)
- return low + s;
- else
- s += bad_char_heuristic[iterator[s + buffer_size - 1]];
- }
-
- return LLDB_INVALID_ADDRESS;
- }
-
OptionGroupOptions m_option_group;
OptionGroupFindMemory m_memory_options;
OptionGroupMemoryTag m_memory_tag_options;