[Lldb-commits] TargetList.cpp changes from [PATCH] Merge of Linux and FreeBSD

dawn at burble.org dawn at burble.org
Wed Jan 4 21:25:39 PST 2012


Here's some background for why the changes to TargetList.cpp were needed.  

On Wed, Jan 04, 2012 at 06:04:17PM -0800, dawn at burble.org wrote:
>     lldb_svnR147560_POSIX_TargetList.patch - changes to TargetList.cpp separated out.
> 
> The changes to TargetList.cpp are needed by both BSD and Linux in order for
> Attach() to work.  I spent a lot of time debugging this one, and the BSD folks
> came to the same conclusion.  I'll dig through my notes and try to write up my
> findings - should this be discussed here or on lldb-dev?

Perhaps the BSD folks can add more based on their experience, but
here's what I remember the problem being:

When attaching, TargetList::CreateTarget() is called with
file = 0 since it's not known yet.
So in the nested call to TargetList::CreateTarget() we do
    target_sp.reset(new Target(debugger, arch, platform_sp));
    (around line TargetList.cpp:155).
This causes Target to be created with an invalid arch, and
things head downhill from there.

We do have a default arch set in platform_sp however from:
    platform_sp = debugger.GetPlatformList().GetSelectedPlatform (); 
    (around line TargetList.cpp:73).
giving us m_selected_platform_sp.m_system_arch.m_triple.Data
            = "i386-pc-linux-gnu".
But no where is this default copied to the target.
What's supposed to happen here?


As a work-around, could we add code like
    if (!arch.IsValid())
        arch = Host::GetArchitecture(Host::eSystemDefaultArchitecture);
before the call to
    target_sp.reset(new Target(debugger, arch, platform_sp));
    (around line TargetList.cpp:155)?


Thanks for any help,
    -Dawn




More information about the lldb-commits mailing list