mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 06:40:01 +08:00
[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:
@@ -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 ®ions,
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user