[LLDB][Minidump] Have Minidumps save off and properly read TLS data (… · llvm/llvm-project@e9c8f75 (original) (raw)

`@@ -6528,6 +6528,29 @@ static void AddRegion(const MemoryRegionInfo &region, bool try_dirty_pages,

`

6528

6528

`CreateCoreFileMemoryRange(region));

`

6529

6529

`}

`

6530

6530

``

``

6531

`+

static void SaveDynamicLoaderSections(Process &process,

`

``

6532

`+

const SaveCoreOptions &options,

`

``

6533

`+

CoreFileMemoryRanges &ranges,

`

``

6534

`+

std::set &stack_ends) {

`

``

6535

`+

DynamicLoader *dyld = process.GetDynamicLoader();

`

``

6536

`+

if (!dyld)

`

``

6537

`+

return;

`

``

6538

+

``

6539

`+

std::vector dynamic_loader_mem_regions;

`

``

6540

`+

std::function<bool(const lldb_private::Thread &)> save_thread_predicate =

`

``

6541

`+

[&](const lldb_private::Thread &t) -> bool {

`

``

6542

`+

return options.ShouldThreadBeSaved(t.GetID());

`

``

6543

`+

};

`

``

6544

`+

dyld->CalculateDynamicSaveCoreRanges(process, dynamic_loader_mem_regions,

`

``

6545

`+

save_thread_predicate);

`

``

6546

`+

for (const auto &region : dynamic_loader_mem_regions) {

`

``

6547

`+

// The Dynamic Loader can give us regions that could include a truncated

`

``

6548

`+

// stack

`

``

6549

`+

if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0)

`

``

6550

`+

AddRegion(region, true, ranges);

`

``

6551

`+

}

`

``

6552

`+

}

`

``

6553

+

6531

6554

`static void SaveOffRegionsWithStackPointers(Process &process,

`

6532

6555

`const SaveCoreOptions &core_options,

`

6533

6556

`const MemoryRegionInfos &regions,

`

`@@ -6559,11 +6582,13 @@ static void SaveOffRegionsWithStackPointers(Process &process,

`

6559

6582

`// off in other calls

`

6560

6583

` sp_region.GetRange().SetRangeBase(stack_head);

`

6561

6584

` sp_region.GetRange().SetByteSize(stack_size);

`

6562

``

`-

stack_ends.insert(sp_region.GetRange().GetRangeEnd());

`

``

6585

`+

const addr_t range_end = sp_region.GetRange().GetRangeEnd();

`

``

6586

`+

stack_ends.insert(range_end);

`

6563

6587

`// This will return true if the threadlist the user specified is empty,

`

6564

6588

`// or contains the thread id from thread_sp.

`

6565

``

`-

if (core_options.ShouldThreadBeSaved(thread_sp->GetID()))

`

``

6589

`+

if (core_options.ShouldThreadBeSaved(thread_sp->GetID())) {

`

6566

6590

`AddRegion(sp_region, try_dirty_pages, ranges);

`

``

6591

`+

}

`

6567

6592

` }

`

6568

6593

` }

`

6569

6594

`}

`

`@@ -6672,9 +6697,14 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options,

`

6672

6697

` std::set stack_ends;

`

6673

6698

`// For fully custom set ups, we don't want to even look at threads if there

`

6674

6699

`// are no threads specified.

`

6675

``

`-

if (core_style != lldb::eSaveCoreCustomOnly || options.HasSpecifiedThreads())

`

``

6700

`+

if (core_style != lldb::eSaveCoreCustomOnly ||

`

``

6701

`+

options.HasSpecifiedThreads()) {

`

6676

6702

`SaveOffRegionsWithStackPointers(*this, options, regions, ranges,

`

6677

6703

` stack_ends);

`

``

6704

`+

// Save off the dynamic loader sections, so if we are on an architecture

`

``

6705

`+

// that supports Thread Locals, that we include those as well.

`

``

6706

`+

SaveDynamicLoaderSections(*this, options, ranges, stack_ends);

`

``

6707

`+

}

`

6678

6708

``

6679

6709

`switch (core_style) {

`

6680

6710

`case eSaveCoreUnspecified:

`