[lldb-dev] Calling Host methods from Platform plugins

Greg Clayton gclayton at apple.com
Thu Aug 21 16:03:20 PDT 2014


> On Aug 21, 2014, at 11:03 AM, Zachary Turner <zturner at google.com> wrote:
> 
> But then wouldn't the appropriate way to do it be to send a request to the debugserver which would then ask its PlatformMacOSX, which would find out it's the local platform, and then call into the Host layer?  Even remote debugging from MacOSX -> MacOSX, it's possible that some value returned by the host layer (we'll use the bundle directory since it was the original example) might be different on the two machines.  Now your #if defined(__APPLE__) preprocessor check passes, you get the bundle directory from the host layer, and it's different from the value on the remote.

You might not be connected, nor are you required to be connected to a remote platform for it to be able to resolve a bundle executable given a bundle "c:\My Documents\Foo.app", or be able to find the bundle directory for "c:\My Documents\Foo.app\Contents\MacOS\Foo" by returning "c:\My Documents\Foo.app". No connection is required. The platform should be able to do the right thing. If you compile on a Mac, you can use the host layer. If you don't we will need to implement that functionality manually.


> 
> 
> On Thu, Aug 21, 2014 at 10:07 AM, Greg Clayton <gclayton at apple.com> wrote:
> 
> > On Aug 20, 2014, at 4:29 PM, Zachary Turner <zturner at google.com> wrote:
> >
> > There are many examples of this, but just to pick one at random, PlatformDarwin::GetSharedModule() has a codepath which calls Host::GetBundleDirectory.  This is probably the correct thing to do if it's the local platform, but it seems to be always the wrong thing to do if this is not the local platform.  Is there something I'm misunderstanding that makes this work?  Shouldn't this kind of thing be behind an IsHost() check?
> 
> No. If you are remote debugging a MacOSX app, the platform should still be able to find the bundle directory.
> 
> windows% lldb
> (lldb) platform select remote-macosx
> (lldb) file Foo.app
> 
> That being said, the code that uses native code to find the bundle directory should be placed into the Host directory and then PlatformDarwin should check #if defined(__APPLE__) and only use the host layer if it is running on Apple and fall back to other code when not native.
> 
> Greg
> 
> 




More information about the lldb-dev mailing list