<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 15, 2013 at 2:03 PM, Greg Clayton <span dir="ltr"><<a href="mailto:gclayton@apple.com" target="_blank">gclayton@apple.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The correct fix for this is to fill in the GetModuleSpecifications() in ObjectFileELF:</blockquote>
</div>
<br></div><div class="gmail_extra">How does the below look? It's definitely cleaner. I stepped through all the code and performance seems more than acceptable as well.<br><br>Fire any feedback my way when you get a chance and I'll test it some more and hopefully get this in tomorrow assuming it's all ok.<br>

<br>Thanks!<br></div><div class="gmail_extra"> -Mike<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">in linux/Host.cpp:<br></div><div class="gmail_extra"><br>static bool<br>GetELFProcessCPUType (const char *exe_path, ProcessInstanceInfo &process_info)<br>

{<br>    // Clear the architecture.<br>    process_info.GetArchitecture().Clear();<br><br>    ModuleSpecList specs;<br>    FileSpec filespec (exe_path, false);<br>    const size_t num_specs = ObjectFile::GetModuleSpecifications (filespec, 0, specs);<br>

    if (num_specs >= 1)<br>    {<br>        ModuleSpec module_spec;<br>        if (specs.GetModuleSpecAtIndex (0, module_spec) && module_spec.GetArchitecture().IsValid())<br>        {<br>            process_info.GetArchitecture () = module_spec.GetArchitecture();<br>

            // SetArchitecture() in ArchSpec.cpp sets vendor and os to unknown. Reset them to PC and Linux.<br>            process_info.GetArchitecture ().GetTriple().setVendor (llvm::Triple::PC);<br>            process_info.GetArchitecture ().GetTriple().setOS (llvm::Triple::Linux);<br>

            return true;<br>        }<br>    }<br>    return false;<br>}<br><br></div><div class="gmail_extra">in ELF/ObjectFileELF.cpp:<br><br>bool<br>ObjectFileELF::MagicBytesMatch (DataBufferSP& data_sp,<br>                                  lldb::addr_t data_offset,<br>

                                  lldb::addr_t data_length)<br>{<br>    if (data_sp && data_sp->GetByteSize() > (llvm::ELF::EI_NIDENT + data_offset))<br>    {<br>        const uint8_t *magic = data_sp->GetBytes() + data_offset;<br>

        return ELFHeader::MagicBytesMatch(magic);<br>    }<br>    return false;<br>}<br><br>size_t<br>ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file,<br>                                        lldb::DataBufferSP& data_sp,<br>

                                        lldb::offset_t data_offset,<br>                                        lldb::offset_t file_offset,<br>                                        lldb::offset_t length,<br>                                        lldb_private::ModuleSpecList &specs)<br>

{<br>    const size_t initial_count = specs.GetSize();<br>    <br>    if (ObjectFileELF::MagicBytesMatch(data_sp, 0, data_sp->GetByteSize()))<br>    {<br>        DataExtractor data;<br>        data.SetData(data_sp);<br>

        elf::ELFHeader header;<br>        if (header.Parse(data, &data_offset))<br>        {<br>            if (data_sp)<br>            {<br>                ModuleSpec spec;<br>                spec.GetFileSpec() = file;<br>

                spec.GetArchitecture().SetArchitecture(eArchTypeELF,<br>                                                       header.e_machine,<br>                                                       LLDB_INVALID_CPUTYPE);<br>

                if (spec.GetArchitecture().IsValid())<br>                {<br>                    // ObjectFileMachO adds the UUID here also, but that isn't in the elf header<br>                    // so we'd have to read the entire file in and calculate the md5sum.<br>

                    // That'd be bad for this routine...<br>                    specs.Append(spec);<br>                }<br>            }<br>        }<br>    }<br>    return specs.GetSize() - initial_count;<br>}<br></div>

</div>