From bb2e861827cb854dd380d2b7ac3d8907de7043d7 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 22 Oct 2021 10:26:50 +0200 Subject: prefer llvm-addr2line to addr2line for backtraces if possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sal/osl/unx/backtraceapi.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'sal') 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 #include #include +#include #include #include "backtrace.h" @@ -74,8 +75,17 @@ FrameCache frameCache( 256 ); void process_file_addr2line( const char* file, std::vector& 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 addrs; @@ -93,8 +103,6 @@ void process_file_addr2line( const char* file, std::vector& 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 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 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 ) { -- cgit