llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: None (GeorgeHuyubo) <details> <summary>Changes</summary> Main executables were bypassing the locate module callback that shared libraries use, preventing custom symbol file location logic from working consistently. Fixed by modifying Platform::ResolveExecutable() to call CallLocateModuleCallbackIfSet() first, then fallback to the standard ModuleList::GetSharedModule() path if needed. This ensures both main executables and shared libraries get the same callback treatment for symbol file resolution. --- Full diff: https://github.com/llvm/llvm-project/pull/160199.diff 1 Files Affected: - (modified) lldb/source/Target/Platform.cpp (+41-9) ``````````diff diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 8681adaf5ea76..bbbe066cdea9e 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -750,12 +750,30 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec, if (resolved_module_spec.GetArchitecture().IsValid() || resolved_module_spec.GetUUID().IsValid()) { - Status error = - ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, - module_search_paths_ptr, nullptr, nullptr); + // Call locate module callback first to give it a chance to find/register + // symbol file specs for the main executable, similar to how shared + // libraries are handled in Platform::GetRemoteSharedModule() + FileSpec symbol_file_spec; + CallLocateModuleCallbackIfSet(resolved_module_spec, exe_module_sp, + symbol_file_spec, nullptr); - if (exe_module_sp && exe_module_sp->GetObjectFile()) - return error; + Status error; + if (!exe_module_sp) { + // If locate module callback didn't provide a module, fallback to standard + // path + error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, + module_search_paths_ptr, nullptr, + nullptr); + } + + if (exe_module_sp && exe_module_sp->GetObjectFile()) { + // Set the symbol file if locate module callback returned one + if (symbol_file_spec) { + exe_module_sp->SetSymbolFileFileSpec(symbol_file_spec); + } + return error; // Return the actual status from GetSharedModule (or success + // from callback) + } exe_module_sp.reset(); } // No valid architecture was specified or the exact arch wasn't found. @@ -767,12 +785,26 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec, Status error; for (const ArchSpec &arch : GetSupportedArchitectures(process_host_arch)) { resolved_module_spec.GetArchitecture() = arch; - error = - ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, - module_search_paths_ptr, nullptr, nullptr); + + // Call locate module callback first, then fallback to standard path + FileSpec symbol_file_spec; + CallLocateModuleCallbackIfSet(resolved_module_spec, exe_module_sp, + symbol_file_spec, nullptr); + + if (!exe_module_sp) { + error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp, + module_search_paths_ptr, nullptr, + nullptr); + } + if (error.Success()) { - if (exe_module_sp && exe_module_sp->GetObjectFile()) + if (exe_module_sp && exe_module_sp->GetObjectFile()) { + // Set the symbol file if locate module callback returned one + if (symbol_file_spec) { + exe_module_sp->SetSymbolFileFileSpec(symbol_file_spec); + } break; + } error = Status::FromErrorString("no exe object file"); } `````````` </details> https://github.com/llvm/llvm-project/pull/160199 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
