[Lldb-commits] [lldb] Fix GetDIE is outside of its CU error from	.debug_names (PR #157574)
    David Peixotto via lldb-commits 
    lldb-commits at lists.llvm.org
       
    Tue Sep  9 13:07:35 PDT 2025
    
    
  
================
@@ -131,8 +131,12 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const DebugNames::Entry &entry) const {
     unit_offset = entry.getLocalTUOffset();
   if (unit_offset) {
     if (DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo,
-                                                     *unit_offset))
-      return &cu->GetNonSkeletonUnit();
+                                                     *unit_offset)) {
+      DWARFUnit &ret = cu->GetNonSkeletonUnit();
----------------
dmpots wrote:
It seems suprising that the `GetNonSkeletonUnit()` call can actually return a skeleton unit. Maybe a better approach here would be to model the fact that we can actually fail to find the non-skeleton unit by returning an `Expected`
```
llvm::Expected<DWARFUnit&> DWARFUnit::GetNonSkeletonUnit() 
```
I did a quick search and see other
[examples](https://github.com/llvm/llvm-project/blob/a76dc5599d4bf55a9bd7347e1a4ca22c77111168/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp#L258) where it looks like we might hit this same bug.
https://github.com/llvm/llvm-project/pull/157574
    
    
More information about the lldb-commits
mailing list