MCPcopy Create free account
hub / github.com/bloomberg/pystack / locateLibrary

Method locateLibrary

src/pystack/_pystack/elf_common.cpp:239–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239std::string
240CoreFileAnalyzer::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
267ProcessAnalyzer::ProcessAnalyzer(pid_t pid)
268: d_dwfl(nullptr)

Callers 1

populateMapsMethod · 0.80

Calls 1

LOGClass · 0.85

Tested by

no test coverage detected