Inquiry about SBFileSpec

The SBFileSpec class of APIs can be used to read files on the local file system right ? I want to know if it can be used for reading files on the remote file system ? or do we need to use some other API ?

A Ravi Theja

The SBPlatform that you can get from your SBTarget is the way to do this correctly:

SBPlatform platform = target.GetPlatform();

SBFileSpec src("/some/remote/path/to/remote/file/file.txt", false);
SBFileSpec dst("/tmp/file.txt");
SBError error = platform.Get (src, dst);

Then you can plat with "dst" locally on your machine. This of course means that you have to be connected to the remote platform. The "lldb-server" we build can be used as a platform that can be started and allows the local LLDB to attach to the remote platform.

So on the remote machine you would start your "lldb-server" in platform mode: lldb-server platform [options]

Then you can attach your platform to this:

% lldb
(lldb) platform select remote-linux
(lldb) platform connect

now you are connected and can run things remotely and get files from the platform:

(lldb) platform settings --working-dir "/tmp"
(lldb) file a.out
(lldb) run

Since we are connected to a platform, the main executable of any target will be sent over to the remote machine in the platform's working directory and then run from there.

And if you are connected, you can get the platform from the current target and transfer files.