================
@@ -2667,6 +2667,29 @@ static bool 
UpdateCompilerContextForSimpleTemplateNames(TypeQuery &match) {
   }
   return any_context_updated;
 }
+
+uint64_t SymbolFileDWARF::GetDebugInfoSize() {
+  DWARFDebugInfo &info = DebugInfo();
+  uint32_t num_comp_units = info.GetNumUnits();
+
+  uint64_t debug_info_size = SymbolFileCommon::GetDebugInfoSize();
+  // In dwp scenario, debug info == skeleton debug info + dwp debug info.
+  if (std::shared_ptr<SymbolFileDWARFDwo> dwp_sp = GetDwpSymbolFile())
+    return debug_info_size + dwp_sp->GetDebugInfoSize();
+
+  // In dwo scenario, debug info == skeleton debug info + all dwo debug info.
+  for (uint32_t i = 0; i < num_comp_units; i++) {
+    DWARFUnit *cu = info.GetUnitAtIndex(i);
+    if (cu == nullptr)
+      continue;
+
+    SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
----------------
clayborg wrote:

This call will force the .dwo files to be loaded, even if they are not. I would 
suggest adding a default boolean parameter to this function in 
SymbolFileWARFDwo.h:
```
  SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_if_needed = true);
```
And then change the implementation to:
```
SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile(bool load_if_needed) {
  if (load_if_needed)
    ExtractUnitDIEIfNeeded();
  if (m_dwo)
    return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
  return nullptr;
}
```
This way we won't end up pulling in all of the debug info just to answer the 
questions.

It all comes down to what we want to know from a call to 
`SymbolFileDWARF::GetDebugInfoSize()`:
- total currently loaded debug info (then my suggestion above stands)
- total possible debug info size (ignore suggestion)

So I would suggest we figure this out and then document the 
`SymbolFile::GetDebugInfoSize()` headerdoc appropriately.


https://github.com/llvm/llvm-project/pull/80218
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to