| 1293 | public: |
| 1294 | TraceResolverLinuxBase() : argv0_(get_argv0()), exec_path_(read_symlink("/proc/self/exe")) {} |
| 1295 | std::string resolve_exec_path(Dl_info& symbol_info) const |
| 1296 | { |
| 1297 | // mutates symbol_info.dli_fname to be filename to open and returns filename |
| 1298 | // to display |
| 1299 | if (symbol_info.dli_fname == argv0_) { |
| 1300 | // dladdr returns argv[0] in dli_fname for symbols contained in |
| 1301 | // the main executable, which is not a valid path if the |
| 1302 | // executable was found by a search of the PATH environment |
| 1303 | // variable; In that case, we actually open /proc/self/exe, which |
| 1304 | // is always the actual executable (even if it was deleted/replaced!) |
| 1305 | // but display the path that /proc/self/exe links to. |
| 1306 | // However, this right away reduces probability of successful symbol |
| 1307 | // resolution, because libbfd may try to find *.debug files in the |
| 1308 | // same dir, in case symbols are stripped. As a result, it may try |
| 1309 | // to find a file /proc/self/<exe_name>.debug, which obviously does |
| 1310 | // not exist. /proc/self/exe is a last resort. First load attempt |
| 1311 | // should go for the original executable file path. |
| 1312 | symbol_info.dli_fname = "/proc/self/exe"; |
| 1313 | return exec_path_; |
| 1314 | } |
| 1315 | else { |
| 1316 | return symbol_info.dli_fname; |
| 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | private: |
| 1321 | std::string argv0_; |
nothing calls this directly
no outgoing calls
no test coverage detected