Set path syntax for remote executable FileSpec.

Reviewers: ovyalov, zturner

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D9579

llvm-svn: 236925
This commit is contained in:
Chaoren Lin 2015-05-09 01:21:32 +00:00
parent f5132e70cc
commit f34f410e0a
4 changed files with 18 additions and 11 deletions

View File

@ -78,6 +78,8 @@ public:
//------------------------------------------------------------------ //------------------------------------------------------------------
explicit FileSpec (const char *path, bool resolve_path, PathSyntax syntax = ePathSyntaxHostNative); explicit FileSpec (const char *path, bool resolve_path, PathSyntax syntax = ePathSyntaxHostNative);
explicit FileSpec (const char *path, bool resolve_path, ArchSpec arch);
//------------------------------------------------------------------ //------------------------------------------------------------------
/// Copy constructor /// Copy constructor
/// ///

View File

@ -27,6 +27,7 @@
#include <pwd.h> #include <pwd.h>
#endif #endif
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataBufferMemoryMap.h" #include "lldb/Core/DataBufferMemoryMap.h"
#include "lldb/Core/RegularExpression.h" #include "lldb/Core/RegularExpression.h"
@ -201,6 +202,11 @@ FileSpec::FileSpec(const char *pathname, bool resolve_path, PathSyntax syntax) :
SetFile(pathname, resolve_path, syntax); SetFile(pathname, resolve_path, syntax);
} }
FileSpec::FileSpec(const char *pathname, bool resolve_path, ArchSpec arch) :
FileSpec(pathname, resolve_path, arch.GetTriple().isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix)
{
}
//------------------------------------------------------------------ //------------------------------------------------------------------
// Copy constructor // Copy constructor
//------------------------------------------------------------------ //------------------------------------------------------------------
@ -605,11 +611,10 @@ FileSpec::RemoveBackupDots (const ConstString &input_const_str, ConstString &res
void void
FileSpec::Dump(Stream *s) const FileSpec::Dump(Stream *s) const
{ {
static ConstString g_slash_only ("/");
if (s) if (s)
{ {
m_directory.Dump(s); m_directory.Dump(s);
if (m_directory && m_directory != g_slash_only) if (m_directory && m_directory.GetStringRef().back() != '/')
s->PutChar('/'); s->PutChar('/');
m_filename.Dump(s); m_filename.Dump(s);
} }
@ -810,10 +815,9 @@ FileSpec::GetPath(bool denormalize) const
void void
FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize) const FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize) const
{ {
if (m_directory) StreamString stream;
path.append(m_directory.GetCString(), m_directory.GetCString() + m_directory.GetLength()); Dump(&stream);
if (m_filename) path.append(stream.GetString().begin(), stream.GetString().end());
llvm::sys::path::append(path, m_filename.GetCString());
Normalize(path, m_syntax); Normalize(path, m_syntax);
if (denormalize && !path.empty()) if (denormalize && !path.empty())
DeNormalize(path, m_syntax); DeNormalize(path, m_syntax);

View File

@ -1312,7 +1312,7 @@ GDBRemoteCommunicationClient::SendArgumentsPacket (const ProcessLaunchInfo &laun
const char *arg = NULL; const char *arg = NULL;
const Args &launch_args = launch_info.GetArguments(); const Args &launch_args = launch_info.GetArguments();
if (exe_file) if (exe_file)
exe_path = exe_file.GetPath(false); exe_path = exe_file.GetPath();
else else
{ {
arg = launch_args.GetArgumentAtIndex(0); arg = launch_args.GetArgumentAtIndex(0);
@ -3744,8 +3744,8 @@ GDBRemoteCommunicationClient::GetModuleInfo (const FileSpec& module_file_spec,
packet.PutCString("qModuleInfo:"); packet.PutCString("qModuleInfo:");
packet.PutCStringAsRawHex8(module_path.c_str()); packet.PutCStringAsRawHex8(module_path.c_str());
packet.PutCString(";"); packet.PutCString(";");
const auto& tripple = arch_spec.GetTriple().getTriple(); const auto& triple = arch_spec.GetTriple().getTriple();
packet.PutBytesAsRawHex8(tripple.c_str(), tripple.size()); packet.PutBytesAsRawHex8(triple.c_str(), triple.size());
StringExtractorGDBRemote response; StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false) != PacketResult::Success) if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false) != PacketResult::Success)
@ -3795,7 +3795,7 @@ GDBRemoteCommunicationClient::GetModuleInfo (const FileSpec& module_file_spec,
extractor.GetStringRef ().swap (value); extractor.GetStringRef ().swap (value);
extractor.SetFilePos (0); extractor.SetFilePos (0);
extractor.GetHexByteString (value); extractor.GetHexByteString (value);
module_spec.GetFileSpec () = FileSpec (value.c_str(), false); module_spec.GetFileSpec() = FileSpec(value.c_str(), false, arch_spec);
} }
} }

View File

@ -2377,8 +2377,9 @@ Target::Install (ProcessLaunchInfo *launch_info)
if (is_main_executable) // TODO: add setting for always installing main executable??? if (is_main_executable) // TODO: add setting for always installing main executable???
{ {
// Always install the main executable // Always install the main executable
remote_file = FileSpec(module_sp->GetFileSpec().GetFilename().AsCString(),
false, module_sp->GetArchitecture());
remote_file.GetDirectory() = platform_sp->GetWorkingDirectory(); remote_file.GetDirectory() = platform_sp->GetWorkingDirectory();
remote_file.GetFilename() = module_sp->GetFileSpec().GetFilename();
} }
} }
if (remote_file) if (remote_file)