/proc/self/cwd/source/server/backtrace.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include "source/server/backtrace.h" |
2 | | |
3 | | #include <fstream> |
4 | | |
5 | | #include "absl/strings/str_split.h" |
6 | | |
7 | | namespace Envoy { |
8 | | |
9 | | bool BackwardsTrace::log_to_stderr_ = false; |
10 | | |
11 | 0 | const std::string& BackwardsTrace::addrMapping(bool setup) { |
12 | 0 | CONSTRUCT_ON_FIRST_USE(std::string, [setup]() -> std::string { |
13 | 0 | if (!setup) { |
14 | 0 | return ""; |
15 | 0 | } |
16 | 0 | #ifndef WIN32 |
17 | 0 | std::ifstream maps("/proc/self/maps"); |
18 | 0 | if (maps.fail()) { |
19 | 0 | return ""; |
20 | 0 | } |
21 | 0 | std::string line; |
22 | | // Search for the first executable memory mapped block. |
23 | 0 | while (std::getline(maps, line)) { |
24 | 0 | std::vector<absl::string_view> parts = absl::StrSplit(line, ' '); |
25 | 0 | if (parts[1] == "r-xp") { |
26 | 0 | return absl::StrCat(parts[0], " ", parts.back()); |
27 | 0 | } |
28 | 0 | } |
29 | 0 | #endif |
30 | 0 | return ""; |
31 | 0 | }()); |
32 | 0 | } |
33 | | |
34 | 0 | void BackwardsTrace::setLogToStderr(bool log_to_stderr) { log_to_stderr_ = log_to_stderr; } |
35 | | |
36 | | } // namespace Envoy |