[Lldb-commits] [PATCH] D52375: [WIP] Support multiple compile units per OSO entry in SymbolFileDWARFDebugMap

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 24 14:36:26 PDT 2018


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





More information about the lldb-commits mailing list