Skip to content

Conversation

cs01
Copy link
Contributor

@cs01 cs01 commented Sep 18, 2025

Reattempt at #145382 (cc @labath). This time setenv() was replaced with set_env() (#145382 (comment)).

@cs01 cs01 requested a review from JDevlieghere as a code owner September 18, 2025 23:32
@llvmbot llvmbot added the lldb label Sep 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2025

@llvm/pr-subscribers-lldb

Author: Chad Smith (cs01)

Changes

Reattempt at #145382. This time setenv() was replaced with set_env() (#145382 (comment)).


Patch is 58.56 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/159676.diff

7 Files Affected:

  • (modified) lldb/source/Plugins/Platform/Android/AdbClient.cpp (+266-250)
  • (modified) lldb/source/Plugins/Platform/Android/AdbClient.h (+42-68)
  • (modified) lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp (+36-36)
  • (modified) lldb/source/Plugins/Platform/Android/PlatformAndroid.h (+5-4)
  • (modified) lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp (+6-5)
  • (modified) lldb/unittests/Platform/Android/AdbClientTest.cpp (+106-18)
  • (modified) lldb/unittests/Platform/Android/PlatformAndroidTest.cpp (+192-125)
diff --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp b/lldb/source/Plugins/Platform/Android/AdbClient.cpp
index a179260ca15f6..0fbb48a2e16a0 100644
--- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp
+++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp
@@ -8,61 +8,48 @@
 
 #include "AdbClient.h"
 
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/FileUtilities.h"
-
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
-#include "lldb/Host/PosixApi.h"
-#include "lldb/Utility/DataBuffer.h"
-#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Connection.h"
 #include "lldb/Utility/DataEncoder.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Status.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/Timeout.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileUtilities.h"
+#include <chrono>
 
 #include <climits>
-
-#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;
 using namespace std::chrono;
+using namespace llvm;
 
-static const seconds kReadTimeout(20);
+static const char *kSocketNamespaceAbstract = "localabstract";
+static const char *kSocketNamespaceFileSystem = "localfilesystem";
+const seconds kReadTimeout(20);
 static const char *kOKAY = "OKAY";
 static const char *kFAIL = "FAIL";
 static const char *kDATA = "DATA";
 static const char *kDONE = "DONE";
-
 static const char *kSEND = "SEND";
 static const char *kRECV = "RECV";
 static const char *kSTAT = "STAT";
-
 static const size_t kSyncPacketLen = 8;
-// Maximum size of a filesync DATA packet.
 static const size_t kMaxPushData = 2 * 1024;
-// Default mode for pushed files.
-static const uint32_t kDefaultMode = 0100770; // S_IFREG | S_IRWXU | S_IRWXG
-
-static const char *kSocketNamespaceAbstract = "localabstract";
-static const char *kSocketNamespaceFileSystem = "localfilesystem";
+static const uint32_t kDefaultMode = 0100770;
 
 static Status ReadAllBytes(Connection &conn, void *buffer, size_t size) {
-
   Status error;
   ConnectionStatus status;
   char *read_buffer = static_cast<char *>(buffer);
@@ -85,86 +72,215 @@ static Status ReadAllBytes(Connection &conn, void *buffer, size_t size) {
     error = Status::FromErrorStringWithFormat(
         "Unable to read requested number of bytes. Connection status: %d.",
         status);
+
   return error;
 }
 
-Status AdbClient::CreateByDeviceID(const std::string &device_id,
-                                   AdbClient &adb) {
-  Status error;
-  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;
+static Status ReadAdbMessage(Connection &conn, std::vector<char> &message) {
+  message.clear();
 
-  if (android_serial.empty()) {
-    DeviceIDList connected_devices;
-    error = adb.GetDevices(connected_devices);
-    if (error.Fail())
-      return error;
+  char buffer[5];
+  buffer[4] = 0;
+
+  auto error = ReadAllBytes(conn, buffer, 4);
+  if (error.Fail())
+    return error;
+
+  unsigned int packet_len = 0;
+  sscanf(buffer, "%x", &packet_len);
+
+  message.resize(packet_len, 0);
+  error = ReadAllBytes(conn, &message[0], packet_len);
+  if (error.Fail())
+    message.clear();
 
-    if (connected_devices.size() != 1)
-      return Status::FromErrorStringWithFormat(
-          "Expected a single connected device, got instead %zu - try "
-          "setting 'ANDROID_SERIAL'",
-          connected_devices.size());
-    adb.SetDeviceID(connected_devices.front());
-  } else {
-    adb.SetDeviceID(android_serial);
-  }
   return error;
 }
 
-AdbClient::AdbClient() = default;
-
-AdbClient::AdbClient(const std::string &device_id) : m_device_id(device_id) {}
+static Status GetResponseError(Connection &conn, const char *response_id) {
+  if (strcmp(response_id, kFAIL) != 0)
+    return Status::FromErrorStringWithFormat(
+        "Got unexpected response id from adb: \"%s\"", response_id);
 
-AdbClient::~AdbClient() = default;
+  std::vector<char> error_message;
+  auto error = ReadAdbMessage(conn, error_message);
+  if (!error.Success())
+    return error;
 
-void AdbClient::SetDeviceID(const std::string &device_id) {
-  m_device_id = device_id;
+  std::string error_str(&error_message[0], error_message.size());
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOGF(log, "ADB error: %s", error_str.c_str());
+  return Status(error_str);
 }
 
-const std::string &AdbClient::GetDeviceID() const { return m_device_id; }
+static Status ReadResponseStatus(Connection &conn) {
+  char response_id[5];
 
-Status AdbClient::Connect() {
+  const size_t packet_len = 4;
+  response_id[packet_len] = 0;
+
+  auto error = ReadAllBytes(conn, response_id, packet_len);
+  if (error.Fail())
+    return error;
+
+  if (strncmp(response_id, kOKAY, packet_len) != 0)
+    return GetResponseError(conn, response_id);
+
+  return error;
+}
+
+static Status SendAdbMessage(Connection &conn, llvm::StringRef packet) {
   Status error;
-  m_conn = std::make_unique<ConnectionFileDescriptor>();
+
+  char length_buffer[5];
+  snprintf(length_buffer, sizeof(length_buffer), "%04x",
+           static_cast<int>(packet.size()));
+
+  ConnectionStatus status;
+
+  conn.Write(length_buffer, 4, status, &error);
+  if (error.Fail())
+    return error;
+
+  conn.Write(packet.str().c_str(), packet.size(), status, &error);
+  return error;
+}
+
+static Status ConnectToAdb(Connection &conn) {
   std::string port = "5037";
-  if (const char *env_port = std::getenv("ANDROID_ADB_SERVER_PORT")) {
+  if (const char *env_port = std::getenv("ANDROID_ADB_SERVER_PORT"))
     port = env_port;
-  }
   std::string uri = "connect://127.0.0.1:" + port;
-  m_conn->Connect(uri.c_str(), &error);
 
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOGF(log, "Connecting to ADB server at %s", uri.c_str());
+
+  Status error;
+  conn.Connect(uri.c_str(), &error);
   return error;
 }
 
-Status AdbClient::GetDevices(DeviceIDList &device_list) {
-  device_list.clear();
-
-  auto error = SendMessage("host:devices");
+static Status EnterSyncMode(Connection &conn) {
+  auto error = SendAdbMessage(conn, "sync:");
   if (error.Fail())
     return error;
 
-  error = ReadResponseStatus();
+  return ReadResponseStatus(conn);
+}
+
+static Status SelectTargetDevice(Connection &conn, llvm::StringRef device_id) {
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOG(log, "Selecting device: {0}", device_id);
+
+  std::ostringstream msg;
+  msg << "host:transport:" << device_id.str();
+
+  auto error = SendAdbMessage(conn, msg.str());
   if (error.Fail())
     return error;
 
-  std::vector<char> in_buffer;
-  error = ReadMessage(in_buffer);
+  return ReadResponseStatus(conn);
+}
 
-  llvm::StringRef response(&in_buffer[0], in_buffer.size());
-  llvm::SmallVector<llvm::StringRef, 4> devices;
-  response.split(devices, "\n", -1, false);
+Expected<std::string> AdbClient::ResolveDeviceID(StringRef device_id) {
+  StringRef preferred_serial;
+  if (!device_id.empty())
+    preferred_serial = device_id;
+  else if (const char *env_serial = std::getenv("ANDROID_SERIAL"))
+    preferred_serial = env_serial;
 
-  for (const auto &device : devices)
-    device_list.push_back(std::string(device.split('\t').first));
+  if (preferred_serial.empty()) {
+    DeviceIDList connected_devices;
 
-  // Force disconnect since ADB closes connection after host:devices response
-  // is sent.
-  m_conn.reset();
-  return error;
+    auto GetDevices = [](DeviceIDList &device_list) -> Status {
+      device_list.clear();
+
+      // Create temporary ADB client for this operation only
+      auto temp_conn = std::make_unique<ConnectionFileDescriptor>();
+      auto error = ConnectToAdb(*temp_conn);
+      if (error.Fail())
+        return error;
+
+      // NOTE: ADB closes the connection after host:devices response.
+      // The connection is no longer valid
+      error = SendAdbMessage(*temp_conn, "host:devices");
+      if (error.Fail())
+        return error;
+
+      error = ReadResponseStatus(*temp_conn);
+      if (error.Fail())
+        return error;
+
+      std::vector<char> in_buffer;
+      error = ReadAdbMessage(*temp_conn, in_buffer);
+
+      StringRef response(&in_buffer[0], in_buffer.size());
+      SmallVector<StringRef, 4> devices;
+      response.split(devices, "\n", -1, false);
+
+      for (const auto &device : devices)
+        device_list.push_back(std::string(device.split('\t').first));
+      return error;
+    };
+
+    Status error = GetDevices(connected_devices);
+    if (error.Fail())
+      return error.ToError();
+
+    if (connected_devices.size() != 1)
+      return createStringError(
+          inconvertibleErrorCode(),
+          "Expected a single connected device, got instead %zu - try "
+          "setting 'ANDROID_SERIAL'",
+          connected_devices.size());
+
+    std::string resolved_device_id = std::move(connected_devices.front());
+    Log *log = GetLog(LLDBLog::Platform);
+    LLDB_LOGF(log, "AdbClient::ResolveDeviceID Resolved device ID: %s",
+              resolved_device_id.c_str());
+    return resolved_device_id;
+  }
+
+  std::string resolved_device_id = preferred_serial.str();
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOGF(log, "AdbClient::ResolveDeviceID Resolved device ID: %s",
+            resolved_device_id.c_str());
+  return resolved_device_id;
+}
+
+AdbClient::AdbClient(llvm::StringRef device_id) : m_device_id(device_id) {
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOGF(log,
+            "AdbClient::AdbClient(device_id='%s') - Creating AdbClient with "
+            "device ID",
+            device_id.str().c_str());
+  m_conn = std::make_unique<ConnectionFileDescriptor>();
+  Connect();
+}
+
+AdbClient::AdbClient() {
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOGF(
+      log,
+      "AdbClient::AdbClient() - Creating AdbClient with default constructor");
+  m_conn = std::make_unique<ConnectionFileDescriptor>();
+  Connect();
+}
+
+AdbClient::~AdbClient() {
+  Log *log = GetLog(LLDBLog::Platform);
+  LLDB_LOGF(log,
+            "AdbClient::~AdbClient() - Destroying AdbClient for device: %s",
+            m_device_id.c_str());
+}
+
+llvm::StringRef AdbClient::GetDeviceID() const { return m_device_id; }
+
+Status AdbClient::Connect() {
+  if (m_conn->IsConnected())
+    return Status();
+
+  return ConnectToAdb(*m_conn);
 }
 
 Status AdbClient::SetPortForwarding(const uint16_t local_port,
@@ -177,7 +293,7 @@ Status AdbClient::SetPortForwarding(const uint16_t local_port,
   if (error.Fail())
     return error;
 
-  return ReadResponseStatus();
+  return ReadResponseStatus(*m_conn);
 }
 
 Status
@@ -196,7 +312,7 @@ AdbClient::SetPortForwarding(const uint16_t local_port,
   if (error.Fail())
     return error;
 
-  return ReadResponseStatus();
+  return ReadResponseStatus(*m_conn);
 }
 
 Status AdbClient::DeletePortForwarding(const uint16_t local_port) {
@@ -207,56 +323,13 @@ Status AdbClient::DeletePortForwarding(const uint16_t local_port) {
   if (error.Fail())
     return error;
 
-  return ReadResponseStatus();
-}
-
-Status AdbClient::SendMessage(const std::string &packet, const bool reconnect) {
-  Status error;
-  if (!m_conn || reconnect) {
-    error = Connect();
-    if (error.Fail())
-      return error;
-  }
-
-  char length_buffer[5];
-  snprintf(length_buffer, sizeof(length_buffer), "%04x",
-           static_cast<int>(packet.size()));
-
-  ConnectionStatus status;
-
-  m_conn->Write(length_buffer, 4, status, &error);
-  if (error.Fail())
-    return error;
-
-  m_conn->Write(packet.c_str(), packet.size(), status, &error);
-  return error;
+  return ReadResponseStatus(*m_conn);
 }
 
-Status AdbClient::SendDeviceMessage(const std::string &packet) {
+Status AdbClient::SendDeviceMessage(llvm::StringRef packet) {
   std::ostringstream msg;
-  msg << "host-serial:" << m_device_id << ":" << packet;
-  return SendMessage(msg.str());
-}
-
-Status AdbClient::ReadMessage(std::vector<char> &message) {
-  message.clear();
-
-  char buffer[5];
-  buffer[4] = 0;
-
-  auto error = ReadAllBytes(buffer, 4);
-  if (error.Fail())
-    return error;
-
-  unsigned int packet_len = 0;
-  sscanf(buffer, "%x", &packet_len);
-
-  message.resize(packet_len, 0);
-  error = ReadAllBytes(&message[0], packet_len);
-  if (error.Fail())
-    message.clear();
-
-  return error;
+  msg << "host-serial:" << m_device_id << ":" << packet.str();
+  return SendAdbMessage(*m_conn, msg.str());
 }
 
 Status AdbClient::ReadMessageStream(std::vector<char> &message,
@@ -264,6 +337,9 @@ Status AdbClient::ReadMessageStream(std::vector<char> &message,
   auto start = steady_clock::now();
   message.clear();
 
+  if (!m_conn)
+    return Status::FromErrorString("No connection available");
+
   Status error;
   lldb::ConnectionStatus status = lldb::eConnectionStatusSuccess;
   char buffer[1024];
@@ -282,87 +358,22 @@ Status AdbClient::ReadMessageStream(std::vector<char> &message,
   return error;
 }
 
-Status AdbClient::ReadResponseStatus() {
-  char response_id[5];
-
-  static const size_t packet_len = 4;
-  response_id[packet_len] = 0;
-
-  auto error = ReadAllBytes(response_id, packet_len);
-  if (error.Fail())
-    return error;
-
-  if (strncmp(response_id, kOKAY, packet_len) != 0)
-    return GetResponseError(response_id);
-
-  return error;
-}
-
-Status AdbClient::GetResponseError(const char *response_id) {
-  if (strcmp(response_id, kFAIL) != 0)
-    return Status::FromErrorStringWithFormat(
-        "Got unexpected response id from adb: \"%s\"", response_id);
-
-  std::vector<char> error_message;
-  auto error = ReadMessage(error_message);
-  if (!error.Success())
-    return error;
-  return Status(std::string(&error_message[0], error_message.size()));
-}
-
-Status AdbClient::SwitchDeviceTransport() {
-  std::ostringstream msg;
-  msg << "host:transport:" << m_device_id;
-
-  auto error = SendMessage(msg.str());
-  if (error.Fail())
-    return error;
-
-  return ReadResponseStatus();
-}
-
-Status AdbClient::StartSync() {
-  auto error = SwitchDeviceTransport();
-  if (error.Fail())
-    return Status::FromErrorStringWithFormat(
-        "Failed to switch to device transport: %s", error.AsCString());
-
-  error = Sync();
-  if (error.Fail())
-    return Status::FromErrorStringWithFormat("Sync failed: %s",
-                                             error.AsCString());
-
-  return error;
-}
-
-Status AdbClient::Sync() {
-  auto error = SendMessage("sync:", false);
-  if (error.Fail())
-    return error;
-
-  return ReadResponseStatus();
-}
-
-Status AdbClient::ReadAllBytes(void *buffer, size_t size) {
-  return ::ReadAllBytes(*m_conn, buffer, size);
-}
-
 Status AdbClient::internalShell(const char *command, milliseconds timeout,
                                 std::vector<char> &output_buf) {
   output_buf.clear();
 
-  auto error = SwitchDeviceTransport();
+  auto error = SelectTargetDevice(*m_conn, m_device_id);
   if (error.Fail())
     return Status::FromErrorStringWithFormat(
-        "Failed to switch to device transport: %s", error.AsCString());
+        "Failed to select target device: %s", error.AsCString());
 
   StreamString adb_command;
   adb_command.Printf("shell:%s", command);
-  error = SendMessage(std::string(adb_command.GetString()), false);
+  error = SendAdbMessage(*m_conn, std::string(adb_command.GetString()));
   if (error.Fail())
     return error;
 
-  error = ReadResponseStatus();
+  error = ReadResponseStatus(*m_conn);
   if (error.Fail())
     return error;
 
@@ -417,18 +428,8 @@ Status AdbClient::ShellToFile(const char *command, milliseconds timeout,
   return Status();
 }
 
-std::unique_ptr<AdbClient::SyncService>
-AdbClient::GetSyncService(Status &error) {
-  std::unique_ptr<SyncService> sync_service;
-  error = StartSync();
-  if (error.Success())
-    sync_service.reset(new SyncService(std::move(m_conn)));
-
-  return sync_service;
-}
-
-Status AdbClient::SyncService::internalPullFile(const FileSpec &remote_file,
-                                                const FileSpec &local_file) {
+Status AdbSyncService::PullFileImpl(const FileSpec &remote_file,
+                                    const FileSpec &local_file) {
   const auto local_file_path = local_file.GetPath();
   llvm::FileRemover local_file_remover(local_file_path);
 
@@ -462,8 +463,8 @@ Status AdbClient::SyncService::internalPullFile(const FileSpec &remote_file,
   return error;
 }
 
-Status AdbClient::SyncService::internalPushFile(const FileSpec &local_file,
-                                                const FileSpec &remote_file) {
+Status AdbSyncService::PushFileImpl(const FileSpec &local_file,
+                                    const FileSpec &remote_file) {
   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())
@@ -487,7 +488,9 @@ Status AdbClient::SyncService::internalPushFile(const FileSpec &local_file,
                                                error.AsCString());
   }
   error = SendSyncRequest(
-      kDONE, llvm::sys::toTimeT(FileSystem::Instance().GetModificationTime(local_file)),
+      kDONE,
+      llvm::sys::toTimeT(
+          FileSystem::Instance().GetModificationTime(local_file)),
       nullptr);
   if (error.Fail())
     return error;
@@ -500,7 +503,7 @@ Status AdbClient::SyncService::internalPushFile(const FileSpec &local_file,
                                              error.AsCString());
   if (response_id == kFAIL) {
     std::string error_message(data_len, 0);
-    error = ReadAllBytes(&error_message[0], data_len);
+    error = ReadAllBytes(*m_conn, &error_message[0], data_len);
     if (error.Fail())
       return Status::FromErrorStringWithFormat(
           "Failed to read DONE error message: %s", error.AsCString());
@@ -518,9 +521,8 @@ Status AdbClient::SyncService::internalPushFile(const FileSpec &local_file,
   return error;
 }
 
-Status AdbClient::SyncService::internalStat(const FileSpec &remote_file,
-                                            uint32_t &mode, uint32_t &size,
-                                            uint32_t &mtime) {
+Status AdbSyncService::StatImpl(const FileSpec &remote_file, uint32_t &mode,
+                                uint32_t &size, uint32_t &mtime) {
   const std::string remote_file_path(remote_file.GetPath(false));
   auto error = SendSyncRequest(kSTAT, remote_file_path.length(),
                                remote_file_path.c_str());
@@ -532,7 +534,7 @@ Status AdbClient::SyncService::internalStat(const FileSpec &remote_file,
   static const size_t response_len = stat_len + (sizeof(uint32_t) * 3);
 
   std::vector<char> buffer(response_len);
-  error = ReadAllBytes(&buffer[0], buffer.size());
+  error = ReadAllBytes(*m_conn, &buffer[0], buffer.size());
   if (error.Fail())
     return Status::FromErrorStringWithFormat("Failed to read response: %s",
                                              error.AsCString());
@@ -555,51 +557,57 @@ Status AdbClient::SyncService::internalStat(const FileSpec &remote_file,
   return Status();
 }
 
-Status AdbClient::SyncService::PullFile(const FileSpec &remote_file,
-                                        const FileSpec &local_file) {
-  return executeCommand([this, &remote_file, &local_file]() {
-    return internalPullFile(remote_file, local_file);
+Status AdbSyncService::PullFile(const FileSpec &remote_file,
+                                const FileSpec &local_file) {
+  return ExecuteCommand([this, &remote_file, &local_file]() {
+    return PullFileImpl(remote_file, local_file);
   });
 }
 
-Status AdbClient::SyncService::PushFile(const FileSpec &local_file,
-                                        const FileSpec &remote_file) {
-  return executeCommand([this, &local_file, &remote_file]() {
-    return internalPushFile(local_file, remote_file);
+Status AdbSyncService::PushFile(cons...
[truncated]

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

Replace direct setenv() call with set_env() helper function that
handles cross-platform differences (using _putenv_s on Windows
and setenv on other platforms). This fixes the build failure:

error C3861: 'setenv': identifier not found
@cs01 cs01 force-pushed the cs01/adbclient-threadsafe2 branch from 88937b6 to 5938bf2 Compare September 19, 2025 18:04
@cs01
Copy link
Contributor Author

cs01 commented Sep 23, 2025

friendly ping @JDevlieghere @labath

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM given labath (who's OOO) reviewed the original PR and this is a reland with a minor change.

@JDevlieghere
Copy link
Member

@cs01 Can you please (at least temporarily) make your email address public before I merge this?

@cs01
Copy link
Contributor Author

cs01 commented Sep 23, 2025

I believe I did already in

cs01 force-pushed the cs01/adbclient-threadsafe2 branch from 88937b6 to 5938bf2
4 days ago.

I think that bot comment is stale.

@cs01
Copy link
Contributor Author

cs01 commented Sep 24, 2025

@JDevlieghere my email address is visible in the latest commits

@dmpots
Copy link
Contributor

dmpots commented Sep 25, 2025

@JDevlieghere my email address is visible in the latest commits

I'm seeing this when I go to merge it.

This commit will be authored by [email protected].

@cs01
Copy link
Contributor Author

cs01 commented Sep 25, 2025

Oh sorry, the commits were with my public address but I still had the github setting turn on. It should be turned off now.

@dmpots
Copy link
Contributor

dmpots commented Sep 25, 2025

Oh sorry, the commits were with my public address but I still had the github setting turn on. It should be turned off now.

Ok, looks better. Now I see

This commit will be authored by [email protected].

I will go ahead and merge since it looks like we have the necessary approvals.

@dmpots dmpots merged commit 223cfa8 into llvm:main Sep 25, 2025
9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 25, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-win running on as-builder-10 while building lldb at step 8 "test-check-lldb-unit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/211/builds/2330

Here is the relevant piece of the build log for the reference
Step 8 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure)
******************** TEST 'lldb-unit :: Platform/Android/./AdbClientTests.exe/7/20' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe-lldb-unit-30696-7-20.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=20 GTEST_SHARD_INDEX=7 C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe
--

Note: This is test shard 8 of 20.

[==========] Running 1 test from 1 test suite.

[----------] Global test environment set-up.

[----------] 1 test from AdbClientTest

[ RUN      ] AdbClientTest.RealTcpConnection

Assertion failed: error.Fail(), file C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\source\Host\common\TCPSocket.cpp, line 254

Exception Code: 0x80000003

 #0 0x00007ff6dad703f5 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0xe03f5)

 #1 0x00007ffbe10fbb04 (C:\Windows\System32\ucrtbase.dll+0x7bb04)

 #2 0x00007ffbe10fcad1 (C:\Windows\System32\ucrtbase.dll+0x7cad1)

 #3 0x00007ffbe10fe4a1 (C:\Windows\System32\ucrtbase.dll+0x7e4a1)

 #4 0x00007ffbe10fe6e1 (C:\Windows\System32\ucrtbase.dll+0x7e6e1)

 #5 0x00007ff6dc0ade7a (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x141de7a)

 #6 0x00007ff6dad2c944 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x9c944)

 #7 0x00007ff6dade310b (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x15310b)

 #8 0x00007ff6dae07ae7 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x177ae7)

 #9 0x00007ff6dae07f46 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x177f46)

#10 0x00007ff6dae08963 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x178963)

#11 0x00007ff6dade314b (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x15314b)

#12 0x00007ff6dae08259 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x178259)

#13 0x00007ff6dcd69fa4 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x20d9fa4)

#14 0x00007ff6dcd19794 (C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\AdbClientTests.exe+0x2089794)

...

@cs01
Copy link
Contributor Author

cs01 commented Sep 25, 2025

I see the build error on windows. I will look into fixing it now. I hope to post a PR in the next 1 hr or less to fix this.

@cs01
Copy link
Contributor Author

cs01 commented Sep 25, 2025

I have a fix, preparing a PR now.

@cs01
Copy link
Contributor Author

cs01 commented Sep 25, 2025

PR in #160771

dmpots pushed a commit that referenced this pull request Sep 25, 2025
#159676 was recently landed.
After it was landed, additional tests were ran, where I saw an assertion
error on windows only. I am not able to test on windows, and the test is
a new test to mock an adb server. The mock server fails to start on
windows, so I am disabling to fix the breakage on main. This is not an
issue with the main code, only a test issue.

Relevant error output:
```
Step 8 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure)
******************** TEST 'lldb-unit :: Platform/Android/./AdbClientTests.exe/7/20' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe-lldb-unit-30696-7-20.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=20 GTEST_SHARD_INDEX=7 C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe
--

Note: This is test shard 8 of 20.

[==========] Running 1 test from 1 test suite.

[----------] Global test environment set-up.

[----------] 1 test from AdbClientTest

[ RUN      ] AdbClientTest.RealTcpConnection

Assertion failed: error.Fail(), file C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\source\Host\common\TCPSocket.cpp, line 254
```
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Sep 25, 2025
…kage (#160771)

llvm/llvm-project#159676 was recently landed.
After it was landed, additional tests were ran, where I saw an assertion
error on windows only. I am not able to test on windows, and the test is
a new test to mock an adb server. The mock server fails to start on
windows, so I am disabling to fix the breakage on main. This is not an
issue with the main code, only a test issue.

Relevant error output:
```
Step 8 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure)
******************** TEST 'lldb-unit :: Platform/Android/./AdbClientTests.exe/7/20' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe-lldb-unit-30696-7-20.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=20 GTEST_SHARD_INDEX=7 C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe
--

Note: This is test shard 8 of 20.

[==========] Running 1 test from 1 test suite.

[----------] Global test environment set-up.

[----------] 1 test from AdbClientTest

[ RUN      ] AdbClientTest.RealTcpConnection

Assertion failed: error.Fail(), file C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\source\Host\common\TCPSocket.cpp, line 254
```
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…#159676)

Reattempt at llvm#145382 (cc
@labath). This time setenv() was replaced with set_env()
(llvm#145382 (comment)).

---------

Co-authored-by: Chad Smith <[email protected]>
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…160771)

llvm#159676 was recently landed.
After it was landed, additional tests were ran, where I saw an assertion
error on windows only. I am not able to test on windows, and the test is
a new test to mock an adb server. The mock server fails to start on
windows, so I am disabling to fix the breakage on main. This is not an
issue with the main code, only a test issue.

Relevant error output:
```
Step 8 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure)
******************** TEST 'lldb-unit :: Platform/Android/./AdbClientTests.exe/7/20' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe-lldb-unit-30696-7-20.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=20 GTEST_SHARD_INDEX=7 C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\Platform\Android\.\AdbClientTests.exe
--

Note: This is test shard 8 of 20.

[==========] Running 1 test from 1 test suite.

[----------] Global test environment set-up.

[----------] 1 test from AdbClientTest

[ RUN      ] AdbClientTest.RealTcpConnection

Assertion failed: error.Fail(), file C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\source\Host\common\TCPSocket.cpp, line 254
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants