llvm-project/lldb/source/Core/StreamFile.cpp
Greg Clayton fbb7634934 Expose SBPlatform through the public API.
Example code:

remote_platform = lldb.SBPlatform("remote-macosx"); 
remote_platform.SetWorkingDirectory("/private/tmp")
debugger.SetSelectedPlatform(remote_platform)

connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); 
err = remote_platform.ConnectRemote(connect_options)
if err.Success():
    print >> result, 'Connected to remote platform:'
    print >> result, 'hostname: %s' % (remote_platform.GetHostname())
    src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False)
    dst = lldb.SBFileSpec()
    # copy src to platform working directory since "dst" is empty
    err = remote_platform.Install(src, dst);
    if err.Success():
        print >> result, '%s installed successfully' % (src)
    else:
        print >> result, 'error: failed to install "%s": %s' % (src, err)


Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories.

The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform.

The API in SBPlatform is subject to change and will be getting many new functions.

llvm-svn: 195273
2013-11-20 21:07:01 +00:00

73 lines
1.5 KiB
C++

//===-- StreamFile.cpp ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/StreamFile.h"
// C Includes
#include <stdio.h>
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Error.h"
using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
// StreamFile constructor
//----------------------------------------------------------------------
StreamFile::StreamFile () :
Stream (),
m_file ()
{
}
StreamFile::StreamFile (uint32_t flags, uint32_t addr_size, ByteOrder byte_order) :
Stream (flags, addr_size, byte_order),
m_file ()
{
}
StreamFile::StreamFile (int fd, bool transfer_ownership) :
Stream (),
m_file (fd, transfer_ownership)
{
}
StreamFile::StreamFile (FILE *fh, bool transfer_ownership) :
Stream (),
m_file (fh, transfer_ownership)
{
}
StreamFile::StreamFile (const char *path) :
Stream (),
m_file (path, File::eOpenOptionWrite | File::eOpenOptionCanCreate, lldb::eFilePermissionsFileDefault)
{
}
StreamFile::~StreamFile()
{
}
void
StreamFile::Flush ()
{
m_file.Flush();
}
size_t
StreamFile::Write (const void *s, size_t length)
{
m_file.Write (s, length);
return length;
}