clayborg added a comment.

I should clarify: mach-o files do have functions at zero and these are legal 
DWARF and we need to read this DWARF correctly. We might be able to ask the 
SymbolFile's ObjectFile about this address and if it can be a valid function 
address using:

  AddressClass ObjectFile::GetAddressClass (lldb::addr_t file_addr);


================
Comment at: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:2243-2247
@@ +2242,7 @@
+
+        // lowest_func_addr is a file address what can't be 0 because at 
address 0 we should have the
+        // file header. It is 0 if the linker optimized out the given function 
when we don't want to
+        // return an invalid function object.
+        if (lowest_func_addr == 0)
+            return nullptr;
+
----------------
We might be able to ask the SymbolFile's ObjectFile if zero can be a valid code 
address. Then this could would become:

```
if (lowest_func_addr == 0 && 
objfile->FileAddressIsValidForCode(lowest_func_addr)
{
}
```

Or we might be able to ask the address class of an address:

```
const AddressClass addr_class = obj_file->GetAddressClass (lowest_func_addr);
if (addr_class != eAddressClassCode && addr_class != 
eAddressClassCodeAlternateISA)
    return nullptr;
```

We would need to make sure that an address of zero in a mach-o .o file returns 
eAddressClassCode or eAddressClassCodeAlternateISA type.



http://reviews.llvm.org/D12804



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to