Skip to content

Commit

Permalink
Fix addr2line work when the process is looked up via PATH.
Browse files Browse the repository at this point in the history
Fixes #72
  • Loading branch information
apolukhin committed Jul 7, 2024
1 parent 34e56c4 commit cbf0df7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/boost/stacktrace/detail/addr2line_impls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <boost/stacktrace/detail/try_dec_convert.hpp>
#include <boost/core/demangle.hpp>
#include <cstdio>
#include <cstring>

#include <sys/types.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -116,7 +117,9 @@ inline std::string addr2line(const char* flag, const void* addr) {
std::string res;

boost::stacktrace::detail::location_from_symbol loc(addr);
if (!loc.empty()) {
// For programs started through $PATH loc.name() is not absolute and
// addr2line will fail.
if (!loc.empty() && std::strchr(loc.name(), '/') != nullptr) {
res = loc.name();
} else {
res.resize(16);
Expand Down

0 comments on commit cbf0df7

Please sign in to comment.