summaryrefslogtreecommitdiff
path: root/sal/osl/unx
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-10-22 10:26:50 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-10-22 16:32:57 +0200
commitbb2e861827cb854dd380d2b7ac3d8907de7043d7 (patch)
tree321d1ff3176c58fd1099ef98fa3fd777ffcae717 /sal/osl/unx
parent29e200aa0af78a4589bf7e52dddfb62f3bdf4e01 (diff)
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.lunak@collabora.com>
Diffstat (limited to 'sal/osl/unx')
-rw-r--r--sal/osl/unx/backtraceapi.cxx18
1 files changed, 16 insertions, 2 deletions
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 )
{