| 15 | using file_unique_ptr = std::unique_ptr<FILE, std::function<int(FILE*)>>; |
| 16 | |
| 17 | int |
| 18 | pystack_find_elf( |
| 19 | Dwfl_Module* mod, |
| 20 | void** userdata, |
| 21 | const char* modname, |
| 22 | Dwarf_Addr base, |
| 23 | char** file_name, |
| 24 | Elf** elfp) |
| 25 | { |
| 26 | const char* the_modname = (modname == nullptr) ? "???" : modname; |
| 27 | int ret = dwfl_build_id_find_elf(mod, userdata, modname, base, file_name, elfp); |
| 28 | if (ret > 0) { |
| 29 | const char* the_filename = (*file_name == nullptr) ? "???" : *file_name; |
| 30 | LOG(DEBUG) << "Located debug info for " << the_modname << " using BUILD ID in " << the_filename; |
| 31 | return ret; |
| 32 | } |
| 33 | ret = dwfl_linux_proc_find_elf(mod, userdata, modname, base, file_name, elfp); |
| 34 | if (file_name == nullptr) { |
| 35 | LOG(DEBUG) << "Could not locate debug info for " << the_modname; |
| 36 | } else { |
| 37 | LOG(DEBUG) << "Located debug info for " << the_modname << " by path in " << *file_name; |
| 38 | } |
| 39 | return ret; |
| 40 | } |
| 41 | |
| 42 | std::string |
| 43 | parse_permissions(long flags) |