Resolve relative paths for StackTrace::Addr2Line.

Fixes #5792
This commit is contained in:
Gunnar Beutner 2014-03-21 08:44:16 +01:00
parent 793acda14e
commit 0c7d53503d
1 changed files with 6 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include "base/qstring.h"
#include "base/utility.h"
#include "base/convert.h"
#include "base/application.h"
#include <boost/algorithm/string/trim.hpp>
#ifdef HAVE_BACKTRACE_SYMBOLS
@ -111,7 +112,7 @@ String StackTrace::Addr2Line(const String& exe, uintptr_t rva)
{
#ifndef _WIN32
std::ostringstream msgbuf;
msgbuf << "addr2line -s -e " << exe << " " << std::hex << rva;
msgbuf << "addr2line -s -e " << Application::GetExePath(exe) << " " << std::hex << rva << " 2>/dev/null";
String args = msgbuf.str();
@ -120,13 +121,16 @@ String StackTrace::Addr2Line(const String& exe, uintptr_t rva)
if (!fp)
return "RVA: " + Convert::ToString(rva);
char buffer[512];
char buffer[512] = {};
fgets(buffer, sizeof(buffer), fp);
fclose(fp);
String line = buffer;
boost::algorithm::trim_right(line);
if (line.GetLength() == 0)
return "RVA: " + Convert::ToString(rva);
return line;
#else /* _WIN32 */
return String();