[LLDB][SBSaveCore] Sbsavecore subregions bug (#138206)

Custom regions in Process::GetUserSpecifiedCoreFileSaveRanges originally
used `FindEntryThatContains`. This made sense on my first attempt, but
what we really want are *intersecting* regions. This is so the user can
specify arbitrary memory, and if it's available we output it to the core
(Minidump or MachO).
This commit is contained in:
Jacob Lalonde
2025-05-05 11:04:55 -07:00
committed by GitHub
parent 1e353fa5c3
commit c50cba6275
4 changed files with 325 additions and 3 deletions

View File

@@ -6706,6 +6706,18 @@ static void GetCoreFileSaveRangesStackOnly(Process &process,
}
}
// TODO: We should refactor CoreFileMemoryRanges to use the lldb range type, and
// then add an intersect method on it, or MemoryRegionInfo.
static MemoryRegionInfo Intersect(const MemoryRegionInfo &lhs,
const MemoryRegionInfo::RangeType &rhs) {
MemoryRegionInfo region_info;
region_info.SetLLDBPermissions(lhs.GetLLDBPermissions());
region_info.GetRange() = lhs.GetRange().Intersect(rhs);
return region_info;
}
static void GetUserSpecifiedCoreFileSaveRanges(Process &process,
const MemoryRegionInfos &regions,
const SaveCoreOptions &options,
@@ -6715,9 +6727,15 @@ static void GetUserSpecifiedCoreFileSaveRanges(Process &process,
return;
for (const auto &range : regions) {
auto entry = option_ranges.FindEntryThatContains(range.GetRange());
if (entry)
AddRegion(range, true, ranges);
auto *entry = option_ranges.FindEntryThatIntersects(range.GetRange());
if (entry) {
if (*entry != range.GetRange()) {
AddRegion(Intersect(range, *entry), true, ranges);
} else {
// If they match, add the range directly.
AddRegion(range, true, ranges);
}
}
}
}