[Lldb-commits] [lldb] r250814 - Increase default memory cache line size for android

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 20 03:33:18 PDT 2015


Author: labath
Date: Tue Oct 20 05:33:17 2015
New Revision: 250814

URL: http://llvm.org/viewvc/llvm-project?rev=250814&view=rev
Log:
Increase default memory cache line size for android

Summary:
ADB packets have a maximum 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.

Reviewers: clayborg, tberghammer

Subscribers: tberghammer, danalbert, srhines, lldb-commits

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

Added:
    lldb/trunk/test/android/
    lldb/trunk/test/android/platform/
    lldb/trunk/test/android/platform/Makefile
    lldb/trunk/test/android/platform/TestDefaultCacheLineSize.py
    lldb/trunk/test/android/platform/main.cpp
Modified:
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
    lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=250814&r1=250813&r2=250814&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Tue Oct 20 05:33:17 2015
@@ -947,7 +947,6 @@ class ModuleCache;
         virtual const std::vector<ConstString> &
         GetTrapHandlerSymbolNames ();
 
-
         //------------------------------------------------------------------
         /// Find a support executable that may not live within in the
         /// standard locations related to LLDB.
@@ -970,6 +969,14 @@ class ModuleCache;
             return FileSpec();
         }
 
+        //------------------------------------------------------------------
+        /// Allow the platform to set preferred memory cache line size. If non-zero (and the user
+        /// has not set cache line size explicitly), this value will be used as the cache line
+        /// size for memory reads.
+        //------------------------------------------------------------------
+        virtual uint32_t
+        GetDefaultMemoryCacheLineSize() { return 0; }
+
     protected:
         bool m_is_host;
         // Set to true when we are able to actually set the OS version while 

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=250814&r1=250813&r2=250814&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Tue Oct 20 05:33:17 2015
@@ -28,6 +28,7 @@ using namespace lldb_private;
 using namespace lldb_private::platform_android;
 
 static uint32_t g_initialize_count = 0;
+static const unsigned int g_android_default_cache_size = 2048; // Fits inside 4k adb packet.
 
 void
 PlatformAndroid::Initialize ()
@@ -275,6 +276,12 @@ PlatformAndroid::DisconnectRemote()
 }
 
 uint32_t
+PlatformAndroid::GetDefaultMemoryCacheLineSize()
+{
+    return g_android_default_cache_size;
+}
+
+uint32_t
 PlatformAndroid::GetSdkVersion()
 {
     if (!IsConnected())

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h?rev=250814&r1=250813&r2=250814&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.h Tue Oct 20 05:33:17 2015
@@ -83,6 +83,9 @@ namespace platform_android {
         Error
         DisconnectRemote () override;
 
+        uint32_t
+        GetDefaultMemoryCacheLineSize() override;
+
      protected:
         const char *
         GetCacheHostname () override;

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=250814&r1=250813&r2=250814&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Oct 20 05:33:17 2015
@@ -813,6 +813,13 @@ Process::Process(lldb::TargetSP target_s
                                                      eBroadcastInternalStateControlResume);
     // We need something valid here, even if just the default UnixSignalsSP.
     assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization");
+
+    // Allow the platform to override the default cache line size
+    OptionValueSP value_sp =
+        m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue();
+    uint32_t platform_cache_line_size = target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
+    if (! value_sp->OptionWasSet() && platform_cache_line_size != 0)
+        value_sp->SetUInt64Value(platform_cache_line_size);
 }
 
 //----------------------------------------------------------------------

Added: lldb/trunk/test/android/platform/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/android/platform/Makefile?rev=250814&view=auto
==============================================================================
--- lldb/trunk/test/android/platform/Makefile (added)
+++ lldb/trunk/test/android/platform/Makefile Tue Oct 20 05:33:17 2015
@@ -0,0 +1,4 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/android/platform/TestDefaultCacheLineSize.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/android/platform/TestDefaultCacheLineSize.py?rev=250814&view=auto
==============================================================================
--- lldb/trunk/test/android/platform/TestDefaultCacheLineSize.py (added)
+++ lldb/trunk/test/android/platform/TestDefaultCacheLineSize.py Tue Oct 20 05:33:17 2015
@@ -0,0 +1,41 @@
+"""
+Verify the default cache line size for android targets
+"""
+
+import os
+import unittest2
+import lldb
+from lldbtest import *
+import lldbutil
+
+class DefaultCacheLineSizeTestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @skipUnlessPlatform(['android'])
+    def test_cache_line_size(self):
+        self.build(dictionary=self.getBuildFlags())
+        exe = os.path.join(os.getcwd(), "a.out")
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target and target.IsValid(), "Target is valid")
+
+        breakpoint = target.BreakpointCreateByName("main")
+        self.assertTrue(breakpoint and breakpoint.IsValid(), "Breakpoint is valid")
+
+        # Run the program.
+        process = target.LaunchSimple(None, None, self.get_process_working_directory())
+        self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
+        self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
+
+        # check the setting value
+        self.expect("settings show target.process.memory-cache-line-size", patterns=[" = 2048"])
+
+        # Run to completion.
+        process.Continue()
+        self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/android/platform/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/android/platform/main.cpp?rev=250814&view=auto
==============================================================================
--- lldb/trunk/test/android/platform/main.cpp (added)
+++ lldb/trunk/test/android/platform/main.cpp Tue Oct 20 05:33:17 2015
@@ -0,0 +1,13 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main ()
+{
+    return 0;
+}




More information about the lldb-commits mailing list