================
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// 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/MemoryRegionInfoCache.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+void MemoryRegionInfoCache::Clear() {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+  m_region_infos.Clear();
+  m_is_sorted = true;
+}
+
+void MemoryRegionInfoCache::EraseRange(addr_t load_addr, size_t size) {
+  std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
+  // If load_addr+size would overflow, do nothing.
+  // Likely this is an LLDB_INVALID_ADDRESS plus something.
+  uint64_t max_minus_addr = std::numeric_limits<addr_t>::max() - load_addr;
+  if (size > max_minus_addr)
+    return;
+
+  if (!m_is_sorted)
+    m_region_infos.Sort();
----------------
jasonmolenda wrote:

I was thinking - we're about to remove an element and invalid the sorting, but 
(1) we could early-return, and (2) even after we've removed an entry we're 
still in correct sort order.

https://github.com/llvm/llvm-project/pull/206208
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to