@@ -6543,7 +6543,7 @@ static void AddRegisterSections(Process &process, ThreadSP &thread_sp, CoreFileM
65436543 return ;
65446544
65456545 const uint64_t fail_value = UINT64_MAX;
6546- bool readSuccess = true ;
6546+ bool readSuccess = false ;
65476547 const lldb::addr_t reg_value_addr = reg_value.GetAsUInt64 (fail_value, &readSuccess);
65486548 if (!readSuccess || reg_value_addr == fail_value)
65496549 return ;
@@ -6562,23 +6562,29 @@ static void AddRegisterSections(Process &process, ThreadSP &thread_sp, CoreFileM
65626562 AddRegion (register_region, true , ranges);
65636563}
65646564
6565- static void AddModuleThreadLocalSections (Process &process, ThreadSP &thread_sp, CoreFileMemoryRanges &ranges, lldb:: addr_t range_end ) {
6565+ static void AddModuleSections (Process &process, CoreFileMemoryRanges &ranges, std::set< addr_t > &stack_ends ) {
65666566 ModuleList &module_list = process.GetTarget ().GetImages ();
6567+ Target* target = &process.GetTarget ();
65676568 for (size_t idx = 0 ; idx < module_list.GetSize (); idx++) {
65686569 ModuleSP module_sp = module_list.GetModuleAtIndex (idx);
65696570 if (!module_sp)
65706571 continue ;
6571- // We want the entire section, so the offset is 0.
6572- const lldb::addr_t tls_storage_addr = thread_sp->GetThreadLocalData (module_sp, 0 );
6573- if (tls_storage_addr == LLDB_INVALID_ADDRESS)
6572+
6573+ ObjectFile *obj = module_sp->GetObjectFile ();
6574+ if (!obj)
6575+ continue ;
6576+ Address addr = obj->GetImageInfoAddress (target);
6577+ addr_t load_addr = addr.GetLoadAddress (target);
6578+ if (load_addr == LLDB_INVALID_ADDRESS)
65746579 continue ;
6580+
65756581 MemoryRegionInfo tls_storage_region;
6576- Status err = process.GetMemoryRegionInfo (tls_storage_addr , tls_storage_region);
6582+ Status err = process.GetMemoryRegionInfo (load_addr , tls_storage_region);
65776583 if (err.Fail ())
65786584 continue ;
65796585
65806586 // We already saved off this truncated stack range.
6581- if (tls_storage_region.GetRange ().GetRangeEnd () == range_end )
6587+ if (stack_ends. count ( tls_storage_region.GetRange ().GetRangeEnd ()) > 0 )
65826588 continue ;
65836589
65846590 AddRegion (tls_storage_region, true , ranges);
@@ -6625,7 +6631,6 @@ static void SaveOffRegionsWithStackPointers(Process &process,
66256631 // Add the register section if x86_64 and add the module tls data
66266632 // only if the range isn't the same as this truncated stack range.
66276633 AddRegisterSections (process, thread_sp, ranges, range_end);
6628- AddModuleThreadLocalSections (process, thread_sp, ranges, range_end);
66296634 }
66306635 }
66316636 }
@@ -6735,9 +6740,12 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options,
67356740 std::set<addr_t > stack_ends;
67366741 // For fully custom set ups, we don't want to even look at threads if there
67376742 // are no threads specified.
6738- if (core_style != lldb::eSaveCoreCustomOnly || options.HasSpecifiedThreads ())
6743+ if (core_style != lldb::eSaveCoreCustomOnly || options.HasSpecifiedThreads ()) {
67396744 SaveOffRegionsWithStackPointers (*this , options, regions, ranges,
6740- stack_ends);
6745+ stack_ends);
6746+ AddModuleSections (*this , ranges, stack_ends);
6747+ }
6748+
67416749
67426750 switch (core_style) {
67436751 case eSaveCoreUnspecified:
0 commit comments