| 237 | } |
| 238 | |
| 239 | std::string |
| 240 | CoreFileAnalyzer::locateLibrary(const std::string& lib) const |
| 241 | { |
| 242 | if (!d_lib_search_path) { |
| 243 | return lib; |
| 244 | } |
| 245 | LOG(DEBUG) << "Searching for module: " << lib; |
| 246 | std::string dir_to_consider; |
| 247 | const fs::path target{lib}; |
| 248 | std::stringstream stream{d_lib_search_path.value()}; |
| 249 | while (std::getline(stream, dir_to_consider, ':')) { |
| 250 | if (!fs::exists(dir_to_consider) || !fs::is_directory(dir_to_consider)) { |
| 251 | continue; |
| 252 | } |
| 253 | for (const auto& entry : fs::directory_iterator(dir_to_consider)) { |
| 254 | if (entry.path().filename() != target.filename()) { |
| 255 | continue; |
| 256 | } |
| 257 | if (fs::is_regular_file(entry)) { |
| 258 | LOG(DEBUG) << "Module " << lib << " found at " << entry.path().string(); |
| 259 | return entry.path().string(); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | LOG(DEBUG) << "Could not locate module " << lib << " in the search path"; |
| 264 | return lib; |
| 265 | } |
| 266 | |
| 267 | ProcessAnalyzer::ProcessAnalyzer(pid_t pid) |
| 268 | : d_dwfl(nullptr) |