[lldb-dev] PATCH for REVIEW: Implement Linux Host::FindProcesses()

Michael Sartain mikesart at valvesoftware.com
Thu May 16 13:09:48 PDT 2013


On Thu, May 16, 2013 at 11:50 AM, Greg Clayton <gclayton at apple.com> wrote:

>
> On May 16, 2013, at 11:32 AM, Michael Sartain <mikesart at valvesoftware.com>
> wrote:
>
> > On Thu, May 16, 2013 at 10:39 AM, Malea, Daniel <daniel.malea at intel.com>
> wrote:
> > If we only support one ModuleSpec on Linux, maybe add:
> >
> > assert(num_specs == 1 && "Linux plugin supports only a single
> > architecture");
> >
> > Yeah, that makes me feel more comfortable with that "== 1" check. It's
> in.
> >
> > I ran into an issue where TargetList::CreateTarget() was failing because
> it's calling ObjectFile::GetModuleSpecifications() and getting back x86_64
> / UnknownVendor / UnknownOS and is expecting to find the Linux for the OS
> when it calls IsCompatibleMatch().
> >
> > So I modified ArchSpec::SetArchitecture() to set the Linux OS using an
> ifdef in ArchSpec.cpp. Is this the best way to do this?
>
> No, I would do this by modifying all the architectures in ModuleSpec
> objects that are returned from ObjectFile::GetModuleSpecifications() inside
> GetELFProcessCPUType().
>

Sorry I wasn't clear - this issue has nothing to do with the code in
Linux/Host.cpp. It's showing up because we've now implemented
ObjectFileELF::GetModuleSpecifications().

It's returning x86_64 / UnknownVendor / UnknownOS for this target I'm
trying to debug where it used to return nothing. Ie, invalid arch.

So in PlatformLinux.cpp, we are now running the exe_arch.IsValid() block
down below (used to take the else clause).

m_arch in module_spec is:
    Arch = llvm::Triple::x86_64,
    Vendor = llvm::Triple::UnknownVendor,
    OS = llvm::Triple::Linux,
    Environment = llvm::Triple::GNU
exe_arch is:
    Arch = llvm::Triple::x86_64,
    Vendor = llvm::Triple::UnknownVendor,
    OS = llvm::Triple::UnknownOS,
    Environment = llvm::Triple::UnknownEnvironment

ModuleList::GetShareModule() fails and reports my exe doesn't contain
"x86_64". Modifying the code in ArchSpec to return Linux isn't the correct
solution, but what is? Something local here where if OS is Unknown we match
any OS?

Thanks.

    if (error.Success())
    {
        ModuleSpec module_spec (resolved_exe_file, exe_arch);
        if (exe_arch.IsValid())
        {
            error = ModuleList::GetSharedModule (module_spec,
                                                 exe_module_sp,
                                                 NULL,
                                                 NULL,
                                                 NULL);

            // TODO find out why exe_module_sp might be NULL
            if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL)
            {
                exe_module_sp.reset();
                error.SetErrorStringWithFormat ("'%s' doesn't contain the
architecture %s",
                                                exe_file.GetPath().c_str(),

exe_arch.GetArchitectureName());
            }
        }
        else
        {
            // No valid architecture was specified, ask the platform for
            // the architectures that we should be using (in the correct
order)
            // and see if we can find a match that way
            StreamString arch_names;
            for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx,
module_spec.GetArchitecture()); ++idx)
            {
                error = ModuleList::GetSharedModule (module_spec,
                                                     exe_module_sp,
                                                     NULL,
                                                     NULL,
                                                     NULL);
                // Did we find an executable using one of the
                if (error.Success())
                {
                    if (exe_module_sp && exe_module_sp->GetObjectFile())
                        break;
                    else
                        error.SetErrorToGenericError();
                }

                if (idx > 0)
                    arch_names.PutCString (", ");
                arch_names.PutCString
(module_spec.GetArchitecture().GetArchitectureName());
            }

            if (error.Fail() || !exe_module_sp)
            {
                error.SetErrorStringWithFormat ("'%s' doesn't contain any
'%s' platform architectures: %s",
                                                exe_file.GetPath().c_str(),

GetPluginName().GetCString(),

arch_names.GetString().c_str());
            }
        }
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20130516/ecc77b57/attachment.html>


More information about the lldb-dev mailing list