[Lldb-commits] [lldb] [LLDB][NativePDB] Estimate symbol sizes (PR #165727)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 30 09:27:01 PDT 2025


================
@@ -1130,16 +1130,47 @@ void SymbolFileNativePDB::AddSymbols(Symtab &symtab) {
   if (!section_list)
     return;
 
-  for (auto pid : m_index->publics().getPublicsTable()) {
+  PublicSym32 last_sym;
+  size_t last_sym_idx = 0;
+  lldb::SectionSP section_sp;
+
+  // To estimate the size of a symbol, we use the difference to the next symbol.
+  // If there's no next symbol or the section/segment changed, the symbol will
+  // take the remaining space. The estimate can be too high in case there's
+  // padding between symbols. This similar to the algorithm used by the DIA
+  // SDK.
+  auto finish_last_symbol = [&](const PublicSym32 *next) {
+    if (!section_sp)
+      return;
+    Symbol *last = symtab.SymbolAtIndex(last_sym_idx);
+    if (!last)
+      return;
+
+    if (next && last_sym.Segment == next->Segment) {
----------------
Michael137 wrote:

When can `next` here not be contextually convertible to `true`? Isn't it always just the address of the local `pub` variable?

https://github.com/llvm/llvm-project/pull/165727


More information about the lldb-commits mailing list