after you create the target, you need to grab the executable module from the SBTarget and call "SBModule::SetPlatformFileSpec(SBFileSpec)" on it.
// First create debugger
SBTarget target = debugger.CreateTarget("/local/path/a.out", "x86_64-apple-macosx", "remote-macosx", false, error);
SBModule exe_module = target.FindModule(target.GetExecutable());
Then set the platform path:
SBFileSpec remote_path ("/remote/path/a.out", false);
process = target.ConnectRemote(...)
This will only work if you are connecting to a debugserver that is not running a process yet. There are two ways to start debugserver:
1 - with no process
2 - have it launch a process and wait to attach
We will assume we have two hosts here: local.foo.com (where you want to debug from), remote.foo.com (the remote host which will run the process).
When you launch with no process, you start debugserver with no process specified:
remote.foo.com% debugserver remote.foo.com:1234
Then you would follow the exact steps from above.
If you launch debugserver and give it a process already:
remote.foo.com% debugserver remote.foo.com:1234 -- /remote/path/a.out --arg --foo --bar
Then after you call ConnectRemote() you should have a live process and you won't require a remote launch. LLDB will be able to match up the remote path coming in ("/remote/path/a.out") with your local path by matching the UUID values as long as you created your target with the correct local copy of your binary ("/local/path/a.out"), with no need to call "SetPlatformFileSpec()".
Likewise if you have 4 shared libraries that you built locally and are somehow loading moving them over to the remote system so they get used while debugging and these files are not part of your normal sysroot that you mounted, you can tell the target about the local copies:
SBModule shlib_module1 = target.AddModule ("/local/path/libfoo.dylib", "x86_64-apple-macosx", NULL);
SBModule shlib_module2 = target.AddModule ("/local/path/libbar.dylib", "x86_64-apple-macosx", NULL);
SBModule shlib_module3 = target.AddModule ("/local/path/libbaz.dylib", "x86_64-apple-macosx", NULL);
You do this right after creating your target. Then LLDB knows about these shared libraries in its global module cache and can find them when we connect to your process even if the paths are totally different and even if you don't cal SetPlatformFileSpec on each module.