Index: include/lldb/Target/Platform.h =================================================================== --- include/lldb/Target/Platform.h +++ include/lldb/Target/Platform.h @@ -947,6 +947,12 @@ virtual const std::vector & GetTrapHandlerSymbolNames (); + // 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 Index: source/Plugins/Platform/Android/PlatformAndroid.h =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.h +++ source/Plugins/Platform/Android/PlatformAndroid.h @@ -83,6 +83,9 @@ Error DisconnectRemote () override; + uint32_t + GetDefaultMemoryCacheLineSize() override; + protected: const char * GetCacheHostname () override; Index: source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.cpp +++ source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -28,6 +28,7 @@ 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 @@ } uint32_t +PlatformAndroid::GetDefaultMemoryCacheLineSize() +{ + return g_android_default_cache_size; +} + +uint32_t PlatformAndroid::GetSdkVersion() { if (!IsConnected()) Index: source/Target/Process.cpp =================================================================== --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -813,6 +813,13 @@ 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); } //---------------------------------------------------------------------- Index: test/android/platform/Makefile =================================================================== --- /dev/null +++ test/android/platform/Makefile @@ -0,0 +1,4 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules Index: test/android/platform/TestDefaultCacheLineSize.py =================================================================== --- /dev/null +++ test/android/platform/TestDefaultCacheLineSize.py @@ -0,0 +1,45 @@ +""" +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__) + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + + @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"]) + + # We have successfully caught thread creation. Now just 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() Index: test/android/platform/main.cpp =================================================================== --- /dev/null +++ test/android/platform/main.cpp @@ -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; +}