[Lldb-commits] [lldb] [lldb] (Begin to) support discontinuous lldb_private::Functions (PR #115730)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 11 21:55:26 PST 2024


================
@@ -254,12 +254,32 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images,
 
 /// @}
 
+AddressRange CollapseRanges(llvm::ArrayRef<AddressRange> ranges) {
+  if (ranges.empty())
+    return AddressRange();
+  if (ranges.size() == 1)
+    return ranges[0];
+
+  Address lowest_addr = ranges[0].GetBaseAddress();
+  addr_t highest_addr = lowest_addr.GetFileAddress() + ranges[0].GetByteSize();
+  for (const AddressRange &range : ranges.drop_front()) {
+    Address range_begin = range.GetBaseAddress();
+    addr_t range_end = range_begin.GetFileAddress() + range.GetByteSize();
+    if (range_begin.GetFileAddress() < lowest_addr.GetFileAddress())
+      lowest_addr = range_begin;
+    if (range_end > highest_addr)
+      highest_addr = range_end;
+  }
+  return AddressRange(lowest_addr, highest_addr - lowest_addr.GetFileAddress());
----------------
JDevlieghere wrote:

I can't help but think you don't actually need the `highest_addr` and you could just keep extending the  byte size of the range, but maybe I'm missing something? 

https://github.com/llvm/llvm-project/pull/115730


More information about the lldb-commits mailing list