clayborg added inline comments.
================ Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp:298-306 +static uint32_t GetOSOSymbolFlags() { + // When a mach-o symbol is encoded, the n_type field is encoded in bits + // 23:16, and the n_desc field is encoded in bits 15:0. + // + // N_OSO object file symbols have a flags value as follows: + // bits 23:16 == 0x66 (N_OSO) + // bits 15: 0 == 0x0001 (specifies this is a debug map object file) ---------------- ``` static constexpr uint32_t kOSOSymbolFlags = 0x660001u; ``` ================ Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp:328 std::vector<uint32_t> oso_indexes; - // When a mach-o symbol is encoded, the n_type field is encoded in bits - // 23:16, and the n_desc field is encoded in bits 15:0. - // - // To find all N_OSO entries that are part of the DWARF + debug map we find - // only object file symbols with the flags value as follows: bits 23:16 == - // 0x66 (N_OSO) bits 15: 0 == 0x0001 (specifies this is a debug map object - // file) - const uint32_t k_oso_symbol_flags_value = 0x660001u; + const uint32_t k_oso_symbol_flags_value = GetOSOSymbolFlags(); ---------------- kOSOSymbolFlags ================ Comment at: source/Symbol/Symtab.cpp:512-520 +bool Symtab::HasSymbolWithTypeAndFlags(lldb::SymbolType symbol_type, + uint32_t flags_value) const { + std::lock_guard<std::recursive_mutex> guard(m_mutex); + for (const Symbol &symbol : m_symbols) + if (symbol.GetType() == symbol_type && symbol.GetFlags() == flags_value) + return true; + ---------------- This function is a bit specific. Might be nice to have a method like: ``` void Symtab::ForEachSymbolWithType( lldb::SymbolType symbol_type, llvm::function_ref<bool(const Symbol*)> lambda) const; ``` The lambda returns false, then stop iterating. Else keep going. See ModuleList::ForEach as an example. Then the code that was calling HasSymbolWithTypeAndFlags would do something like: ``` symtab->ForEachSymbolWithType(eSymbolTypeObjectFile, [&this->m_has_compile_unit_infos](Symbol *symbol)->bool { if (symbol->GetFlags() == kOSOSymbolFlags) { m_has_compile_unit_infos = true; return false; // Stop iterating } return true; // Keep iterating }); ``` https://reviews.llvm.org/D52375 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits