summaryrefslogtreecommitdiff
path: root/source/Plugins/Platform
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /source/Plugins/Platform
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
Notes
Diffstat (limited to 'source/Plugins/Platform')
-rw-r--r--source/Plugins/Platform/Android/AdbClient.cpp414
-rw-r--r--source/Plugins/Platform/Android/AdbClient.h82
-rw-r--r--source/Plugins/Platform/Android/Makefile14
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.cpp57
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.h6
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp17
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h3
-rw-r--r--source/Plugins/Platform/FreeBSD/Makefile14
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp77
-rw-r--r--source/Plugins/Platform/Kalimba/Makefile14
-rw-r--r--source/Plugins/Platform/Linux/Makefile14
-rw-r--r--source/Plugins/Platform/Linux/PlatformLinux.cpp99
-rw-r--r--source/Plugins/Platform/Linux/PlatformLinux.h4
-rw-r--r--source/Plugins/Platform/MacOSX/Makefile34
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp2
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp2
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp2
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwin.cpp57
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwin.h3
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp19
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp156
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp155
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp78
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp2
-rw-r--r--source/Plugins/Platform/Makefile36
-rw-r--r--source/Plugins/Platform/NetBSD/Makefile14
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp28
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.h4
-rw-r--r--source/Plugins/Platform/POSIX/Makefile14
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp53
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.h7
-rw-r--r--source/Plugins/Platform/Windows/Makefile14
-rw-r--r--source/Plugins/Platform/Windows/PlatformWindows.cpp38
-rw-r--r--source/Plugins/Platform/Windows/PlatformWindows.h4
-rw-r--r--source/Plugins/Platform/gdb-server/Makefile14
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp22
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h3
37 files changed, 891 insertions, 685 deletions
diff --git a/source/Plugins/Platform/Android/AdbClient.cpp b/source/Plugins/Platform/Android/AdbClient.cpp
index 736447fd22d21..1b07ddba59fcd 100644
--- a/source/Plugins/Platform/Android/AdbClient.cpp
+++ b/source/Plugins/Platform/Android/AdbClient.cpp
@@ -8,33 +8,41 @@
//===----------------------------------------------------------------------===//
// Other libraries and framework includes
+#include "AdbClient.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FileUtilities.h"
+
#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataEncoder.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSpec.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/FileUtilities.h"
-
-// Project includes
-#include "AdbClient.h"
#include <limits.h>
#include <algorithm>
+#include <cstdlib>
#include <fstream>
#include <sstream>
+// On Windows, transitive dependencies pull in <Windows.h>, which defines a
+// macro that clashes with a method name.
+#ifdef SendMessage
+#undef SendMessage
+#endif
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_android;
namespace {
-const uint32_t kReadTimeout = 1000000; // 1 second
+const std::chrono::seconds kReadTimeout(8);
const char * kOKAY = "OKAY";
const char * kFAIL = "FAIL";
const char * kDATA = "DATA";
@@ -53,6 +61,35 @@ const uint32_t kDefaultMode = 0100770; // S_IFREG | S_IRWXU | S_IRWXG
const char * kSocketNamespaceAbstract = "localabstract";
const char * kSocketNamespaceFileSystem = "localfilesystem";
+Error
+ReadAllBytes (Connection &conn, void *buffer, size_t size)
+{
+ using namespace std::chrono;
+
+ Error error;
+ ConnectionStatus status;
+ char *read_buffer = static_cast<char*>(buffer);
+
+ auto now = steady_clock::now();
+ const auto deadline = now + kReadTimeout;
+ size_t total_read_bytes = 0;
+ while (total_read_bytes < size && now < deadline)
+ {
+ uint32_t timeout_usec = duration_cast<microseconds>(deadline - now).count();
+ auto read_bytes =
+ conn.Read(read_buffer + total_read_bytes, size - total_read_bytes, timeout_usec, status, &error);
+ if (error.Fail ())
+ return error;
+ total_read_bytes += read_bytes;
+ if (status != eConnectionStatusSuccess)
+ break;
+ now = steady_clock::now();
+ }
+ if (total_read_bytes < size)
+ error = Error("Unable to read requested number of bytes. Connection status: %d.", status);
+ return error;
+}
+
} // namespace
Error
@@ -63,30 +100,39 @@ AdbClient::CreateByDeviceID(const std::string &device_id, AdbClient &adb)
if (error.Fail())
return error;
- if (device_id.empty())
+ std::string android_serial;
+ if (!device_id.empty())
+ android_serial = device_id;
+ else if (const char *env_serial = std::getenv("ANDROID_SERIAL"))
+ android_serial = env_serial;
+
+ if (android_serial.empty())
{
if (connect_devices.size() != 1)
- return Error("Expected a single connected device, got instead %" PRIu64,
- static_cast<uint64_t>(connect_devices.size()));
-
+ return Error("Expected a single connected device, got instead %zu - try setting 'ANDROID_SERIAL'",
+ connect_devices.size());
adb.SetDeviceID(connect_devices.front());
}
else
{
- auto find_it = std::find(connect_devices.begin(), connect_devices.end(), device_id);
+ auto find_it = std::find(connect_devices.begin(), connect_devices.end(), android_serial);
if (find_it == connect_devices.end())
- return Error("Device \"%s\" not found", device_id.c_str());
+ return Error("Device \"%s\" not found", android_serial.c_str());
adb.SetDeviceID(*find_it);
}
return error;
}
+AdbClient::AdbClient () {}
+
AdbClient::AdbClient (const std::string &device_id)
: m_device_id (device_id)
{
}
+AdbClient::~AdbClient() {}
+
void
AdbClient::SetDeviceID (const std::string &device_id)
{
@@ -103,7 +149,8 @@ Error
AdbClient::Connect ()
{
Error error;
- m_conn.Connect ("connect://localhost:5037", &error);
+ m_conn.reset (new ConnectionFileDescriptor);
+ m_conn->Connect ("connect://localhost:5037", &error);
return error;
}
@@ -131,6 +178,9 @@ AdbClient::GetDevices (DeviceIDList &device_list)
for (const auto device: devices)
device_list.push_back (device.split ('\t').first);
+ // Force disconnect since ADB closes connection after host:devices
+ // response is sent.
+ m_conn.reset ();
return error;
}
@@ -184,7 +234,7 @@ Error
AdbClient::SendMessage (const std::string &packet, const bool reconnect)
{
Error error;
- if (reconnect)
+ if (!m_conn || reconnect)
{
error = Connect ();
if (error.Fail ())
@@ -196,11 +246,11 @@ AdbClient::SendMessage (const std::string &packet, const bool reconnect)
ConnectionStatus status;
- m_conn.Write (length_buffer, 4, status, &error);
+ m_conn->Write (length_buffer, 4, status, &error);
if (error.Fail ())
return error;
- m_conn.Write (packet.c_str (), packet.size (), status, &error);
+ m_conn->Write (packet.c_str (), packet.size (), status, &error);
return error;
}
@@ -251,7 +301,7 @@ AdbClient::ReadMessageStream (std::vector<char>& message, uint32_t timeout_ms)
if (elapsed_time >= timeout_ms)
return Error("Timed out");
- size_t n = m_conn.Read(buffer, sizeof(buffer), 1000 * (timeout_ms - elapsed_time), status, &error);
+ size_t n = m_conn->Read(buffer, sizeof(buffer), 1000 * (timeout_ms - elapsed_time), status, &error);
if (n > 0)
message.insert(message.end(), &buffer[0], &buffer[n]);
}
@@ -304,12 +354,118 @@ AdbClient::SwitchDeviceTransport ()
}
Error
-AdbClient::PullFile (const FileSpec &remote_file, const FileSpec &local_file)
+AdbClient::StartSync ()
+{
+ auto error = SwitchDeviceTransport ();
+ if (error.Fail ())
+ return Error ("Failed to switch to device transport: %s", error.AsCString ());
+
+ error = Sync ();
+ if (error.Fail ())
+ return Error ("Sync failed: %s", error.AsCString ());
+
+ return error;
+}
+
+Error
+AdbClient::Sync ()
{
- auto error = StartSync ();
+ auto error = SendMessage ("sync:", false);
if (error.Fail ())
return error;
+ return ReadResponseStatus ();
+}
+
+Error
+AdbClient::ReadAllBytes (void *buffer, size_t size)
+{
+ return ::ReadAllBytes (*m_conn, buffer, size);
+}
+
+Error
+AdbClient::internalShell(const char *command, uint32_t timeout_ms, std::vector<char> &output_buf)
+{
+ output_buf.clear();
+
+ auto error = SwitchDeviceTransport();
+ if (error.Fail())
+ return Error("Failed to switch to device transport: %s", error.AsCString());
+
+ StreamString adb_command;
+ adb_command.Printf("shell:%s", command);
+ error = SendMessage(adb_command.GetData(), false);
+ if (error.Fail())
+ return error;
+
+ error = ReadResponseStatus();
+ if (error.Fail())
+ return error;
+
+ error = ReadMessageStream(output_buf, timeout_ms);
+ if (error.Fail())
+ return error;
+
+ // ADB doesn't propagate return code of shell execution - if
+ // output starts with /system/bin/sh: most likely command failed.
+ static const char *kShellPrefix = "/system/bin/sh:";
+ if (output_buf.size() > strlen(kShellPrefix))
+ {
+ if (!memcmp(&output_buf[0], kShellPrefix, strlen(kShellPrefix)))
+ return Error("Shell command %s failed: %s", command,
+ std::string(output_buf.begin(), output_buf.end()).c_str());
+ }
+
+ return Error();
+}
+
+Error
+AdbClient::Shell(const char *command, uint32_t timeout_ms, std::string *output)
+{
+ std::vector<char> output_buffer;
+ auto error = internalShell(command, timeout_ms, output_buffer);
+ if (error.Fail())
+ return error;
+
+ if (output)
+ output->assign(output_buffer.begin(), output_buffer.end());
+ return error;
+}
+
+Error
+AdbClient::ShellToFile(const char *command, uint32_t timeout_ms, const FileSpec &output_file_spec)
+{
+ std::vector<char> output_buffer;
+ auto error = internalShell(command, timeout_ms, output_buffer);
+ if (error.Fail())
+ return error;
+
+ const auto output_filename = output_file_spec.GetPath();
+ std::ofstream dst(output_filename, std::ios::out | std::ios::binary);
+ if (!dst.is_open())
+ return Error("Unable to open local file %s", output_filename.c_str());
+
+ dst.write(&output_buffer[0], output_buffer.size());
+ dst.close();
+ if (!dst)
+ return Error("Failed to write file %s", output_filename.c_str());
+ return Error();
+}
+
+std::unique_ptr<AdbClient::SyncService>
+AdbClient::GetSyncService (Error &error)
+{
+ std::unique_ptr<SyncService> sync_service;
+ error = StartSync ();
+ if (error.Success ())
+ sync_service.reset (new SyncService(std::move(m_conn)));
+
+ return sync_service;
+}
+
+Error
+AdbClient::SyncService::internalPullFile (const FileSpec &remote_file, const FileSpec &local_file)
+{
const auto local_file_path = local_file.GetPath ();
llvm::FileRemover local_file_remover (local_file_path.c_str ());
@@ -318,7 +474,7 @@ AdbClient::PullFile (const FileSpec &remote_file, const FileSpec &local_file)
return Error ("Unable to open local file %s", local_file_path.c_str());
const auto remote_file_path = remote_file.GetPath (false);
- error = SendSyncRequest (kRECV, remote_file_path.length (), remote_file_path.c_str ());
+ auto error = SendSyncRequest (kRECV, remote_file_path.length (), remote_file_path.c_str ());
if (error.Fail ())
return error;
@@ -338,12 +494,8 @@ AdbClient::PullFile (const FileSpec &remote_file, const FileSpec &local_file)
}
Error
-AdbClient::PushFile (const FileSpec &local_file, const FileSpec &remote_file)
+AdbClient::SyncService::internalPushFile (const FileSpec &local_file, const FileSpec &remote_file)
{
- auto error = StartSync ();
- if (error.Fail ())
- return error;
-
const auto local_file_path (local_file.GetPath ());
std::ifstream src (local_file_path.c_str(), std::ios::in | std::ios::binary);
if (!src.is_open ())
@@ -352,7 +504,7 @@ AdbClient::PushFile (const FileSpec &local_file, const FileSpec &remote_file)
std::stringstream file_description;
file_description << remote_file.GetPath(false).c_str() << "," << kDefaultMode;
std::string file_description_str = file_description.str();
- error = SendSyncRequest (kSEND, file_description_str.length(), file_description_str.c_str());
+ auto error = SendSyncRequest (kSEND, file_description_str.length(), file_description_str.c_str());
if (error.Fail ())
return error;
@@ -392,67 +544,89 @@ AdbClient::PushFile (const FileSpec &local_file, const FileSpec &remote_file)
}
Error
-AdbClient::StartSync ()
+AdbClient::SyncService::internalStat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime)
{
- auto error = SwitchDeviceTransport ();
+ const std::string remote_file_path (remote_file.GetPath (false));
+ auto error = SendSyncRequest (kSTAT, remote_file_path.length (), remote_file_path.c_str ());
if (error.Fail ())
- return Error ("Failed to switch to device transport: %s", error.AsCString ());
+ return Error ("Failed to send request: %s", error.AsCString ());
- error = Sync ();
+ static const size_t stat_len = strlen (kSTAT);
+ static const size_t response_len = stat_len + (sizeof (uint32_t) * 3);
+
+ std::vector<char> buffer (response_len);
+ error = ReadAllBytes (&buffer[0], buffer.size ());
if (error.Fail ())
- return Error ("Sync failed: %s", error.AsCString ());
+ return Error ("Failed to read response: %s", error.AsCString ());
- return error;
+ DataExtractor extractor (&buffer[0], buffer.size (), eByteOrderLittle, sizeof (void*));
+ offset_t offset = 0;
+
+ const void* command = extractor.GetData (&offset, stat_len);
+ if (!command)
+ return Error ("Failed to get response command");
+ const char* command_str = static_cast<const char*> (command);
+ if (strncmp (command_str, kSTAT, stat_len))
+ return Error ("Got invalid stat command: %s", command_str);
+
+ mode = extractor.GetU32 (&offset);
+ size = extractor.GetU32 (&offset);
+ mtime = extractor.GetU32 (&offset);
+ return Error ();
}
Error
-AdbClient::Sync ()
+AdbClient::SyncService::PullFile (const FileSpec &remote_file, const FileSpec &local_file)
{
- auto error = SendMessage ("sync:", false);
- if (error.Fail ())
- return error;
+ return executeCommand ([this, &remote_file, &local_file]() {
+ return internalPullFile (remote_file, local_file);
+ });
+}
- return ReadResponseStatus ();
+Error
+AdbClient::SyncService::PushFile (const FileSpec &local_file, const FileSpec &remote_file)
+{
+ return executeCommand ([this, &local_file, &remote_file]() {
+ return internalPushFile (local_file, remote_file);
+ });
}
Error
-AdbClient::PullFileChunk (std::vector<char> &buffer, bool &eof)
+AdbClient::SyncService::Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime)
{
- buffer.clear ();
+ return executeCommand ([this, &remote_file, &mode, &size, &mtime]() {
+ return internalStat (remote_file, mode, size, mtime);
+ });
+}
- std::string response_id;
- uint32_t data_len;
- auto error = ReadSyncHeader (response_id, data_len);
- if (error.Fail ())
- return error;
+bool
+AdbClient::SyncService::IsConnected () const
+{
+ return m_conn && m_conn->IsConnected ();
+}
- if (response_id == kDATA)
- {
- buffer.resize (data_len, 0);
- error = ReadAllBytes (&buffer[0], data_len);
- if (error.Fail ())
- buffer.clear ();
- }
- else if (response_id == kDONE)
- {
- eof = true;
- }
- else if (response_id == kFAIL)
- {
- std::string error_message (data_len, 0);
- error = ReadAllBytes (&error_message[0], data_len);
- if (error.Fail ())
- return Error ("Failed to read pull error message: %s", error.AsCString ());
- return Error ("Failed to pull file: %s", error_message.c_str ());
- }
- else
- return Error ("Pull failed with unknown response: %s", response_id.c_str ());
+AdbClient::SyncService::SyncService(std::unique_ptr<Connection> &&conn):
+m_conn(std::move(conn))
+{
+}
- return Error ();
+Error
+AdbClient::SyncService::executeCommand (const std::function<Error()> &cmd)
+{
+ if (!m_conn)
+ return Error ("SyncService is disconnected");
+
+ const auto error = cmd ();
+ if (error.Fail ())
+ m_conn.reset ();
+
+ return error;
}
+AdbClient::SyncService::~SyncService () {}
+
Error
-AdbClient::SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data)
+AdbClient::SyncService::SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data)
{
const DataBufferSP data_sp (new DataBufferHeap (kSyncPacketLen, 0));
DataEncoder encoder (data_sp, eByteOrderLittle, sizeof (void*));
@@ -461,17 +635,17 @@ AdbClient::SendSyncRequest (const char *request_id, const uint32_t data_len, con
Error error;
ConnectionStatus status;
- m_conn.Write (data_sp->GetBytes (), kSyncPacketLen, status, &error);
+ m_conn->Write (data_sp->GetBytes (), kSyncPacketLen, status, &error);
if (error.Fail ())
return error;
if (data)
- m_conn.Write (data, data_len, status, &error);
+ m_conn->Write (data, data_len, status, &error);
return error;
}
Error
-AdbClient::ReadSyncHeader (std::string &response_id, uint32_t &data_len)
+AdbClient::SyncService::ReadSyncHeader (std::string &response_id, uint32_t &data_len)
{
char buffer[kSyncPacketLen];
@@ -488,82 +662,44 @@ AdbClient::ReadSyncHeader (std::string &response_id, uint32_t &data_len)
}
Error
-AdbClient::ReadAllBytes (void *buffer, size_t size)
+AdbClient::SyncService::PullFileChunk (std::vector<char> &buffer, bool &eof)
{
- Error error;
- ConnectionStatus status;
- char *read_buffer = static_cast<char*>(buffer);
-
- size_t tota_read_bytes = 0;
- while (tota_read_bytes < size)
- {
- auto read_bytes = m_conn.Read (read_buffer + tota_read_bytes, size - tota_read_bytes, kReadTimeout, status, &error);
- if (error.Fail ())
- return error;
- tota_read_bytes += read_bytes;
- }
- return error;
-}
+ buffer.clear ();
-Error
-AdbClient::Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime)
-{
- auto error = StartSync ();
+ std::string response_id;
+ uint32_t data_len;
+ auto error = ReadSyncHeader (response_id, data_len);
if (error.Fail ())
return error;
- const std::string remote_file_path (remote_file.GetPath (false));
- error = SendSyncRequest (kSTAT, remote_file_path.length (), remote_file_path.c_str ());
- if (error.Fail ())
- return Error ("Failed to send request: %s", error.AsCString ());
-
- static const size_t stat_len = strlen (kSTAT);
- static const size_t response_len = stat_len + (sizeof (uint32_t) * 3);
-
- std::vector<char> buffer (response_len);
- error = ReadAllBytes (&buffer[0], buffer.size ());
- if (error.Fail ())
- return Error ("Failed to read response: %s", error.AsCString ());
-
- DataExtractor extractor (&buffer[0], buffer.size (), eByteOrderLittle, sizeof (void*));
- offset_t offset = 0;
-
- const void* command = extractor.GetData (&offset, stat_len);
- if (!command)
- return Error ("Failed to get response command");
- const char* command_str = static_cast<const char*> (command);
- if (strncmp (command_str, kSTAT, stat_len))
- return Error ("Got invalid stat command: %s", command_str);
+ if (response_id == kDATA)
+ {
+ buffer.resize (data_len, 0);
+ error = ReadAllBytes (&buffer[0], data_len);
+ if (error.Fail ())
+ buffer.clear ();
+ }
+ else if (response_id == kDONE)
+ {
+ eof = true;
+ }
+ else if (response_id == kFAIL)
+ {
+ std::string error_message (data_len, 0);
+ error = ReadAllBytes (&error_message[0], data_len);
+ if (error.Fail ())
+ return Error ("Failed to read pull error message: %s", error.AsCString ());
+ return Error ("Failed to pull file: %s", error_message.c_str ());
+ }
+ else
+ return Error ("Pull failed with unknown response: %s", response_id.c_str ());
- mode = extractor.GetU32 (&offset);
- size = extractor.GetU32 (&offset);
- mtime = extractor.GetU32 (&offset);
return Error ();
}
Error
-AdbClient::Shell (const char* command, uint32_t timeout_ms, std::string* output)
+AdbClient::SyncService::ReadAllBytes (void *buffer, size_t size)
{
- auto error = SwitchDeviceTransport ();
- if (error.Fail ())
- return Error ("Failed to switch to device transport: %s", error.AsCString ());
-
- StreamString adb_command;
- adb_command.Printf("shell:%s", command);
- error = SendMessage (adb_command.GetData(), false);
- if (error.Fail ())
- return error;
-
- error = ReadResponseStatus ();
- if (error.Fail ())
- return error;
-
- std::vector<char> in_buffer;
- error = ReadMessageStream (in_buffer, timeout_ms);
- if (error.Fail())
- return error;
-
- if (output)
- output->assign(in_buffer.begin(), in_buffer.end());
- return error;
+ return ::ReadAllBytes (*m_conn, buffer, size);
}
+
diff --git a/source/Plugins/Platform/Android/AdbClient.h b/source/Plugins/Platform/Android/AdbClient.h
index 4ec411d1411dd..37973bbdccf85 100644
--- a/source/Plugins/Platform/Android/AdbClient.h
+++ b/source/Plugins/Platform/Android/AdbClient.h
@@ -14,7 +14,9 @@
// C++ Includes
+#include <functional>
#include <list>
+#include <memory>
#include <string>
#include <vector>
@@ -22,7 +24,6 @@
// Project includes
#include "lldb/Core/Error.h"
-#include "lldb/Host/ConnectionFileDescriptor.h"
namespace lldb_private {
@@ -41,12 +42,63 @@ public:
using DeviceIDList = std::list<std::string>;
+ class SyncService
+ {
+ friend class AdbClient;
+
+ public:
+ ~SyncService ();
+
+ Error
+ PullFile (const FileSpec &remote_file, const FileSpec &local_file);
+
+ Error
+ PushFile (const FileSpec &local_file, const FileSpec &remote_file);
+
+ Error
+ Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime);
+
+ bool
+ IsConnected () const;
+
+ private:
+ explicit SyncService (std::unique_ptr<Connection> &&conn);
+
+ Error
+ SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data);
+
+ Error
+ ReadSyncHeader (std::string &response_id, uint32_t &data_len);
+
+ Error
+ PullFileChunk (std::vector<char> &buffer, bool &eof);
+
+ Error
+ ReadAllBytes (void *buffer, size_t size);
+
+ Error
+ internalPullFile (const FileSpec &remote_file, const FileSpec &local_file);
+
+ Error
+ internalPushFile (const FileSpec &local_file, const FileSpec &remote_file);
+
+ Error
+ internalStat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime);
+
+ Error
+ executeCommand (const std::function<Error()> &cmd);
+
+ std::unique_ptr<Connection> m_conn;
+ };
+
static Error
CreateByDeviceID(const std::string &device_id, AdbClient &adb);
- AdbClient () = default;
+ AdbClient ();
explicit AdbClient (const std::string &device_id);
+ ~AdbClient();
+
const std::string&
GetDeviceID() const;
@@ -65,16 +117,16 @@ public:
DeletePortForwarding (const uint16_t local_port);
Error
- PullFile (const FileSpec &remote_file, const FileSpec &local_file);
+ Shell (const char* command, uint32_t timeout_ms, std::string* output);
Error
- PushFile (const FileSpec &local_file, const FileSpec &remote_file);
+ ShellToFile(const char *command, uint32_t timeout_ms, const FileSpec &output_file_spec);
- Error
- Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime);
+ std::unique_ptr<SyncService>
+ GetSyncService (Error &error);
Error
- Shell (const char* command, uint32_t timeout_ms, std::string* output);
+ SwitchDeviceTransport ();
private:
Error
@@ -90,12 +142,6 @@ private:
SendDeviceMessage (const std::string &packet);
Error
- SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data);
-
- Error
- ReadSyncHeader (std::string &response_id, uint32_t &data_len);
-
- Error
ReadMessage (std::vector<char> &message);
Error
@@ -108,25 +154,23 @@ private:
ReadResponseStatus ();
Error
- SwitchDeviceTransport ();
-
- Error
Sync ();
Error
StartSync ();
Error
- PullFileChunk (std::vector<char> &buffer, bool &eof);
+ internalShell(const char *command, uint32_t timeout_ms, std::vector<char> &output_buf);
Error
- ReadAllBytes (void *buffer, size_t size);
+ ReadAllBytes(void *buffer, size_t size);
std::string m_device_id;
- ConnectionFileDescriptor m_conn;
+ std::unique_ptr<Connection> m_conn;
};
} // namespace platform_android
} // namespace lldb_private
#endif // liblldb_AdbClient_h_
+
diff --git a/source/Plugins/Platform/Android/Makefile b/source/Plugins/Platform/Android/Makefile
deleted file mode 100644
index aa186f924e66c..0000000000000
--- a/source/Plugins/Platform/Android/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/Android/Makefile ------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformAndroid
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/Android/PlatformAndroid.cpp b/source/Plugins/Platform/Android/PlatformAndroid.cpp
index e842884c046a3..381795171d363 100644
--- a/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -225,8 +225,36 @@ PlatformAndroid::GetFile (const FileSpec& source,
if (source_spec.IsRelative())
source_spec = GetRemoteWorkingDirectory ().CopyByAppendingPathComponent (source_spec.GetCString (false));
- AdbClient adb (m_device_id);
- return adb.PullFile (source_spec, destination);
+ Error error;
+ auto sync_service = GetSyncService (error);
+ if (error.Fail ())
+ return error;
+
+ uint32_t mode = 0, size = 0, mtime = 0;
+ error = sync_service->Stat(source_spec, mode, size, mtime);
+ if (error.Fail())
+ return error;
+
+ if (mode != 0)
+ return sync_service->PullFile(source_spec, destination);
+
+ auto source_file = source_spec.GetCString(false);
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("Got mode == 0 on '%s': try to get file via 'shell cat'", source_file);
+
+ if (strchr(source_file, '\'') != nullptr)
+ return Error("Doesn't support single-quotes in filenames");
+
+ // mode == 0 can signify that adbd cannot access the file
+ // due security constraints - try "cat ..." as a fallback.
+ AdbClient adb(m_device_id);
+
+ char cmd[PATH_MAX];
+ snprintf(cmd, sizeof(cmd), "cat '%s'", source_file);
+
+ return adb.ShellToFile(cmd, 60000 /* ms */, destination);
}
Error
@@ -242,9 +270,12 @@ PlatformAndroid::PutFile (const FileSpec& source,
if (destination_spec.IsRelative())
destination_spec = GetRemoteWorkingDirectory ().CopyByAppendingPathComponent (destination_spec.GetCString (false));
- AdbClient adb (m_device_id);
// TODO: Set correct uid and gid on remote file.
- return adb.PushFile(source, destination_spec);
+ Error error;
+ auto sync_service = GetSyncService (error);
+ if (error.Fail ())
+ return error;
+ return sync_service->PushFile(source, destination_spec);
}
const char *
@@ -315,8 +346,9 @@ PlatformAndroid::DownloadSymbolFile (const lldb::ModuleSP& module_sp,
const FileSpec& dst_file_spec)
{
// For oat file we can try to fetch additional debug info from the device
- if (module_sp->GetFileSpec().GetFileNameExtension() != ConstString("oat"))
- return Error("Symbol file downloading only supported for oat files");
+ ConstString extension = module_sp->GetFileSpec().GetFileNameExtension();
+ if (extension != ConstString("oat") && extension != ConstString("odex"))
+ return Error("Symbol file downloading only supported for oat and odex files");
// If we have no information about the platform file we can't execute oatdump
if (!module_sp->GetPlatformFileSpec())
@@ -331,7 +363,6 @@ PlatformAndroid::DownloadSymbolFile (const lldb::ModuleSP& module_sp,
return Error("Symtab already available in the module");
AdbClient adb(m_device_id);
-
std::string tmpdir;
Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 5000 /* ms */, &tmpdir);
if (error.Fail() || tmpdir.empty())
@@ -387,3 +418,15 @@ PlatformAndroid::GetLibdlFunctionDeclarations() const
extern "C" char* dlerror(void) asm("__dl_dlerror");
)";
}
+
+AdbClient::SyncService*
+PlatformAndroid::GetSyncService (Error &error)
+{
+ if (m_adb_sync_svc && m_adb_sync_svc->IsConnected ())
+ return m_adb_sync_svc.get ();
+
+ AdbClient adb (m_device_id);
+ m_adb_sync_svc = adb.GetSyncService (error);
+ return (error.Success ()) ? m_adb_sync_svc.get () : nullptr;
+}
+
diff --git a/source/Plugins/Platform/Android/PlatformAndroid.h b/source/Plugins/Platform/Android/PlatformAndroid.h
index 119d0a0bdf04d..6f7a87ca9fef9 100644
--- a/source/Plugins/Platform/Android/PlatformAndroid.h
+++ b/source/Plugins/Platform/Android/PlatformAndroid.h
@@ -12,12 +12,15 @@
// C Includes
// C++ Includes
+#include <memory>
#include <string>
// Other libraries and framework includes
// Project includes
#include "Plugins/Platform/Linux/PlatformLinux.h"
+#include "AdbClient.h"
+
namespace lldb_private {
namespace platform_android {
@@ -102,6 +105,9 @@ namespace platform_android {
GetLibdlFunctionDeclarations() const override;
private:
+ AdbClient::SyncService* GetSyncService (Error &error);
+
+ std::unique_ptr<AdbClient::SyncService> m_adb_sync_svc;
std::string m_device_id;
uint32_t m_sdk_version;
diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
index 3d91dd6b7a32f..f11f2874e3562 100644
--- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -11,6 +11,8 @@
#include "lldb/Core/Error.h"
#include "lldb/Core/Log.h"
#include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Host/ConnectionFileDescriptor.h"
+
#include "PlatformAndroidRemoteGDBServer.h"
#include "Utility/UriParser.h"
@@ -258,18 +260,3 @@ PlatformAndroidRemoteGDBServer::ConnectProcess(const char* connect_url,
target,
error);
}
-
-size_t
-PlatformAndroidRemoteGDBServer::ConnectToWaitingProcesses(Debugger& debugger, Error& error)
-{
- std::vector<std::string> connection_urls;
- GetPendingGdbServerList(connection_urls);
-
- for (size_t i = 0; i < connection_urls.size(); ++i)
- {
- ConnectProcess(connection_urls[i].c_str(), nullptr, debugger, nullptr, error);
- if (error.Fail())
- return i; // We already connected to i process succsessfully
- }
- return connection_urls.size();
-}
diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
index 3d2653812dedc..79e273c665eb2 100644
--- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
+++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
@@ -46,9 +46,6 @@ public:
lldb_private::Target *target,
lldb_private::Error &error) override;
- size_t
- ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error) override;
-
protected:
std::string m_device_id;
std::map<lldb::pid_t, uint16_t> m_port_forwards;
diff --git a/source/Plugins/Platform/FreeBSD/Makefile b/source/Plugins/Platform/FreeBSD/Makefile
deleted file mode 100644
index e5c25d8504df6..0000000000000
--- a/source/Plugins/Platform/FreeBSD/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/FreeBSD/Makefile ------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformFreeBSD
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 9b3c57501117d..83c9247f46823 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -614,84 +614,31 @@ PlatformFreeBSD::GetStatus (Stream &strm)
size_t
PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
{
- ArchSpec arch = target.GetArchitecture();
- const uint8_t *trap_opcode = NULL;
- size_t trap_opcode_size = 0;
-
- switch (arch.GetMachine())
+ switch (target.GetArchitecture().GetMachine())
{
- default:
- assert(false && "Unhandled architecture in PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode()");
- break;
- case llvm::Triple::aarch64:
- {
- static const uint8_t g_aarch64_opcode[] = { 0x00, 0x00, 0x20, 0xd4 };
- trap_opcode = g_aarch64_opcode;
- trap_opcode_size = sizeof(g_aarch64_opcode);
- }
- break;
- // TODO: support big-endian arm and thumb trap codes.
case llvm::Triple::arm:
{
- static const uint8_t g_arm_breakpoint_opcode[] = { 0xfe, 0xde, 0xff, 0xe7 };
- static const uint8_t g_thumb_breakpoint_opcode[] = { 0x01, 0xde };
-
- lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
+ lldb::BreakpointLocationSP bp_loc_sp(bp_site->GetOwnerAtIndex(0));
AddressClass addr_class = eAddressClassUnknown;
if (bp_loc_sp)
- addr_class = bp_loc_sp->GetAddress ().GetAddressClass ();
+ {
+ addr_class = bp_loc_sp->GetAddress().GetAddressClass();
+ if (addr_class == eAddressClassUnknown && (bp_loc_sp->GetAddress().GetFileAddress() & 1))
+ addr_class = eAddressClassCodeAlternateISA;
+ }
- if (addr_class == eAddressClassCodeAlternateISA
- || (addr_class == eAddressClassUnknown && (bp_site->GetLoadAddress() & 1)))
+ if (addr_class == eAddressClassCodeAlternateISA)
{
// TODO: Enable when FreeBSD supports thumb breakpoints.
// FreeBSD kernel as of 10.x, does not support thumb breakpoints
- trap_opcode = g_thumb_breakpoint_opcode;
- trap_opcode_size = 0;
- }
- else
- {
- trap_opcode = g_arm_breakpoint_opcode;
- trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+ return 0;
}
}
- break;
- case llvm::Triple::mips64:
- {
- static const uint8_t g_hex_opcode[] = { 0x00, 0x00, 0x00, 0x0d };
- trap_opcode = g_hex_opcode;
- trap_opcode_size = sizeof(g_hex_opcode);
- }
- break;
- case llvm::Triple::mips64el:
- {
- static const uint8_t g_hex_opcode[] = { 0x0d, 0x00, 0x00, 0x00 };
- trap_opcode = g_hex_opcode;
- trap_opcode_size = sizeof(g_hex_opcode);
- }
- break;
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- {
- static const uint8_t g_ppc_opcode[] = { 0x7f, 0xe0, 0x00, 0x08 };
- trap_opcode = g_ppc_opcode;
- trap_opcode_size = sizeof(g_ppc_opcode);
- }
- break;
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- static const uint8_t g_i386_opcode[] = { 0xCC };
- trap_opcode = g_i386_opcode;
- trap_opcode_size = sizeof(g_i386_opcode);
- }
- break;
+ LLVM_FALLTHROUGH;
+ default:
+ return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
}
-
- if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
- return trap_opcode_size;
- return 0;
}
diff --git a/source/Plugins/Platform/Kalimba/Makefile b/source/Plugins/Platform/Kalimba/Makefile
deleted file mode 100644
index c22b7d21c13d1..0000000000000
--- a/source/Plugins/Platform/Kalimba/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/Kalimba/Makefile --------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformKalimba
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/Linux/Makefile b/source/Plugins/Platform/Linux/Makefile
deleted file mode 100644
index 2877fddf0bcd8..0000000000000
--- a/source/Plugins/Platform/Linux/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/Linux/Makefile --------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformLinux
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 8dc9769844c73..846e350eec56b 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -485,6 +485,7 @@ PlatformLinux::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
case 6: triple.setArchName("mips"); break;
case 7: triple.setArchName("mips64el"); break;
case 8: triple.setArchName("mipsel"); break;
+ case 9: triple.setArchName("s390x"); break;
default: return false;
}
// Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the vendor by
@@ -522,98 +523,6 @@ PlatformLinux::GetStatus (Stream &strm)
#endif
}
-size_t
-PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target,
- BreakpointSite *bp_site)
-{
- ArchSpec arch = target.GetArchitecture();
- const uint8_t *trap_opcode = NULL;
- size_t trap_opcode_size = 0;
-
- switch (arch.GetMachine())
- {
- default:
- assert(false && "CPU type not supported!");
- break;
-
- case llvm::Triple::aarch64:
- {
- static const uint8_t g_aarch64_opcode[] = { 0x00, 0x00, 0x20, 0xd4 };
- trap_opcode = g_aarch64_opcode;
- trap_opcode_size = sizeof(g_aarch64_opcode);
- }
- break;
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
- trap_opcode = g_i386_breakpoint_opcode;
- trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
- }
- break;
- case llvm::Triple::hexagon:
- {
- static const uint8_t g_hex_opcode[] = { 0x0c, 0xdb, 0x00, 0x54 };
- trap_opcode = g_hex_opcode;
- trap_opcode_size = sizeof(g_hex_opcode);
- }
- break;
- case llvm::Triple::arm:
- {
- // The ARM reference recommends the use of 0xe7fddefe and 0xdefe
- // but the linux kernel does otherwise.
- static const uint8_t g_arm_breakpoint_opcode[] = { 0xf0, 0x01, 0xf0, 0xe7 };
- static const uint8_t g_thumb_breakpoint_opcode[] = { 0x01, 0xde };
-
- lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
- AddressClass addr_class = eAddressClassUnknown;
-
- if (bp_loc_sp)
- {
- addr_class = bp_loc_sp->GetAddress ().GetAddressClass ();
-
- if (addr_class == eAddressClassUnknown &&
- (bp_loc_sp->GetAddress ().GetFileAddress () & 1))
- {
- addr_class = eAddressClassCodeAlternateISA;
- }
- }
-
- if (addr_class == eAddressClassCodeAlternateISA)
- {
- trap_opcode = g_thumb_breakpoint_opcode;
- trap_opcode_size = sizeof(g_thumb_breakpoint_opcode);
- }
- else
- {
- trap_opcode = g_arm_breakpoint_opcode;
- trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
- }
- }
- break;
- case llvm::Triple::mips:
- case llvm::Triple::mips64:
- {
- static const uint8_t g_hex_opcode[] = { 0x00, 0x00, 0x00, 0x0d };
- trap_opcode = g_hex_opcode;
- trap_opcode_size = sizeof(g_hex_opcode);
- }
- break;
- case llvm::Triple::mipsel:
- case llvm::Triple::mips64el:
- {
- static const uint8_t g_hex_opcode[] = { 0x0d, 0x00, 0x00, 0x00 };
- trap_opcode = g_hex_opcode;
- trap_opcode_size = sizeof(g_hex_opcode);
- }
- break;
- }
-
- if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
- return trap_opcode_size;
- return 0;
-}
-
int32_t
PlatformLinux::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
{
@@ -762,9 +671,9 @@ PlatformLinux::DebugProcess (ProcessLaunchInfo &launch_info,
if (log)
log->Printf ("PlatformLinux::%s setting up hijacker", __FUNCTION__);
- listener_sp.reset (new Listener("lldb.PlatformLinux.DebugProcess.hijack"));
+ listener_sp = Listener::MakeListener("lldb.PlatformLinux.DebugProcess.hijack");
launch_info.SetHijackListener (listener_sp);
- process_sp->HijackProcessEvents (listener_sp.get ());
+ process_sp->HijackProcessEvents (listener_sp);
}
// Log file actions.
@@ -790,7 +699,7 @@ PlatformLinux::DebugProcess (ProcessLaunchInfo &launch_info,
// Handle the hijacking of process events.
if (listener_sp)
{
- const StateType state = process_sp->WaitForProcessToStop (NULL, NULL, false, listener_sp.get());
+ const StateType state = process_sp->WaitForProcessToStop (NULL, NULL, false, listener_sp);
if (state == eStateStopped)
{
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h
index 770a20c90cce6..d99256cff0eaf 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -87,10 +87,6 @@ namespace platform_linux {
bool
GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) override;
- size_t
- GetSoftwareBreakpointTrapOpcode (Target &target,
- BreakpointSite *bp_site) override;
-
int32_t
GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info) override;
diff --git a/source/Plugins/Platform/MacOSX/Makefile b/source/Plugins/Platform/MacOSX/Makefile
deleted file mode 100644
index 4377d369bc195..0000000000000
--- a/source/Plugins/Platform/MacOSX/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-##===- source/Plugins/Platform/MacOSX/Makefile -------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LEVEL := $(LLDB_LEVEL)/../..
-
-include $(LEVEL)/Makefile.config
-
-SOURCES += PlatformDarwin.cpp \
- PlatformDarwinKernel.cpp \
- PlatformMacOSX.cpp \
- PlatformRemoteiOS.cpp \
- PlatformRemoteAppleTV.cpp \
- PlatformRemoteAppleWatch.cpp
-
-ifeq ($(HOST_OS),Darwin)
-SOURCES += PlatformAppleSimulator.cpp \
- PlatformiOSSimulator.cpp \
- PlatformiOSSimulatorCoreSimulatorSupport.mm \
- PlatformAppleTVSimulator.cpp \
- PlatformAppleWatchSimulator.cpp
-endif
-
-LIBRARYNAME := lldbPluginPlatformMacOSX
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
-
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index eea2844d5649f..a5f165e1f9256 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -252,7 +252,7 @@ FileSpec
PlatformAppleSimulator::GetCoreSimulatorPath()
{
#if defined(__APPLE__)
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
if (!m_core_simulator_framework_path.hasValue())
{
const char *developer_dir = GetDeveloperDirectory();
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
index f537934a9172a..097d58dcfbc1a 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
@@ -304,7 +304,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil
const char *
PlatformAppleTVSimulator::GetSDKDirectoryAsCString()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
if (m_sdk_directory.empty())
{
const char *developer_dir = GetDeveloperDirectory();
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
index ea8e789b2920d..46e5970bc0897 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
@@ -304,7 +304,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil
const char *
PlatformAppleWatchSimulator::GetSDKDirectoryAsCString()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
if (m_sdk_directory.empty())
{
const char *developer_dir = GetDeveloperDirectory();
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index fb38630710a15..f9eada9865299 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -583,22 +583,13 @@ PlatformDarwin::GetSharedModule (const ModuleSpec &module_spec,
size_t
PlatformDarwin::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
{
- const uint8_t *trap_opcode = NULL;
+ const uint8_t *trap_opcode = nullptr;
uint32_t trap_opcode_size = 0;
bool bp_is_thumb = false;
-
+
llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
switch (machine)
{
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
- trap_opcode = g_i386_breakpoint_opcode;
- trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
- }
- break;
-
case llvm::Triple::aarch64:
{
// TODO: fix this with actual darwin breakpoint opcode for arm64.
@@ -611,7 +602,8 @@ PlatformDarwin::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite
break;
case llvm::Triple::thumb:
- bp_is_thumb = true; // Fall through...
+ bp_is_thumb = true;
+ LLVM_FALLTHROUGH;
case llvm::Triple::arm:
{
static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
@@ -634,7 +626,7 @@ PlatformDarwin::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite
trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
}
break;
-
+
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
{
@@ -643,12 +635,11 @@ PlatformDarwin::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite
trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
}
break;
-
+
default:
- assert(!"Unhandled architecture in PlatformDarwin::GetSoftwareBreakpointTrapOpcode()");
- break;
+ return Platform::GetSoftwareBreakpointTrapOpcode(target, bp_site);
}
-
+
if (trap_opcode && trap_opcode_size)
{
if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
@@ -1024,7 +1015,7 @@ PlatformDarwin::ARMGetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch
const char *
PlatformDarwin::GetDeveloperDirectory()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
if (m_developer_directory.empty())
{
bool developer_dir_path_valid = false;
@@ -1166,6 +1157,7 @@ PlatformDarwin::SetThreadCreationBreakpoint (Target &target)
llvm::array_lengthof(g_bp_names),
eFunctionNameTypeFull,
eLanguageTypeUnknown,
+ 0,
skip_prologue,
internal,
hardware);
@@ -1580,10 +1572,10 @@ PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std:
FileSpec sysroot_spec;
// Scope for mutex locker below
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
sysroot_spec = GetSDKDirectoryForModules(sdk_type);
}
-
+
if (sysroot_spec.IsDirectory())
{
options.push_back("-isysroot");
@@ -1703,3 +1695,28 @@ PlatformDarwin::LocateExecutable (const char *basename)
return FileSpec();
}
+
+lldb_private::Error
+PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info)
+{
+ // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr
+ // if the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't
+ // require any specific value; rather, it just needs to exist).
+ // We will set it here as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag
+ // is not set. Xcode makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell
+ // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they
+ // specifically want it unset.
+ const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE";
+ auto &env_vars = launch_info.GetEnvironmentEntries();
+ if (!env_vars.ContainsEnvironmentVariable(disable_env_var))
+ {
+ // We want to make sure that OS_ACTIVITY_DT_MODE is set so that
+ // we get os_log and NSLog messages mirrored to the target process
+ // stderr.
+ if (!env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE"))
+ env_vars.AppendArgument("OS_ACTIVITY_DT_MODE=enable");
+ }
+
+ // Let our parent class do the real launching.
+ return PlatformPOSIX::LaunchProcess(launch_info);
+}
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index b280b35da6551..faecf4cc5a240 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -98,6 +98,9 @@ public:
lldb_private::FileSpec
LocateExecutable (const char *basename) override;
+ lldb_private::Error
+ LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
+
protected:
void
ReadLibdispatchOffsetsAddress (lldb_private::Process *process);
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index a502aa03eb269..d3c1c805a83b1 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -30,6 +30,7 @@
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -881,12 +882,24 @@ PlatformDarwinKernel::GetSharedModule (const ModuleSpec &module_spec,
ModuleSP module_sp (new Module (kern_spec));
if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (kern_spec))
{
- Error error;
- error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL);
- if (module_sp && module_sp->GetObjectFile())
+ // module_sp is an actual kernel binary we want to add.
+ if (process)
{
+ process->GetTarget().GetImages().AppendIfNeeded (module_sp);
+ error.Clear();
return error;
}
+ else
+ {
+ error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL);
+ if (module_sp
+ && module_sp->GetObjectFile()
+ && module_sp->GetObjectFile()->GetType() != ObjectFile::Type::eTypeCoreFile)
+ {
+ return error;
+ }
+ module_sp.reset();
+ }
}
}
}
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
index 04231f27ff9b5..30af2bb2250b1 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
@@ -158,14 +158,6 @@ PlatformRemoteAppleTV::CreateInstance (bool force, const ArchSpec *arch)
case llvm::Triple::TvOS: // This is the right triple value for Apple TV debugging
break;
-#if defined(__APPLE__)
- // Only accept "unknown" for the OS if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
-#endif
default:
create = false;
break;
@@ -314,9 +306,14 @@ PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback (void *baton
bool
PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded()
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (m_sdk_directory_infos.empty())
{
const char *device_support_dir = GetDeviceSupportDirectory();
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir);
+ }
if (device_support_dir)
{
const bool find_directories = true;
@@ -341,12 +338,20 @@ PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded()
if (sdk_symbols_symlink_fspec.Exists())
{
m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
}
else
{
sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols");
if (sdk_symbols_symlink_fspec.Exists())
m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
}
}
@@ -374,6 +379,10 @@ PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded()
}
if (local_sdk_cache.Exists())
{
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str());
+ }
char path[PATH_MAX];
if (local_sdk_cache.GetPath(path, sizeof(path)))
{
@@ -388,6 +397,10 @@ PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded()
for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
{
m_sdk_directory_infos[i].user_cached = true;
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleTV::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str());
+ }
}
}
}
@@ -572,6 +585,7 @@ uint32_t
PlatformRemoteAppleTV::FindFileInAllSDKs (const char *platform_file_path,
FileSpecList &file_list)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded())
{
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
@@ -579,6 +593,10 @@ PlatformRemoteAppleTV::FindFileInAllSDKs (const char *platform_file_path,
// First try for an exact match of major, minor and update
for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
{
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path,
sdk_idx,
local_file))
@@ -618,6 +636,7 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path,
bool symbols_dirs_only,
lldb_private::FileSpec &local_file)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (sdkroot_path && sdkroot_path[0] && platform_file_path && platform_file_path[0])
{
char resolved_path[PATH_MAX];
@@ -632,7 +651,13 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the SDK dir %s", platform_file_path, sdkroot_path);
+ }
return true;
+ }
}
::snprintf (resolved_path,
@@ -643,7 +668,13 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the SDK dir %s/Symbols.Internal", platform_file_path, sdkroot_path);
+ }
return true;
+ }
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/Symbols%s",
@@ -652,7 +683,13 @@ PlatformRemoteAppleTV::GetFileInSDKRoot (const char *platform_file_path,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the SDK dir %s/Symbols", platform_file_path, sdkroot_path);
+ }
return true;
+ }
}
return false;
}
@@ -662,6 +699,7 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
@@ -679,7 +717,13 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir);
+ }
return error;
+ }
::snprintf (resolved_path,
sizeof(resolved_path),
@@ -689,7 +733,13 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir);
+ }
return error;
+ }
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/Symbols/%s",
@@ -698,8 +748,13 @@ PlatformRemoteAppleTV::GetSymbolFile (const FileSpec &platform_file,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir);
+ }
return error;
-
+ }
}
local_file = platform_file;
if (local_file.Exists())
@@ -729,6 +784,7 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec,
// then we attempt to get a shared module for the right architecture
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
Error error;
char platform_file_path[PATH_MAX];
@@ -746,6 +802,10 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec,
const uint32_t connected_sdk_idx = GetConnectedSDKIndex ();
if (connected_sdk_idx < num_sdk_infos)
{
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec()))
{
module_sp.reset();
@@ -765,6 +825,10 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec,
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos)
{
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec()))
{
module_sp.reset();
@@ -788,6 +852,10 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec,
// it above
continue;
}
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec()))
{
//printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
@@ -812,6 +880,76 @@ PlatformRemoteAppleTV::GetSharedModule (const ModuleSpec &module_spec,
if (error.Success())
return error;
+ // See if the file is present in any of the module_search_paths_ptr directories.
+ if (!module_sp && module_search_paths_ptr && platform_file)
+ {
+ // create a vector of all the file / directory names in platform_file
+ // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ //
+ // We'll need to look in the module_search_paths_ptr directories for
+ // both "UIFoundation" and "UIFoundation.framework" -- most likely the
+ // latter will be the one we find there.
+
+ FileSpec platform_pull_apart (platform_file);
+ std::vector<std::string> path_parts;
+ ConstString unix_root_dir("/");
+ while (true)
+ {
+ ConstString part = platform_pull_apart.GetLastPathComponent();
+ platform_pull_apart.RemoveLastPathComponent();
+ if (part.IsEmpty() || part == unix_root_dir)
+ break;
+ path_parts.push_back (part.AsCString());
+ }
+ const size_t path_parts_size = path_parts.size();
+
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i)
+ {
+ // Create a new FileSpec with this module_search_paths_ptr
+ // plus just the filename ("UIFoundation"), then the parent
+ // dir plus filename ("UIFoundation.framework/UIFoundation")
+ // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
+
+ for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j)
+ {
+ FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i));
+
+ // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation
+ // path_parts is
+ // [0] UIFoundation
+ // [1] UIFoundation.framework
+ // [2] PrivateFrameworks
+ //
+ // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka
+ // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path.
+
+ for (int k = j; k >= 0; --k)
+ {
+ path_to_try.AppendPathComponent (path_parts[k]);
+ }
+
+ if (path_to_try.Exists())
+ {
+ ModuleSpec new_module_spec (module_spec);
+ new_module_spec.GetFileSpec() = path_to_try;
+ Error new_error (Platform::GetSharedModule (new_module_spec,
+ process,
+ module_sp,
+ NULL,
+ old_module_sp_ptr,
+ did_create_ptr));
+
+ if (module_sp)
+ {
+ module_sp->SetPlatformFileSpec (path_to_try);
+ return new_error;
+ }
+ }
+ }
+ }
+ }
+
const bool always_create = false;
error = ModuleList::GetSharedModule (module_spec,
module_sp,
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
index 808fd96a5284c..ba59887ccf27c 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
@@ -158,14 +158,6 @@ PlatformRemoteAppleWatch::CreateInstance (bool force, const ArchSpec *arch)
case llvm::Triple::WatchOS: // This is the right triple value for Apple Watch debugging
break;
-#if defined(__APPLE__)
- // Only accept "unknown" for the OS if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
-#endif
default:
create = false;
break;
@@ -322,9 +314,14 @@ PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback (void *ba
bool
PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (m_sdk_directory_infos.empty())
{
const char *device_support_dir = GetDeviceSupportDirectory();
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded Got DeviceSupport directory %s", device_support_dir);
+ }
if (device_support_dir)
{
const bool find_directories = true;
@@ -349,12 +346,20 @@ PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
if (sdk_symbols_symlink_fspec.Exists())
{
m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
}
else
{
sdk_symbols_symlink_fspec.GetFilename().SetCString("Symbols");
if (sdk_symbols_symlink_fspec.Exists())
m_sdk_directory_infos.push_back(sdk_directory_info);
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded added builtin SDK directory %s", sdk_symbols_symlink_fspec.GetPath().c_str());
+ }
}
}
@@ -374,6 +379,10 @@ PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
}
if (local_sdk_cache.Exists())
{
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded searching %s for additional SDKs", local_sdk_cache.GetPath().c_str());
+ }
char path[PATH_MAX];
if (local_sdk_cache.GetPath(path, sizeof(path)))
{
@@ -388,6 +397,10 @@ PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded()
for (uint32_t i=num_installed; i<num_sdk_infos; ++i)
{
m_sdk_directory_infos[i].user_cached = true;
+ if (log)
+ {
+ log->Printf ("PlatformRemoteAppleWatch::UpdateSDKDirectoryInfosIfNeeded user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str());
+ }
}
}
}
@@ -583,6 +596,7 @@ uint32_t
PlatformRemoteAppleWatch::FindFileInAllSDKs (const char *platform_file_path,
FileSpecList &file_list)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
if (platform_file_path && platform_file_path[0] && UpdateSDKDirectoryInfosIfNeeded())
{
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
@@ -590,6 +604,10 @@ PlatformRemoteAppleWatch::FindFileInAllSDKs (const char *platform_file_path,
// First try for an exact match of major, minor and update
for (uint32_t sdk_idx=0; sdk_idx<num_sdk_infos; ++sdk_idx)
{
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path,
sdk_idx,
local_file))
@@ -629,6 +647,7 @@ PlatformRemoteAppleWatch::GetFileInSDKRoot (const char *platform_file_path,
bool symbols_dirs_only,
lldb_private::FileSpec &local_file)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (sdkroot_path && sdkroot_path[0] && platform_file_path && platform_file_path[0])
{
char resolved_path[PATH_MAX];
@@ -643,7 +662,13 @@ PlatformRemoteAppleWatch::GetFileInSDKRoot (const char *platform_file_path,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the SDK dir %s", platform_file_path, sdkroot_path);
+ }
return true;
+ }
}
::snprintf (resolved_path,
@@ -654,7 +679,13 @@ PlatformRemoteAppleWatch::GetFileInSDKRoot (const char *platform_file_path,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the SDK dir %s/Symbols.Internal", platform_file_path, sdkroot_path);
+ }
return true;
+ }
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/Symbols%s",
@@ -663,7 +694,13 @@ PlatformRemoteAppleWatch::GetFileInSDKRoot (const char *platform_file_path,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the SDK dir %s/Symbols", platform_file_path, sdkroot_path);
+ }
return true;
+ }
}
return false;
}
@@ -673,6 +710,7 @@ PlatformRemoteAppleWatch::GetSymbolFile (const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file)
{
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
Error error;
char platform_file_path[PATH_MAX];
if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
@@ -690,7 +728,13 @@ PlatformRemoteAppleWatch::GetSymbolFile (const FileSpec &platform_file,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the DeviceSupport dir %s", platform_file_path, os_version_dir);
+ }
return error;
+ }
::snprintf (resolved_path,
sizeof(resolved_path),
@@ -700,7 +744,13 @@ PlatformRemoteAppleWatch::GetSymbolFile (const FileSpec &platform_file,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols.Internal", platform_file_path, os_version_dir);
+ }
return error;
+ }
::snprintf (resolved_path,
sizeof(resolved_path),
"%s/Symbols/%s",
@@ -709,7 +759,13 @@ PlatformRemoteAppleWatch::GetSymbolFile (const FileSpec &platform_file,
local_file.SetFile(resolved_path, true);
if (local_file.Exists())
+ {
+ if (log)
+ {
+ log->Printf ("Found a copy of %s in the DeviceSupport dir %s/Symbols", platform_file_path, os_version_dir);
+ }
return error;
+ }
}
local_file = platform_file;
@@ -740,6 +796,7 @@ PlatformRemoteAppleWatch::GetSharedModule (const ModuleSpec &module_spec,
// then we attempt to get a shared module for the right architecture
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST | LIBLLDB_LOG_VERBOSE);
Error error;
char platform_file_path[PATH_MAX];
@@ -757,6 +814,10 @@ PlatformRemoteAppleWatch::GetSharedModule (const ModuleSpec &module_spec,
const uint32_t connected_sdk_idx = GetConnectedSDKIndex ();
if (connected_sdk_idx < num_sdk_infos)
{
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[connected_sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path, connected_sdk_idx, platform_module_spec.GetFileSpec()))
{
module_sp.reset();
@@ -776,6 +837,10 @@ PlatformRemoteAppleWatch::GetSharedModule (const ModuleSpec &module_spec,
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos)
{
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[m_last_module_sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path, m_last_module_sdk_idx, platform_module_spec.GetFileSpec()))
{
module_sp.reset();
@@ -799,6 +864,10 @@ PlatformRemoteAppleWatch::GetSharedModule (const ModuleSpec &module_spec,
// it above
continue;
}
+ if (log)
+ {
+ log->Printf ("Searching for %s in sdk path %s", platform_file_path, m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
+ }
if (GetFileInSDK (platform_file_path, sdk_idx, platform_module_spec.GetFileSpec()))
{
//printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
@@ -823,6 +892,76 @@ PlatformRemoteAppleWatch::GetSharedModule (const ModuleSpec &module_spec,
if (error.Success())
return error;
+ // See if the file is present in any of the module_search_paths_ptr directories.
+ if (!module_sp && module_search_paths_ptr && platform_file)
+ {
+ // create a vector of all the file / directory names in platform_file
+ // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ //
+ // We'll need to look in the module_search_paths_ptr directories for
+ // both "UIFoundation" and "UIFoundation.framework" -- most likely the
+ // latter will be the one we find there.
+
+ FileSpec platform_pull_apart (platform_file);
+ std::vector<std::string> path_parts;
+ ConstString unix_root_dir("/");
+ while (true)
+ {
+ ConstString part = platform_pull_apart.GetLastPathComponent();
+ platform_pull_apart.RemoveLastPathComponent();
+ if (part.IsEmpty() || part == unix_root_dir)
+ break;
+ path_parts.push_back (part.AsCString());
+ }
+ const size_t path_parts_size = path_parts.size();
+
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i)
+ {
+ // Create a new FileSpec with this module_search_paths_ptr
+ // plus just the filename ("UIFoundation"), then the parent
+ // dir plus filename ("UIFoundation.framework/UIFoundation")
+ // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
+
+ for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j)
+ {
+ FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i));
+
+ // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation
+ // path_parts is
+ // [0] UIFoundation
+ // [1] UIFoundation.framework
+ // [2] PrivateFrameworks
+ //
+ // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka
+ // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path.
+
+ for (int k = j; k >= 0; --k)
+ {
+ path_to_try.AppendPathComponent (path_parts[k]);
+ }
+
+ if (path_to_try.Exists())
+ {
+ ModuleSpec new_module_spec (module_spec);
+ new_module_spec.GetFileSpec() = path_to_try;
+ Error new_error (Platform::GetSharedModule (new_module_spec,
+ process,
+ module_sp,
+ NULL,
+ old_module_sp_ptr,
+ did_create_ptr));
+
+ if (module_sp)
+ {
+ module_sp->SetPlatformFileSpec (path_to_try);
+ return new_error;
+ }
+ }
+ }
+ }
+ }
+
const bool always_create = false;
error = ModuleList::GetSharedModule (module_spec,
module_sp,
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
index 75afa9019dcdc..abc429a72345e 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
@@ -142,14 +142,6 @@ PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
case llvm::Triple::IOS: // This is the right triple value for iOS debugging
break;
-#if defined(__APPLE__)
- // Only accept "unknown" for the OS if the host is Apple and
- // it "unknown" wasn't specified (it was just returned because it
- // was NOT specified)
- case llvm::Triple::UnknownOS:
- create = !arch->TripleOSWasSpecified();
- break;
-#endif
default:
create = false;
break;
@@ -913,6 +905,76 @@ PlatformRemoteiOS::GetSharedModule (const ModuleSpec &module_spec,
if (error.Success())
return error;
+ // See if the file is present in any of the module_search_paths_ptr directories.
+ if (!module_sp && module_search_paths_ptr && platform_file)
+ {
+ // create a vector of all the file / directory names in platform_file
+ // e.g. this might be /System/Library/PrivateFrameworks/UIFoundation.framework/UIFoundation
+ //
+ // We'll need to look in the module_search_paths_ptr directories for
+ // both "UIFoundation" and "UIFoundation.framework" -- most likely the
+ // latter will be the one we find there.
+
+ FileSpec platform_pull_apart (platform_file);
+ std::vector<std::string> path_parts;
+ ConstString unix_root_dir("/");
+ while (true)
+ {
+ ConstString part = platform_pull_apart.GetLastPathComponent();
+ platform_pull_apart.RemoveLastPathComponent();
+ if (part.IsEmpty() || part == unix_root_dir)
+ break;
+ path_parts.push_back (part.AsCString());
+ }
+ const size_t path_parts_size = path_parts.size();
+
+ size_t num_module_search_paths = module_search_paths_ptr->GetSize();
+ for (size_t i = 0; i < num_module_search_paths; ++i)
+ {
+ // Create a new FileSpec with this module_search_paths_ptr
+ // plus just the filename ("UIFoundation"), then the parent
+ // dir plus filename ("UIFoundation.framework/UIFoundation")
+ // etc - up to four names (to handle "Foo.framework/Contents/MacOS/Foo")
+
+ for (size_t j = 0; j < 4 && j < path_parts_size - 1; ++j)
+ {
+ FileSpec path_to_try (module_search_paths_ptr->GetFileSpecAtIndex (i));
+
+ // Add the components backwards. For .../PrivateFrameworks/UIFoundation.framework/UIFoundation
+ // path_parts is
+ // [0] UIFoundation
+ // [1] UIFoundation.framework
+ // [2] PrivateFrameworks
+ //
+ // and if 'j' is 2, we want to append path_parts[1] and then path_parts[0], aka
+ // 'UIFoundation.framework/UIFoundation', to the module_search_paths_ptr path.
+
+ for (int k = j; k >= 0; --k)
+ {
+ path_to_try.AppendPathComponent (path_parts[k]);
+ }
+
+ if (path_to_try.Exists())
+ {
+ ModuleSpec new_module_spec (module_spec);
+ new_module_spec.GetFileSpec() = path_to_try;
+ Error new_error (Platform::GetSharedModule (new_module_spec,
+ process,
+ module_sp,
+ NULL,
+ old_module_sp_ptr,
+ did_create_ptr));
+
+ if (module_sp)
+ {
+ module_sp->SetPlatformFileSpec (path_to_try);
+ return new_error;
+ }
+ }
+ }
+ }
+ }
+
const bool always_create = false;
error = ModuleList::GetSharedModule (module_spec,
module_sp,
diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
index cbe9c7949a4a6..99b9324417b5b 100644
--- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
@@ -308,7 +308,7 @@ EnumerateDirectoryCallback (void *baton, FileSpec::FileType file_type, const Fil
const char *
PlatformiOSSimulator::GetSDKDirectoryAsCString()
{
- Mutex::Locker locker (m_mutex);
+ std::lock_guard<std::mutex> guard(m_mutex);
if (m_sdk_directory.empty())
{
const char *developer_dir = GetDeveloperDirectory();
diff --git a/source/Plugins/Platform/Makefile b/source/Plugins/Platform/Makefile
deleted file mode 100644
index 572b08644074c..0000000000000
--- a/source/Plugins/Platform/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-##===- source/Plugins/Platform/Makefile --------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../..
-
-include $(LLDB_LEVEL)/../../Makefile.config
-
-PARALLEL_DIRS := gdb-server MacOSX Linux FreeBSD NetBSD POSIX Windows Kalimba Android
-
-# ifeq ($(HOST_OS),Darwin)
-# DIRS += MacOSX
-# endif
-#
-# ifeq ($(HOST_OS),Linux)
-# DIRS += Linux
-# endif
-#
-# ifeq ($(HOST_OS),FreeBSD)
-# DIRS += FreeBSD
-# endif
-#
-# ifeq ($(HOST_OS),GNU/kFreeBSD)
-# DIRS += FreeBSD
-# endif
-#
-# ifeq ($(HOST_OS),NetBSD)
-# DIRS += NetBSD
-# endif
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/NetBSD/Makefile b/source/Plugins/Platform/NetBSD/Makefile
deleted file mode 100644
index 2c480bdbe8dac..0000000000000
--- a/source/Plugins/Platform/NetBSD/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/NetBSD/Makefile ------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformNetBSD
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index 2979d1e438b77..3482d2ae5e208 100644
--- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -585,34 +585,6 @@ PlatformNetBSD::GetStatus (Stream &strm)
Platform::GetStatus(strm);
}
-size_t
-PlatformNetBSD::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
-{
- ArchSpec arch = target.GetArchitecture();
- const uint8_t *trap_opcode = NULL;
- size_t trap_opcode_size = 0;
-
- switch (arch.GetMachine())
- {
- default:
- assert(false && "Unhandled architecture in PlatformNetBSD::GetSoftwareBreakpointTrapOpcode()");
- break;
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- static const uint8_t g_i386_opcode[] = { 0xCC };
- trap_opcode = g_i386_opcode;
- trap_opcode_size = sizeof(g_i386_opcode);
- }
- break;
- }
-
- if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
- return trap_opcode_size;
- return 0;
-}
-
-
void
PlatformNetBSD::CalculateTrapHandlerSymbolNames ()
{
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
index b0187be99b059..46d1d1843c631 100644
--- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -86,10 +86,6 @@ namespace platform_netbsd {
lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr) override;
- size_t
- GetSoftwareBreakpointTrapOpcode(Target &target,
- BreakpointSite *bp_site) override;
-
bool
GetRemoteOSVersion () override;
diff --git a/source/Plugins/Platform/POSIX/Makefile b/source/Plugins/Platform/POSIX/Makefile
deleted file mode 100644
index eca927720ba87..0000000000000
--- a/source/Plugins/Platform/POSIX/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/POSIX/Makefile --------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformPOSIX
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index c7564655a11b5..bc890695f0ce4 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -41,6 +41,9 @@ using namespace lldb_private;
//------------------------------------------------------------------
PlatformPOSIX::PlatformPOSIX (bool is_host) :
Platform(is_host), // This is the local host platform
+m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
+m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
+m_option_group_platform_caching(new OptionGroupPlatformCaching()),
m_remote_platform_sp ()
{
}
@@ -69,14 +72,17 @@ PlatformPOSIX::GetModuleSpec (const FileSpec& module_file_spec,
lldb_private::OptionGroupOptions*
PlatformPOSIX::GetConnectionOptions (lldb_private::CommandInterpreter& interpreter)
{
- if (m_options.get() == NULL)
+ auto iter = m_options.find(&interpreter), end = m_options.end();
+ if (iter == end)
{
- m_options.reset(new OptionGroupOptions(interpreter));
- m_options->Append(new OptionGroupPlatformRSync());
- m_options->Append(new OptionGroupPlatformSSH());
- m_options->Append(new OptionGroupPlatformCaching());
+ std::unique_ptr<lldb_private::OptionGroupOptions> options(new OptionGroupOptions(interpreter));
+ options->Append(m_option_group_platform_rsync.get());
+ options->Append(m_option_group_platform_ssh.get());
+ options->Append(m_option_group_platform_caching.get());
+ m_options[&interpreter] = std::move(options);
}
- return m_options.get();
+
+ return m_options.at(&interpreter).get();
}
bool
@@ -675,29 +681,21 @@ PlatformPOSIX::ConnectRemote (Args& args)
if (error.Success() && m_remote_platform_sp)
{
- if (m_options.get())
+ if (m_option_group_platform_rsync.get() && m_option_group_platform_ssh.get() && m_option_group_platform_caching.get())
{
- OptionGroupOptions* options = m_options.get();
- const OptionGroupPlatformRSync *m_rsync_options =
- static_cast<const OptionGroupPlatformRSync *>(options->GetGroupWithOption('r'));
- const OptionGroupPlatformSSH *m_ssh_options =
- static_cast<const OptionGroupPlatformSSH *>(options->GetGroupWithOption('s'));
- const OptionGroupPlatformCaching *m_cache_options =
- static_cast<const OptionGroupPlatformCaching *>(options->GetGroupWithOption('c'));
-
- if (m_rsync_options->m_rsync)
+ if (m_option_group_platform_rsync->m_rsync)
{
SetSupportsRSync(true);
- SetRSyncOpts(m_rsync_options->m_rsync_opts.c_str());
- SetRSyncPrefix(m_rsync_options->m_rsync_prefix.c_str());
- SetIgnoresRemoteHostname(m_rsync_options->m_ignores_remote_hostname);
+ SetRSyncOpts(m_option_group_platform_rsync->m_rsync_opts.c_str());
+ SetRSyncPrefix(m_option_group_platform_rsync->m_rsync_prefix.c_str());
+ SetIgnoresRemoteHostname(m_option_group_platform_rsync->m_ignores_remote_hostname);
}
- if (m_ssh_options->m_ssh)
+ if (m_option_group_platform_ssh->m_ssh)
{
SetSupportsSSH(true);
- SetSSHOpts(m_ssh_options->m_ssh_opts.c_str());
+ SetSSHOpts(m_option_group_platform_ssh->m_ssh_opts.c_str());
}
- SetLocalCacheDirectory(m_cache_options->m_cache_dir.c_str());
+ SetLocalCacheDirectory(m_option_group_platform_caching->m_cache_dir.c_str());
}
}
@@ -801,13 +799,13 @@ PlatformPOSIX::Attach (ProcessAttachInfo &attach_info,
if (process_sp)
{
- auto listener_sp = attach_info.GetHijackListener();
+ ListenerSP listener_sp = attach_info.GetHijackListener();
if (listener_sp == nullptr)
{
- listener_sp.reset(new Listener("lldb.PlatformPOSIX.attach.hijack"));
+ listener_sp = Listener::MakeListener("lldb.PlatformPOSIX.attach.hijack");
attach_info.SetHijackListener(listener_sp);
}
- process_sp->HijackProcessEvents(listener_sp.get());
+ process_sp->HijackProcessEvents(listener_sp);
error = process_sp->Attach (attach_info);
}
}
@@ -869,7 +867,7 @@ PlatformPOSIX::EvaluateLibdlExpression(lldb_private::Process* process,
return error;
}
- ThreadSP thread_sp(process->GetThreadList().GetSelectedThread());
+ ThreadSP thread_sp(process->GetThreadList().GetExpressionExecutionThread());
if (!thread_sp)
return Error("Selected thread isn't valid");
@@ -884,6 +882,7 @@ PlatformPOSIX::EvaluateLibdlExpression(lldb_private::Process* process,
expr_options.SetIgnoreBreakpoints(true);
expr_options.SetExecutionPolicy(eExecutionPolicyAlways);
expr_options.SetLanguage(eLanguageTypeC_plus_plus);
+ expr_options.SetTimeoutUsec(2000000); // 2 seconds
Error expr_error;
UserExpression::Evaluate(exe_ctx,
@@ -945,7 +944,7 @@ PlatformPOSIX::DoLoadImage(lldb_private::Process* process,
if (image_ptr == 0)
{
ValueObjectSP error_str_sp = result_valobj_sp->GetChildAtIndex(1, true);
- if (error_str_sp && error_str_sp->IsCStringContainer(true))
+ if (error_str_sp)
{
DataBufferSP buffer_sp(new DataBufferHeap(10240,0));
size_t num_chars = error_str_sp->ReadPointedString (buffer_sp, error, 10240).first;
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 60f6207d140bc..4f1f220028163 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -12,6 +12,7 @@
// C Includes
// C++ Includes
+#include <map>
#include <memory>
// Other libraries and framework includes
@@ -192,7 +193,11 @@ public:
ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error) override;
protected:
- std::unique_ptr<lldb_private::OptionGroupOptions> m_options;
+ std::unique_ptr<lldb_private::OptionGroupPlatformRSync> m_option_group_platform_rsync;
+ std::unique_ptr<lldb_private::OptionGroupPlatformSSH> m_option_group_platform_ssh;
+ std::unique_ptr<lldb_private::OptionGroupPlatformCaching> m_option_group_platform_caching;
+
+ std::map<lldb_private::CommandInterpreter*,std::unique_ptr<lldb_private::OptionGroupOptions>> m_options;
lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote POSIX-compliant OS
lldb_private::Error
diff --git a/source/Plugins/Platform/Windows/Makefile b/source/Plugins/Platform/Windows/Makefile
deleted file mode 100644
index b78cd7bfd080f..0000000000000
--- a/source/Plugins/Platform/Windows/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/Windows/Makefile --------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformWindows
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/Windows/PlatformWindows.cpp b/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 4172f80176d31..cef5684d9baca 100644
--- a/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -321,42 +321,6 @@ PlatformWindows::ResolveExecutable (const ModuleSpec &ms,
return error;
}
-size_t
-PlatformWindows::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
-{
- ArchSpec arch = target.GetArchitecture();
- const uint8_t *trap_opcode = nullptr;
- size_t trap_opcode_size = 0;
-
- switch (arch.GetMachine())
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- {
- static const uint8_t g_i386_opcode[] = { 0xCC };
- trap_opcode = g_i386_opcode;
- trap_opcode_size = sizeof(g_i386_opcode);
- }
- break;
-
- case llvm::Triple::hexagon:
- {
- static const uint8_t g_hex_opcode[] = { 0x0c, 0xdb, 0x00, 0x54 };
- trap_opcode = g_hex_opcode;
- trap_opcode_size = sizeof(g_hex_opcode);
- }
- break;
- default:
- llvm_unreachable("Unhandled architecture in PlatformWindows::GetSoftwareBreakpointTrapOpcode()");
- break;
- }
-
- if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
- return trap_opcode_size;
-
- return 0;
-}
-
bool
PlatformWindows::GetRemoteOSVersion ()
{
@@ -601,7 +565,7 @@ PlatformWindows::Attach(ProcessAttachInfo &attach_info,
const char *plugin_name = attach_info.GetProcessPluginName();
process_sp = target->CreateProcess(attach_info.GetListenerForProcess(debugger), plugin_name, nullptr);
- process_sp->HijackProcessEvents(attach_info.GetHijackListener().get());
+ process_sp->HijackProcessEvents(attach_info.GetHijackListener());
if (process_sp)
error = process_sp->Attach (attach_info);
diff --git a/source/Plugins/Platform/Windows/PlatformWindows.h b/source/Plugins/Platform/Windows/PlatformWindows.h
index e9a04b4cc33d3..6af178bb8c26e 100644
--- a/source/Plugins/Platform/Windows/PlatformWindows.h
+++ b/source/Plugins/Platform/Windows/PlatformWindows.h
@@ -72,10 +72,6 @@ public:
return GetPluginDescriptionStatic(IsHost());
}
- size_t
- GetSoftwareBreakpointTrapOpcode(lldb_private::Target &target,
- lldb_private::BreakpointSite *bp_site) override;
-
bool
GetRemoteOSVersion() override;
diff --git a/source/Plugins/Platform/gdb-server/Makefile b/source/Plugins/Platform/gdb-server/Makefile
deleted file mode 100644
index c56613b2a6536..0000000000000
--- a/source/Plugins/Platform/gdb-server/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-##===- source/Plugins/Platform/gdb-server/Makefile ---------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-LLDB_LEVEL := ../../../..
-LIBRARYNAME := lldbPluginPlatformGDB
-BUILD_ARCHIVE = 1
-
-include $(LLDB_LEVEL)/Makefile
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index f16ea017676f5..e64ed66be3ca2 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -714,9 +714,9 @@ PlatformRemoteGDBServer::Attach (ProcessAttachInfo &attach_info,
error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
if (error.Success())
{
- auto listener = attach_info.GetHijackListener();
- if (listener != nullptr)
- process_sp->HijackProcessEvents(listener.get());
+ ListenerSP listener_sp = attach_info.GetHijackListener();
+ if (listener_sp)
+ process_sp->HijackProcessEvents(listener_sp);
error = process_sp->Attach(attach_info);
}
@@ -1002,6 +1002,22 @@ PlatformRemoteGDBServer::ConnectProcess(const char* connect_url,
}
size_t
+PlatformRemoteGDBServer::ConnectToWaitingProcesses(Debugger& debugger, Error& error)
+{
+ std::vector<std::string> connection_urls;
+ GetPendingGdbServerList(connection_urls);
+
+ for (size_t i = 0; i < connection_urls.size(); ++i)
+ {
+ ConnectProcess(connection_urls[i].c_str(), nullptr, debugger, nullptr, error);
+ if (error.Fail())
+ return i; // We already connected to i process succsessfully
+ }
+ return connection_urls.size();
+
+}
+
+size_t
PlatformRemoteGDBServer::GetPendingGdbServerList(std::vector<std::string>& connection_urls)
{
std::vector<std::pair<uint16_t, std::string>> remote_servers;
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 61136f1185e66..9d640f3c174b9 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -224,6 +224,9 @@ public:
lldb_private::Target *target,
lldb_private::Error &error) override;
+ size_t
+ ConnectToWaitingProcesses(lldb_private::Debugger& debugger, lldb_private::Error& error) override;
+
virtual size_t
GetPendingGdbServerList(std::vector<std::string>& connection_urls);