sal/osl/unx/backtraceapi.cxx |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit bb2e861827cb854dd380d2b7ac3d8907de7043d7
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Oct 22 10:26:50 2021 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Fri Oct 22 16:32:57 2021 +0200

    prefer llvm-addr2line to addr2line for backtraces if possible
    
    It's faster, and at least when compiling with Clang it should work
    fine.
    
    Change-Id: I474857c2a54b8032b74202ccd5c67d25f6062790
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124055
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 23d3bec498b9..d67806d9268b 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -19,6 +19,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
+#include <sal/log.hxx>
 #include <sal/backtrace.hxx>
 
 #include "backtrace.h"
@@ -74,8 +75,17 @@ FrameCache frameCache( 256 );
 
 void process_file_addr2line( const char* file, std::vector<FrameData>& 
frameData )
 {
+    if(access( file, R_OK ) != 0)
+        return; // cannot read info from the binary file anyway
     OUString binary("addr2line");
     OUString dummy;
+#if defined __clang__
+    // llvm-addr2line is faster than addr2line
+    if(osl::detail::find_in_PATH("llvm-addr2line", dummy))
+        binary = "llvm-addr2line";
+#endif
+    if(!osl::detail::find_in_PATH(binary, dummy))
+        return; // Will not work, avoid warnings from osl process code.
     OUString arg1("-Cfe");
     OUString arg2 = OUString::fromUtf8(file);
     std::vector<OUString> addrs;
@@ -93,8 +103,6 @@ void process_file_addr2line( const char* file, 
std::vector<FrameData>& frameData
         }
     }
 
-    if(!osl::detail::find_in_PATH(binary, dummy) || access( file, R_OK ) != 0)
-        return; // Will not work, avoid warnings from osl process code.
     oslProcess aProcess;
     oslFileHandle pOut = nullptr;
     oslFileHandle pErr = nullptr;
@@ -105,7 +113,10 @@ void process_file_addr2line( const char* file, 
std::vector<FrameData>& frameData
     osl_freeSecurityHandle(pSecurity);
 
     if (eErr != osl_Process_E_None)
+    {
+        SAL_WARN("sal.osl", binary << " call to resolve " << file << " symbols 
failed");
         return;
+    }
 
     OStringBuffer outputBuffer;
     if (pOut)
@@ -148,7 +159,10 @@ void process_file_addr2line( const char* file, 
std::vector<FrameData>& frameData
         outputPos = end2 + 1;
     }
     if(lines.size() != addrs.size() * 2)
+    {
+        SAL_WARN("sal.osl", "failed to parse " << binary << " call output to 
resolve " << file << " symbols ");
         return; // addr2line problem?
+    }
     size_t linesPos = 0;
     for( FrameData& frame : frameData )
     {

Reply via email to