[lldb-dev] Loading Linux core files

Greg Clayton gclayton at apple.com
Wed Jul 15 13:52:44 PDT 2015


> On Jul 13, 2015, at 4:22 PM, Ted Woodward <ted.woodward at codeaurora.org> wrote:
> 
> I’m trying to load a core file on Ubuntu 12, but I’m getting an assert in ThreadElfCore::CreateRegisterContextForFrame() because the arch.GetTriple().getOS() returns UnknownOS instead of Linux.
>  
> I’ve stepped through loading my binary, and the target’s OS Is correctly set to Linux. But ProcessElfCore::DoLoadCore() has this code:
>     // Even if the architecture is set in the target, we need to override
>     // it to match the core file which is always single arch.
>     ArchSpec arch (m_core_module_sp->GetArchitecture());
>     if (arch.IsValid())
>         m_target.SetArchitecture(arch);
>  
> The problem is Linux core files don’t have anything in them to indicate that they are Linux. Linux is identified through a note that is added by gcc/clang, but isn’t in the core file. So x86-64-unknown-Linux gets replaced by x86-64-unknown-unknown.
>  
> I’m thinking of changing this to not override the architecture if the target’s OS is Linux. Any thoughts?

You should get the target architecture and merge the one from the core file and then set the target architecture using that.


ArchSpec target_arch = m_target.GetArchitecture();
ArchSpec core_arch = m_core_module_sp->GetArchitecture();

target_arch.MergeFrom(core_arch);

if (arch.IsValid())
    m_target.SetArchitecture(arch);

This way any unspecified unknowns will not replace what is in the target's original architecture.

Greg





More information about the lldb-dev mailing list