[Lldb-commits] [lldb] r287880 - Use more chrono in AdbClient

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 24 06:11:48 PST 2016


Author: labath
Date: Thu Nov 24 08:11:47 2016
New Revision: 287880

URL: http://llvm.org/viewvc/llvm-project?rev=287880&view=rev
Log:
Use more chrono in AdbClient

This refactors AdbClient interface in terms of std::chrono.

Modified:
    lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp
    lldb/trunk/source/Plugins/Platform/Android/AdbClient.h
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp

Modified: lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp?rev=287880&r1=287879&r2=287880&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.cpp Thu Nov 24 08:11:47 2016
@@ -383,10 +383,10 @@ Error AdbClient::internalShell(const cha
   return Error();
 }
 
-Error AdbClient::Shell(const char *command, uint32_t timeout_ms,
+Error AdbClient::Shell(const char *command, milliseconds timeout,
                        std::string *output) {
   std::vector<char> output_buffer;
-  auto error = internalShell(command, milliseconds(timeout_ms), output_buffer);
+  auto error = internalShell(command, timeout, output_buffer);
   if (error.Fail())
     return error;
 
@@ -395,10 +395,10 @@ Error AdbClient::Shell(const char *comma
   return error;
 }
 
-Error AdbClient::ShellToFile(const char *command, uint32_t timeout_ms,
+Error AdbClient::ShellToFile(const char *command, milliseconds timeout,
                              const FileSpec &output_file_spec) {
   std::vector<char> output_buffer;
-  auto error = internalShell(command, milliseconds(timeout_ms), output_buffer);
+  auto error = internalShell(command, timeout, output_buffer);
   if (error.Fail())
     return error;
 

Modified: lldb/trunk/source/Plugins/Platform/Android/AdbClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/AdbClient.h?rev=287880&r1=287879&r2=287880&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/AdbClient.h (original)
+++ lldb/trunk/source/Plugins/Platform/Android/AdbClient.h Thu Nov 24 08:11:47 2016
@@ -94,9 +94,10 @@ public:
 
   Error DeletePortForwarding(const uint16_t local_port);
 
-  Error Shell(const char *command, uint32_t timeout_ms, std::string *output);
+  Error Shell(const char *command, std::chrono::milliseconds timeout,
+              std::string *output);
 
-  Error ShellToFile(const char *command, uint32_t timeout_ms,
+  Error ShellToFile(const char *command, std::chrono::milliseconds timeout,
                     const FileSpec &output_file_spec);
 
   std::unique_ptr<SyncService> GetSyncService(Error &error);

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=287880&r1=287879&r2=287880&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Thu Nov 24 08:11:47 2016
@@ -28,6 +28,7 @@
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::platform_android;
+using namespace std::chrono;
 
 static uint32_t g_initialize_count = 0;
 static const unsigned int g_android_default_cache_size =
@@ -230,7 +231,7 @@ Error PlatformAndroid::GetFile(const Fil
   char cmd[PATH_MAX];
   snprintf(cmd, sizeof(cmd), "cat '%s'", source_file);
 
-  return adb.ShellToFile(cmd, 60000 /* ms */, destination);
+  return adb.ShellToFile(cmd, minutes(1), destination);
 }
 
 Error PlatformAndroid::PutFile(const FileSpec &source,
@@ -288,7 +289,7 @@ uint32_t PlatformAndroid::GetSdkVersion(
   std::string version_string;
   AdbClient adb(m_device_id);
   Error error =
-      adb.Shell("getprop ro.build.version.sdk", 5000 /* ms */, &version_string);
+      adb.Shell("getprop ro.build.version.sdk", seconds(5), &version_string);
   version_string = llvm::StringRef(version_string).trim().str();
 
   if (error.Fail() || version_string.empty()) {
@@ -327,7 +328,7 @@ Error PlatformAndroid::DownloadSymbolFil
   AdbClient adb(m_device_id);
   std::string tmpdir;
   Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp",
-                          5000 /* ms */, &tmpdir);
+                          seconds(5), &tmpdir);
   if (error.Fail() || tmpdir.empty())
     return Error("Failed to generate temporary directory on the device (%s)",
                  error.AsCString());
@@ -338,7 +339,7 @@ Error PlatformAndroid::DownloadSymbolFil
   tmpdir_remover(&tmpdir, [this, &adb](std::string *s) {
     StreamString command;
     command.Printf("rm -rf %s", s->c_str());
-    Error error = adb.Shell(command.GetData(), 5000 /* ms */, nullptr);
+    Error error = adb.Shell(command.GetData(), seconds(5), nullptr);
 
     Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
     if (log && error.Fail())
@@ -353,7 +354,7 @@ Error PlatformAndroid::DownloadSymbolFil
   command.Printf("oatdump --symbolize=%s --output=%s",
                  module_sp->GetPlatformFileSpec().GetCString(false),
                  symfile_platform_filespec.GetCString(false));
-  error = adb.Shell(command.GetData(), 60000 /* ms */, nullptr);
+  error = adb.Shell(command.GetData(), minutes(1), nullptr);
   if (error.Fail())
     return Error("Oatdump failed: %s", error.AsCString());
 




More information about the lldb-commits mailing list