2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBFileSpec.cpp ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-04-08 21:36:44 +08:00
|
|
|
#include <limits.h>
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBFileSpec.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2011-02-08 13:05:52 +08:00
|
|
|
#include "lldb/Host/FileSpec.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2011-11-13 14:57:31 +08:00
|
|
|
#include "lldb/Core/Stream.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SBFileSpec::SBFileSpec () :
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
m_opaque_ap(new lldb_private::FileSpec())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBFileSpec::SBFileSpec (const SBFileSpec &rhs) :
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
m_opaque_ap(new lldb_private::FileSpec(*rhs.m_opaque_ap))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
SBFileSpec::SBFileSpec (const lldb_private::FileSpec& fspec) :
|
|
|
|
m_opaque_ap(new lldb_private::FileSpec(fspec))
|
|
|
|
{
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-21 04:54:39 +08:00
|
|
|
// Deprected!!!
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec::SBFileSpec (const char *path) :
|
2010-10-21 04:54:39 +08:00
|
|
|
m_opaque_ap(new FileSpec (path, true))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBFileSpec::SBFileSpec (const char *path, bool resolve) :
|
|
|
|
m_opaque_ap(new FileSpec (path, resolve))
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBFileSpec::~SBFileSpec ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SBFileSpec &
|
|
|
|
SBFileSpec::operator = (const SBFileSpec &rhs)
|
|
|
|
{
|
|
|
|
if (this != &rhs)
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
*m_opaque_ap = *rhs.m_opaque_ap;
|
2010-06-09 00:52:24 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFileSpec::IsValid() const
|
|
|
|
{
|
2013-10-05 05:35:29 +08:00
|
|
|
return m_opaque_ap->operator bool();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBFileSpec::Exists () const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
bool result = m_opaque_ap->Exists();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2010-10-29 12:59:35 +08:00
|
|
|
log->Printf ("SBFileSpec(%p)::Exists () => %s", m_opaque_ap.get(), (result ? "true" : "false"));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-10 12:48:55 +08:00
|
|
|
bool
|
|
|
|
SBFileSpec::ResolveExecutableLocation ()
|
|
|
|
{
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
return m_opaque_ap->ResolveExecutableLocation ();
|
2010-09-10 12:48:55 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len)
|
|
|
|
{
|
|
|
|
return lldb_private::FileSpec::Resolve (src_path, dst_path, dst_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2010-08-28 06:35:26 +08:00
|
|
|
SBFileSpec::GetFilename() const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
const char *s = m_opaque_ap->GetFilename().AsCString();
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-31 11:01:06 +08:00
|
|
|
{
|
|
|
|
if (s)
|
|
|
|
log->Printf ("SBFileSpec(%p)::GetFilename () => \"%s\"", m_opaque_ap.get(), s);
|
|
|
|
else
|
|
|
|
log->Printf ("SBFileSpec(%p)::GetFilename () => NULL", m_opaque_ap.get());
|
|
|
|
}
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
return s;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBFileSpec::GetDirectory() const
|
|
|
|
{
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
const char *s = m_opaque_ap->GetDirectory().AsCString();
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-30 12:51:46 +08:00
|
|
|
if (log)
|
2010-10-31 11:01:06 +08:00
|
|
|
{
|
|
|
|
if (s)
|
|
|
|
log->Printf ("SBFileSpec(%p)::GetDirectory () => \"%s\"", m_opaque_ap.get(), s);
|
|
|
|
else
|
|
|
|
log->Printf ("SBFileSpec(%p)::GetDirectory () => NULL", m_opaque_ap.get());
|
|
|
|
}
|
2010-10-30 12:51:46 +08:00
|
|
|
return s;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2013-11-21 05:07:01 +08:00
|
|
|
void
|
|
|
|
SBFileSpec::SetFilename(const char *filename)
|
|
|
|
{
|
|
|
|
if (filename && filename[0])
|
|
|
|
m_opaque_ap->GetFilename().SetCString(filename);
|
|
|
|
else
|
|
|
|
m_opaque_ap->GetFilename().Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBFileSpec::SetDirectory(const char *directory)
|
|
|
|
{
|
|
|
|
if (directory && directory[0])
|
|
|
|
m_opaque_ap->GetDirectory().SetCString(directory);
|
|
|
|
else
|
|
|
|
m_opaque_ap->GetDirectory().Clear();
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
uint32_t
|
|
|
|
SBFileSpec::GetPath (char *dst_path, size_t dst_len) const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
uint32_t result = m_opaque_ap->GetPath (dst_path, dst_len);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
2012-11-30 05:49:15 +08:00
|
|
|
log->Printf ("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%" PRIu64 ") => %u",
|
2012-09-19 02:04:04 +08:00
|
|
|
m_opaque_ap.get(), result, dst_path, (uint64_t)dst_len, result);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-10-31 11:01:06 +08:00
|
|
|
if (result == 0 && dst_path && dst_len > 0)
|
2010-06-09 00:52:24 +08:00
|
|
|
*dst_path = '\0';
|
2010-10-31 11:01:06 +08:00
|
|
|
return result;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const lldb_private::FileSpec *
|
|
|
|
SBFileSpec::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::FileSpec *
|
|
|
|
SBFileSpec::get() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const lldb_private::FileSpec &
|
|
|
|
SBFileSpec::operator*() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::FileSpec &
|
|
|
|
SBFileSpec::ref() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
SBFileSpec::SetFileSpec (const lldb_private::FileSpec& fs)
|
|
|
|
{
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
*m_opaque_ap = fs;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-10-26 11:11:13 +08:00
|
|
|
bool
|
|
|
|
SBFileSpec::GetDescription (SBStream &description) const
|
|
|
|
{
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
Added a way to extract the module specifications from a file. A module specification is information that is required to describe a module (executable, shared library, object file, ect). This information includes host path, platform path (remote path), symbol file path, UUID, object name (for objects in .a files for example you could have an object name of "foo.o"), and target triple. Module specification can be used to create a module, or used to add a module to a target. A list of module specifications can be used to enumerate objects in container objects (like universal mach files and BSD archive files).
There are two new classes:
lldb::SBModuleSpec
lldb::SBModuleSpecList
The SBModuleSpec wraps up a lldb_private::ModuleSpec, and SBModuleSpecList wraps up a lldb_private::ModuleSpecList.
llvm-svn: 185877
2013-07-09 06:22:41 +08:00
|
|
|
char path[PATH_MAX];
|
|
|
|
if (m_opaque_ap->GetPath(path, sizeof(path)))
|
|
|
|
strm.PutCString (path);
|
2010-10-26 11:11:13 +08:00
|
|
|
return true;
|
|
|
|
}
|