labath created this revision.
labath added reviewers: clayborg, tberghammer.
labath added a subscriber: lldb-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

ADB packets have a fixed size of 4k. This means the size of memory reads does 
not affect speed
too much (as long as it fits in one packet). Therefore, I am increasing the 
default memory read
size for android to 2k. This value is used only if the user has not modified 
the default
memory-cache-line-size setting.

http://reviews.llvm.org/D13812

Files:
  include/lldb/Target/Process.h
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -180,6 +180,14 @@
     return m_collection_sp->GetPropertyAtIndexAsUInt64 (NULL, idx, g_properties[idx].default_uint_value);
 }
 
+lldb::OptionValueSP
+ProcessProperties::GetMemoryCacheLineSizeOption()
+{
+    const uint32_t idx = ePropertyMemCacheLineSize;
+    lldb_private::ExecutionContext exe_ctx(m_process);
+    return m_collection_sp->GetPropertyAtIndex(&exe_ctx, true, idx)->GetValue();
+}
+
 Args
 ProcessProperties::GetExtraStartupCommands () const
 {
Index: source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
===================================================================
--- source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
+++ source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
@@ -36,10 +36,25 @@
     Error
     DisconnectRemote () override;
 
+    lldb::ProcessSP
+    DebugProcess(ProcessLaunchInfo &launch_info,
+                 Debugger &debugger,
+                 Target *target,       // Can be NULL, if NULL create a new target, else use existing one
+                 Error &error) override;
+
+    lldb::ProcessSP
+    Attach(ProcessAttachInfo &attach_info,
+           Debugger &debugger,
+           Target *target,       // Can be NULL, if NULL create a new target, else use existing one
+           Error &error) override;
+
 protected:
     std::string m_device_id;
     std::map<lldb::pid_t, uint16_t> m_port_forwards;
 
+    void
+    AdjustProcessProperties(const lldb::ProcessSP &process_sp);
+
     uint16_t
     LaunchGDBserverAndGetPort (lldb::pid_t &pid) override;
 
Index: source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===================================================================
--- source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -11,6 +11,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Target/ExecutionContext.h"
 #include "AdbClient.h"
 #include "PlatformAndroidRemoteGDBServer.h"
 #include "Utility/UriParser.h"
@@ -22,6 +23,7 @@
 using namespace platform_android;
 
 static const lldb::pid_t g_remote_platform_pid = 0; // Alias for the process id of lldb-platform
+static const unsigned int g_android_default_cache_size = 2048; // Fits inside 4k adb packet.
 
 static Error
 ForwardPortWithAdb (const uint16_t local_port, const uint16_t remote_port, std::string& device_id)
@@ -136,6 +138,40 @@
     return PlatformRemoteGDBServer::DisconnectRemote ();
 }
 
+lldb::ProcessSP
+PlatformAndroidRemoteGDBServer::DebugProcess(ProcessLaunchInfo &launch_info,
+              Debugger &debugger,
+              Target *target,       // Can be NULL, if NULL create a new target, else use existing one
+              Error &error)
+{
+    lldb::ProcessSP process_sp = PlatformRemoteGDBServer::DebugProcess(launch_info, debugger, target, error);
+    AdjustProcessProperties(process_sp);
+    return process_sp;
+}
+
+lldb::ProcessSP
+PlatformAndroidRemoteGDBServer::Attach(ProcessAttachInfo &attach_info,
+        Debugger &debugger,
+        Target *target,       // Can be NULL, if NULL create a new target, else use existing one
+        Error &error)
+{
+    lldb::ProcessSP process_sp = PlatformRemoteGDBServer::Attach(attach_info, debugger, target, error);
+    AdjustProcessProperties(process_sp);
+    return process_sp;
+}
+
+void
+PlatformAndroidRemoteGDBServer::AdjustProcessProperties(const lldb::ProcessSP &process_sp)
+{
+    if (! process_sp)
+        return;
+
+    lldb::OptionValueSP value_sp = process_sp->GetMemoryCacheLineSizeOption();
+
+    if (value_sp && ! value_sp->OptionWasSet())
+        value_sp->SetUInt64Value(g_android_default_cache_size);
+}
+
 void
 PlatformAndroidRemoteGDBServer::DeleteForwardPort (lldb::pid_t pid)
 {
Index: include/lldb/Target/Process.h
===================================================================
--- include/lldb/Target/Process.h
+++ include/lldb/Target/Process.h
@@ -67,6 +67,9 @@
     uint64_t
     GetMemoryCacheLineSize () const;
 
+    lldb::OptionValueSP
+    GetMemoryCacheLineSizeOption ();
+
     Args
     GetExtraStartupCommands () const;
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to