llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

SourceManager::GetDefaultFileAndLine locates the executable's main to pick a 
default source file, used for input like "break set -l N" with no file 
specified. It searched for main by full name, but a function's linkage name can 
differ from its source name, in which case a full-name search for "main" does 
not find it and no default file is chosen.

For example, wasi-libc renames main to __main_argc_argv, so on WebAssembly the 
debug function for main was never matched and "break set -l N" failed with "no 
default file available".

Search by base name instead. The base name is "main" regardless of the linkage 
name, and where the two coincide the behavior is unchanged.

---
Full diff: https://github.com/llvm/llvm-project/pull/207043.diff


1 Files Affected:

- (modified) lldb/source/Core/SourceManager.cpp (+4-1) 


``````````diff
diff --git a/lldb/source/Core/SourceManager.cpp 
b/lldb/source/Core/SourceManager.cpp
index d3e1bb5d332f0..af73a2c571c0f 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -429,8 +429,11 @@ SourceManager::GetDefaultFileAndLine() {
         function_options.include_symbols =
             false; // Force it to be a debug symbol.
         function_options.include_inlines = true;
+        // The linkage name can differ from the source name, so match on the
+        // base name to find the function regardless of how it was mangled or
+        // renamed.
         executable_ptr->FindFunctions(main_name, CompilerDeclContext(),
-                                      lldb::eFunctionNameTypeFull,
+                                      lldb::eFunctionNameTypeBase,
                                       function_options, sc_list);
         for (const SymbolContext &sc : sc_list) {
           if (sc.function) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/207043
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to