| 265 | } |
| 266 | |
| 267 | ProcessAnalyzer::ProcessAnalyzer(pid_t pid) |
| 268 | : d_dwfl(nullptr) |
| 269 | , d_debuginfo_path(nullptr) |
| 270 | , d_callbacks() |
| 271 | , d_pid(pid) |
| 272 | { |
| 273 | memset(&d_callbacks, 0, sizeof(d_callbacks)); |
| 274 | d_callbacks.find_elf = pystack_find_elf; |
| 275 | d_callbacks.find_debuginfo = dwfl_standard_find_debuginfo; |
| 276 | d_callbacks.debuginfo_path = &d_debuginfo_path; |
| 277 | |
| 278 | d_dwfl = dwfl_unique_ptr(dwfl_begin(&d_callbacks), dwfl_end); |
| 279 | |
| 280 | if (!d_dwfl) { |
| 281 | throw ElfAnalyzerError("Failed to initialize DWARF analyzer"); |
| 282 | } |
| 283 | |
| 284 | if (dwfl_linux_proc_report(d_dwfl.get(), pid) || dwfl_report_end(d_dwfl.get(), nullptr, nullptr)) { |
| 285 | throw ElfAnalyzerError("Failed to analyze DWARF information for the remote process"); |
| 286 | } |
| 287 | |
| 288 | if (dwfl_linux_proc_attach(d_dwfl.get(), pid, true) != 0) { |
| 289 | throw ElfAnalyzerError("Could not attach the DWARF process analyzer"); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | const dwfl_unique_ptr& |
| 294 | ProcessAnalyzer::getDwfl() const |
nothing calls this directly
no test coverage detected