diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index edb4c513a64d29c5b99f0f6c90e0c9b99fcd9cac..d9b7735b7e0a70fa226f0ca1327946ec4e8c453b 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -1,5 +1,12 @@ cmake_minimum_required(VERSION 3.13.4) +# OHOS_LOCAL begin +option(LLDB_ENABLE_PERFORMANCE "Enable lldb performance monitoring" OFF) +if(LLDB_ENABLE_PERFORMANCE) + add_definitions(-DLLDB_ENABLE_PERFORMANCE_MONITORING) +endif() +# OHOS_LOCAL end + # Add path for custom modules. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} diff --git a/lldb/include/lldb/Utility/LLDBLog.h b/lldb/include/lldb/Utility/LLDBLog.h index 63dbb63f6f5672346aa37187a88cc7b3e4acd0b2..1252dcc6bc2dd5317bbd153f4b430dcb9ff68e39 100644 --- a/lldb/include/lldb/Utility/LLDBLog.h +++ b/lldb/include/lldb/Utility/LLDBLog.h @@ -47,8 +47,11 @@ enum class LLDBLog : Log::MaskType { Types = Log::ChannelFlag<28>, Unwind = Log::ChannelFlag<29>, Watchpoints = Log::ChannelFlag<30>, - OnDemand = Log::ChannelFlag<31>, - LLVM_MARK_AS_BITMASK_ENUM(Watchpoints), + // OHOS_LOCAL begin + Performance = Log::ChannelFlag<31>, + OnDemand = Log::ChannelFlag<32>, + LLVM_MARK_AS_BITMASK_ENUM(OnDemand), + // OHOS_LOCAL end }; LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); @@ -58,4 +61,7 @@ void InitializeLldbChannel(); template <> Log::Channel &LogChannelFor(); } // namespace lldb_private +// OHOS_LOCAL +#define LLDB_PERFORMANCE_LOG(...) LLDB_LOGF(GetLog(LLDBLog::Performance), __VA_ARGS__) + #endif // LLDB_UTILITY_LLDBLOG_H diff --git a/lldb/include/lldb/Utility/Timer.h b/lldb/include/lldb/Utility/Timer.h index 201378bbeb2cc54041f5b143a5a8ce4de985f3d6..d046861cc30f0a110aa9831cc277384c6a860a20 100644 --- a/lldb/include/lldb/Utility/Timer.h +++ b/lldb/include/lldb/Utility/Timer.h @@ -75,6 +75,27 @@ private: Timer(const Timer &) = delete; const Timer &operator=(const Timer &) = delete; }; +// OHOS_LOCAL begin +namespace LLDBPerformanceTagName +{ + const char *const TAG_DYNAMICLOADER = "LLDB_Performance_DynamicLoader"; + const char *const TAG_BREAKPOINTS = "LLDB_Performance_Breakpoints"; + const char *const TAG_CONNECTION = "LLDB_Performance_Connection"; + const char *const TAG_JITLOADER = "LLDB_Performance_JITLoader"; + const char *const TAG_GDBREMOTE = "LLDB_Performance_GDBRemote"; + const char *const TAG_PLATFORM = "LLDB_Performance_Platform"; + const char *const TAG_DEBUGGER = "LLDB_Performance_Debugger"; + const char *const TAG_COMMANDS = "LLDB_Performance_Commands"; + const char *const TAG_MODULES = "LLDB_Performance_Modules"; + const char *const TAG_SYMBOLS = "LLDB_Performance_Symbols"; + const char *const TAG_PROCESS = "LLDB_Performance_Process"; + const char *const TAG_TARGET = "LLDB_Performance_Target"; + const char *const TAG_UNWIND = "LLDB_Performance_Unwind"; + const char *const TAG_THREAD = "LLDB_Performance_Thread"; + const char *const TAG_STEP = "LLDB_Performance_Step"; + const char *const TAG_HDC = "LLDB_Performance_HDC"; +} +// OHOS_LOCAL end } // namespace lldb_private @@ -87,4 +108,15 @@ private: static ::lldb_private::Timer::Category _cat(LLVM_PRETTY_FUNCTION); \ ::lldb_private::Timer _scoped_timer(_cat, __VA_ARGS__) +// OHOS_LOCAL begin +#ifdef LLDB_ENABLE_PERFORMANCE_MONITORING +#define LLDB_MODULE_TIMER(tag) \ + static std::string _tag_str = (llvm::Twine(tag) + llvm::Twine(LLVM_PRETTY_FUNCTION)).str(); \ + static ::lldb_private::Timer::Category _module_cat(_tag_str.c_str()); \ + ::lldb_private::Timer _module_scoped_timer(_module_cat, "%s", LLVM_PRETTY_FUNCTION) +#else +#define LLDB_MODULE_TIMER(tag) +#endif +// OHOS_LOCAL end + #endif // LLDB_UTILITY_TIMER_H diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 578cf14283d920d3c8f97a86024621e7d1b7bc2b..f07f44e64d23eafd35e5c9642ab922e033907afe 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -30,6 +30,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include @@ -440,6 +441,7 @@ BreakpointOptions &Breakpoint::GetOptions() { return m_options; } const BreakpointOptions &Breakpoint::GetOptions() const { return m_options; } void Breakpoint::ResolveBreakpoint() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL if (m_resolver_sp) { ElapsedTime elapsed(m_resolve_time); m_resolver_sp->ResolveBreakpoint(*m_filter_sp); diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 23954dd3c9fdc23dffad932a357fd1ea72db62c9..015bd91c920e92e3a4e728a55a83cac67615a67a 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -30,6 +30,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/LLDBLog.h" // OHOS_LOCAL #include #include @@ -706,6 +707,8 @@ protected: target_stats.GetFrameVariableStats().NotifySuccess(); else target_stats.GetFrameVariableStats().NotifyFailure(); + + LLDB_PERFORMANCE_LOG("Completed frame variable."); // OHOS_LOCAL return res; } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 28a99ea3d94a582153623f56ed56cf034931c8f3..dce7afdd773ebbf3bef97ca4e9f7836bb587b2eb 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -34,6 +34,7 @@ #include "lldb/Utility/State.h" #include "llvm/ADT/ScopeExit.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include @@ -377,6 +378,7 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_COMMANDS); // OHOS_LOCAL PlatformSP platform_sp( GetDebugger().GetPlatformList().GetSelectedPlatform()); diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 56cbacbebec5656d2353e9ec283158bb50a2d312..3f1590f068159adbba132e16a3004a2908c7e14e 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -25,6 +25,7 @@ #include "lldb/Utility/Args.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/LLDBLog.h" // OHOS_LOCAL #include "llvm/Support/Errno.h" using namespace lldb; @@ -226,6 +227,7 @@ protected: } } } + LLDB_PERFORMANCE_LOG("Completed register read."); // OHOS_LOCAL return result.Succeeded(); } diff --git a/lldb/source/Commands/CommandObjectThreadUtil.cpp b/lldb/source/Commands/CommandObjectThreadUtil.cpp index 504d5fa0118d4c271424433b4e2effcad08136e3..d3bb2bf62189ec4a28115c49198923de1231e3b7 100644 --- a/lldb/source/Commands/CommandObjectThreadUtil.cpp +++ b/lldb/source/Commands/CommandObjectThreadUtil.cpp @@ -11,6 +11,7 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/LLDBLog.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -43,6 +44,7 @@ bool CommandObjectIterateOverThreads::DoExecute(Args &command, Thread *thread = m_exe_ctx.GetThreadPtr(); if (!thread || !HandleOneThread(thread->GetID(), result)) return false; + LLDB_PERFORMANCE_LOG("Completed backtrace."); // OHOS_LOCAL return result.Succeeded(); } else if (command.GetArgumentCount() == 1) { all_threads = ::strcmp(command.GetArgumentAtIndex(0), "all") == 0; diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 62857c181af891f1e6f0d82f0077eee6aeffed4a..780895a29430fef120f6d6128419fb1907fdfa1b 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -52,6 +52,7 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #if defined(_WIN32) #include "lldb/Host/windows/PosixApi.h" @@ -311,6 +312,7 @@ const FormatEntity::Entry *Debugger::GetThreadFormat() const { } const FormatEntity::Entry *Debugger::GetThreadStopFormat() const { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DEBUGGER); // OHOS_LOCAL const uint32_t idx = ePropertyThreadStopFormat; return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx); } @@ -1713,6 +1715,7 @@ lldb::thread_result_t Debugger::DefaultEventHandler() { while (!done) { EventSP event_sp; if (listener_sp->GetEvent(event_sp, llvm::None)) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DEBUGGER); // OHOS_LOCAL if (event_sp) { Broadcaster *broadcaster = event_sp->GetBroadcaster(); if (broadcaster) { diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp index 96e0d4ec6555d359c95fbc51462f9683c2f5d1fb..8abba45d76d0ea91f06619aae3c0e7c47c41368d 100644 --- a/lldb/source/Core/DynamicLoader.cpp +++ b/lldb/source/Core/DynamicLoader.cpp @@ -18,6 +18,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "lldb/lldb-private-interfaces.h" #include "llvm/ADT/StringRef.h" @@ -70,6 +71,7 @@ void DynamicLoader::SetStopWhenImagesChange(bool stop) { } ModuleSP DynamicLoader::GetTargetExecutable() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DYNAMICLOADER); // OHOS_LOCAL Target &target = m_process->GetTarget(); ModuleSP executable = target.GetExecutableModule(); diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 1692a3710a3dee69c96b019b3ebbbe0cfc4a1341..becd6c1d5871a55927705896eb6e39e087637e91 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -25,6 +25,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/UUID.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "lldb/lldb-defines.h" #if defined(_WIN32) @@ -778,6 +779,7 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl *old_modules, bool *did_create_ptr, bool always_create) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_MODULES); // OHOS_LOCAL ModuleList &shared_module_list = GetSharedModuleList(); std::lock_guard guard( shared_module_list.m_modules_mutex); diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index dc5b24979fb54e0391fe45c1eae34c9ab03340f3..765f5618ab0d8eec8a09e13ef37dc443ad7a97ff 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -249,6 +249,7 @@ size_t ConnectionFileDescriptor::Read(void *dst, size_t dst_len, const Timeout &timeout, ConnectionStatus &status, Status *error_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_CONNECTION); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Connection); std::unique_lock locker(m_mutex, std::defer_lock); @@ -445,6 +446,7 @@ ConnectionFileDescriptor::BytesAvailable(const Timeout &timeout, // Read. If we ever get used more generally we will need to lock here as // well. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_CONNECTION); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Connection); LLDB_LOG(log, "this = {0}, timeout = {1}", this, timeout); diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 6ef209b20fc676d11f97211e87c8b184a3d5e566..b6c6e7b07ab29ce8b4174b46b3b92c7965ba198b 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1834,6 +1834,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line, LazyBool lazy_add_to_history, CommandReturnObject &result) { + LLDB_PERFORMANCE_LOG("HandleCommand: %s", command_line); // OHOS_LOCAL + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_COMMANDS); // OHOS_LOCAL std::string command_string(command_line); std::string original_command_string(command_line); diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 719cfbc9e802331f85d355459530aa183808a4a7..e3498fa39b217d4684e455fd85aa4a8f6671462a 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -28,6 +28,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "lldb/Target/Language.h" @@ -717,6 +718,7 @@ Thread *CommandObject::GetDefaultThread() { bool CommandObjectParsed::Execute(const char *args_string, CommandReturnObject &result) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_COMMANDS); // OHOS_LOCAL bool handled = false; Args cmd_args(args_string); if (HasOverrideCallback()) { diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp index 4869cf0fd9c8165a777c08a72dc8598694687880..267651742e05348869ab326182603f0a3d6aeba9 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -17,6 +17,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "llvm/Support/Path.h" @@ -113,6 +114,7 @@ addr_t DYLDRendezvous::ResolveRendezvousAddress() { } void DYLDRendezvous::UpdateExecutablePath() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DYNAMICLOADER); // OHOS_LOCAL if (m_process) { Log *log = GetLog(LLDBLog::DynamicLoader); Module *exe_mod = m_process->GetTarget().GetExecutableModulePointer(); @@ -130,6 +132,7 @@ void DYLDRendezvous::UpdateExecutablePath() { } bool DYLDRendezvous::Resolve() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DYNAMICLOADER); // OHOS_LOCAL Log *log = GetLog(LLDBLog::DynamicLoader); const size_t word_size = 4; diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 540067eedc86ccc0bf99c3af2206920686c740bc..8fc7488071d4df984f4fdefafbd37196ccd8a783 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -25,6 +25,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/ProcessInfo.h" #include "llvm/Support/ThreadPool.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include @@ -78,6 +79,7 @@ DynamicLoaderPOSIXDYLD::~DynamicLoaderPOSIXDYLD() { } void DynamicLoaderPOSIXDYLD::DidAttach() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DYNAMICLOADER); // OHOS_LOCAL Log *log = GetLog(LLDBLog::DynamicLoader); LLDB_LOGF(log, "DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64, __FUNCTION__, m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID); @@ -584,6 +586,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(const FileSpec &file, addr_t link_map_addr, addr_t base_addr, bool base_addr_is_offset) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DYNAMICLOADER); // OHOS_LOCAL if (ModuleSP module_sp = DynamicLoader::LoadModuleAtAddress( file, link_map_addr, base_addr, base_addr_is_offset)) return module_sp; @@ -613,6 +616,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadModuleAtAddress(const FileSpec &file, } void DynamicLoaderPOSIXDYLD::LoadAllCurrentModules() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_DYNAMICLOADER); // OHOS_LOCAL DYLDRendezvous::iterator I; DYLDRendezvous::iterator E; ModuleList module_list; diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp index 26e73a7aeaede4179b9077390724151f2f4454f5..f8b707cc23e55675021771a95ec12cc89644215b 100644 --- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -26,6 +26,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "llvm/Support/MathExtras.h" #include @@ -166,6 +167,7 @@ void JITLoaderGDB::DebuggerInitialize(Debugger &debugger) { } void JITLoaderGDB::DidAttach() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_JITLOADER); // OHOS_LOCAL Target &target = m_process->GetTarget(); ModuleList &module_list = target.GetImages(); SetJITBreakpoint(module_list); @@ -178,6 +180,7 @@ void JITLoaderGDB::DidLaunch() { } void JITLoaderGDB::ModulesDidLoad(ModuleList &module_list) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_JITLOADER); // OHOS_LOCAL if (!DidSetJITBreakpoint() && m_process->IsAlive()) SetJITBreakpoint(module_list); } diff --git a/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp b/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp index 9543f407dd6bb8fd3f1ac9f2a6e1d3ccefbd5e02..eef720eaf78bc0527e5170fda08403647d132c3c 100644 --- a/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp +++ b/lldb/source/Plugins/Platform/OHOS/HdcClient.cpp @@ -23,6 +23,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timeout.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #if defined(_WIN32) #include @@ -266,6 +267,7 @@ Status HdcClient::DeletePortForwarding(const uint16_t local_port, Status HdcClient::TransferFile(const char *direction, const FileSpec &src, const FileSpec &dst) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_HDC); // OHOS_LOCAL llvm::SmallVector cwd; std::error_code ec = llvm::sys::fs::current_path(cwd); if (ec) diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index fb0d39ea6f866c6464872ffe12ab49009f004f5e..8b056b2445d2be324d7107770ebb77e036473679 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -32,6 +32,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "llvm/ADT/ScopeExit.h" using namespace lldb; @@ -362,6 +363,7 @@ Status PlatformPOSIX::DisconnectRemote() { lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Status &error) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PLATFORM); // OHOS_LOCAL lldb::ProcessSP process_sp; Log *log = GetLog(LLDBLog::Platform); diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 2438661886291e80fd280f9ce71858723cbba69e..626d26ab6a07a30589e7fdad293595232c0f969e 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -29,6 +29,7 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UriParser.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "Plugins/Process/Utility/GDBRemoteSignals.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" @@ -491,6 +492,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach( Target *target, // Can be NULL, if NULL create a new target, else use // existing one Status &error) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL lldb::ProcessSP process_sp; if (IsRemote()) { if (IsConnected()) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp index e3a3cfc4f23ea8334792445116bd17fe7f759c2f..70142ea7f04313766bf91dc454e97ddd7c5890e2 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp @@ -12,6 +12,7 @@ #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/LLDBAssert.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "ProcessGDBRemoteLog.h" @@ -40,6 +41,7 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse( ContinueDelegate &delegate, const UnixSignals &signals, llvm::StringRef payload, std::chrono::seconds interrupt_timeout, StringExtractorGDBRemote &response) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Log *log = GetLog(GDBRLog::Process); response.Clear(); @@ -182,6 +184,7 @@ GDBRemoteCommunication::PacketResult GDBRemoteClientBase::SendPacketAndWaitForResponse( llvm::StringRef payload, StringExtractorGDBRemote &response, std::chrono::seconds interrupt_timeout) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Lock lock(*this, interrupt_timeout); if (!lock) { if (Log *log = GetLog(GDBRLog::Process)) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 755b8220c49eabcb81d19939d69ac03e2c42a4d9..12a8803eb299dd5d6279bda7b2721ea6e6ec5cc7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -32,6 +32,7 @@ #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Reproducer.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "llvm/ADT/SmallString.h" #include "llvm/Support/ScopedPrinter.h" @@ -114,6 +115,7 @@ size_t GDBRemoteCommunication::SendNack() { GDBRemoteCommunication::PacketResult GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL StreamString packet(0, 4, eByteOrderBig); packet.PutChar('$'); packet.Write(payload.data(), payload.size()); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 580cdde57d80f79723f44ac1a2a1d9402491ea45..63fbd33194c12e81035cd12ebb681ba06f85bffd 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -28,6 +28,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" @@ -1529,6 +1530,7 @@ Status GDBRemoteCommunicationClient::Detach(bool keep_stopped, Status GDBRemoteCommunicationClient::GetMemoryRegionInfo( lldb::addr_t addr, lldb_private::MemoryRegionInfo ®ion_info) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Status error; region_info.Clear(); @@ -2778,6 +2780,7 @@ bool GDBRemoteCommunicationClient::GetThreadStopInfo( uint8_t GDBRemoteCommunicationClient::SendGDBStoppointTypePacket( GDBStoppointType type, bool insert, addr_t addr, uint32_t length, std::chrono::seconds timeout) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Breakpoints); LLDB_LOGF(log, "GDBRemoteCommunicationClient::%s() %s at addr = 0x%" PRIx64, __FUNCTION__, insert ? "add" : "remove", addr); @@ -3435,6 +3438,7 @@ bool GDBRemoteCommunicationClient::AvoidGPackets(ProcessGDBRemote *process) { DataBufferSP GDBRemoteCommunicationClient::ReadRegister(lldb::tid_t tid, uint32_t reg) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL StreamString payload; payload.Printf("p%x", reg); StringExtractorGDBRemote response; diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp index 7ad4f4968eac9f2a6dfb53d3ed25ac0b8306ae09..71e064b27b66759151385c3b5b80424306b73606 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -15,6 +15,7 @@ #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Scalar.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" #include "ThreadGDBRemote.h" @@ -83,6 +84,7 @@ const RegisterSet *GDBRemoteRegisterContext::GetRegisterSet(size_t reg_set) { bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) { // Read the register + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL if (ReadRegisterBytes(reg_info)) { const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; if (m_reg_valid[reg] == false) diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 3e1a6fb6620a7cd1cccc629485edc24005cff85c..7423f1b93a3b4b13e57e9ef124b25389d5a4921f 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1111,6 +1111,7 @@ void ProcessGDBRemote::DidLaunch() { Status ProcessGDBRemote::DoAttachToProcessWithID( lldb::pid_t attach_pid, const ProcessAttachInfo &attach_info) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Log *log = GetLog(GDBRLog::Process); Status error; @@ -1204,6 +1205,7 @@ void ProcessGDBRemote::DidExit() { void ProcessGDBRemote::DidAttach(ArchSpec &process_arch) { // If you can figure out what the architecture is, fill it in here. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL process_arch.Clear(); DidLaunchOrAttach(process_arch); } @@ -2499,6 +2501,7 @@ void ProcessGDBRemote::WillPublicStop() { // runtime queue information (iOS and MacOSX only), and more. Expediting // memory will help stack backtracing be much faster. Expediting registers // will make sure we don't have to read the thread registers for GPRs. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL m_jthreadsinfo_sp = m_gdb_comm.GetThreadsInfo(); if (m_jthreadsinfo_sp) { @@ -2520,6 +2523,7 @@ void ProcessGDBRemote::WillPublicStop() { // Process Memory size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size, Status &error) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL GetMaxMemorySize(); bool binary_memory_read = m_gdb_comm.GetxPacketSupported(); // M and m packets take 2 bytes for 1 byte of memory @@ -2923,6 +2927,7 @@ size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len, } Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Status error; assert(bp_site != nullptr); @@ -3423,6 +3428,7 @@ void ProcessGDBRemote::DebuggerInitialize(Debugger &debugger) { } bool ProcessGDBRemote::StartAsyncThread() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL Log *log = GetLog(GDBRLog::Process); LLDB_LOGF(log, "ProcessGDBRemote::%s ()", __FUNCTION__); diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp index 3d23c074c1be3a5520a0036d8c2f95f33384c8bc..15330f20dfc8323e4b5e09e5187c0d01d2c28d5e 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -21,6 +21,7 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StringExtractorGDBRemote.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" @@ -234,6 +235,7 @@ StructuredData::ObjectSP ThreadGDBRemote::FetchThreadExtendedInfo() { } void ThreadGDBRemote::WillResume(StateType resume_state) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_GDBREMOTE); // OHOS_LOCAL int signo = GetResumeSignal(); const lldb::user_id_t tid = GetProtocolID(); Log *log = GetLog(GDBRLog::Thread); diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp index 6eeabe0ff5e4d01102f1621a813737cb89653dda..85270d4600e5ed0427b8743f7a65e17b9d076e0d 100644 --- a/lldb/source/Symbol/Block.cpp +++ b/lldb/source/Symbol/Block.cpp @@ -15,6 +15,7 @@ #include "lldb/Symbol/VariableList.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include @@ -414,6 +415,7 @@ Block::AppendBlockVariables(bool can_create, bool get_child_block_variables, bool stop_if_child_block_is_inlined_function, const std::function &filter, VariableList *variable_list) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_SYMBOLS); // OHOS_LOCAL uint32_t num_variables_added = 0; VariableList *block_var_list = GetBlockVariableList(can_create).get(); if (block_var_list) { diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp index 1b2801cd03683589ebfd50a5476f01669b30947d..9dff1ff72b9c0571f9b29a142029abbb7a709a5e 100644 --- a/lldb/source/Symbol/LineEntry.cpp +++ b/lldb/source/Symbol/LineEntry.cpp @@ -10,6 +10,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb_private; @@ -193,6 +194,7 @@ AddressRange LineEntry::GetSameLineContiguousAddressRange( bool include_inlined_functions) const { // Add each LineEntry's range to complete_line_range until we find a // different file / line number. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_SYMBOLS); // OHOS_LOCAL AddressRange complete_line_range = range; auto symbol_context_scope = lldb::eSymbolContextLineEntry; Declaration start_call_site(original_file, line); diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp index a07a72f31922e4123abf96876993e7054852c2ad..d3e46def2e54bd90ac6690f7e251ffbf65124da1 100644 --- a/lldb/source/Target/Memory.cpp +++ b/lldb/source/Target/Memory.cpp @@ -13,6 +13,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/RangeMap.h" #include "lldb/Utility/State.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include #include @@ -125,6 +126,7 @@ bool MemoryCache::RemoveInvalidRange(lldb::addr_t base_addr, size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len, Status &error) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL size_t bytes_left = dst_len; // Check the L1 cache for a range that contain the entire memory read. If we diff --git a/lldb/source/Target/ModuleCache.cpp b/lldb/source/Target/ModuleCache.cpp index a3b219b934a9088cec8a82336882d939165a2e8b..579ca1cbf68333959b3e729c5dededc223aa70c9 100644 --- a/lldb/source/Target/ModuleCache.cpp +++ b/lldb/source/Target/ModuleCache.cpp @@ -15,6 +15,7 @@ #include "lldb/Host/LockFile.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "llvm/Support/FileSystem.h" #include "llvm/Support/FileUtilities.h" @@ -306,6 +307,7 @@ Status ModuleCache::GetAndPut(const FileSpec &root_dir_spec, const SymfileDownloader &symfile_downloader, lldb::ModuleSP &cached_module_sp, bool *did_create_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_MODULES); // OHOS_LOCAL const auto module_spec_dir = GetModuleDirectory(root_dir_spec, module_spec.GetUUID()); auto error = MakeDirectory(module_spec_dir); diff --git a/lldb/source/Target/OperatingSystem.cpp b/lldb/source/Target/OperatingSystem.cpp index 75762c05151d14aaa7312cdb927b046772c389e9..172d06e92d21bc9c4ec27e13e01363719b1d845f 100644 --- a/lldb/source/Target/OperatingSystem.cpp +++ b/lldb/source/Target/OperatingSystem.cpp @@ -9,12 +9,14 @@ #include "lldb/Target/OperatingSystem.h" #include "lldb/Core/PluginManager.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; OperatingSystem *OperatingSystem::FindPlugin(Process *process, const char *plugin_name) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL OperatingSystemCreateInstance create_callback = nullptr; if (plugin_name) { create_callback = diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index b2f1318ca91df1dd9cd237c6eadf4d8bee19f355..e1a60fba29b5401daad34f5984ea55406c3dcd14 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -359,6 +359,7 @@ ProcessSP Process::FindPlugin(lldb::TargetSP target_sp, ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL static uint32_t g_process_unique_id = 0; ProcessSP process_sp; @@ -648,6 +649,7 @@ StateType Process::WaitForProcessToStop(const Timeout &timeout, EventSP *event_sp_ptr, bool wait_always, ListenerSP hijack_listener_sp, Stream *stream, bool use_run_lock) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL // We can't just wait for a "stopped" event, because the stopped event may // have restarted the target. We have to actually check each event, and in // the case of a stopped event check the restarted flag on the event. @@ -944,6 +946,7 @@ bool Process::HandleProcessStateChangedEvent(const EventSP &event_sp, } bool Process::HijackProcessEvents(ListenerSP listener_sp) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL if (listener_sp) { return HijackBroadcaster(listener_sp, eBroadcastBitStateChanged | eBroadcastBitInterrupt); @@ -1337,6 +1340,7 @@ void Process::SetPublicState(StateType new_state, bool restarted) { } Status Process::Resume() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL Log *log(GetLog(LLDBLog::State | LLDBLog::Process)); LLDB_LOGF(log, "Process::Resume -- locking run lock"); if (!m_public_run_lock.TrySetRunning()) { @@ -2034,6 +2038,7 @@ size_t Process::ReadCStringFromMemory(addr_t addr, char *dst, size_t Process::ReadMemoryFromInferior(addr_t addr, void *buf, size_t size, Status &error) { LLDB_SCOPED_TIMER(); + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL if (ABISP abi_sp = GetABI()) addr = abi_sp->FixAnyAddress(addr); @@ -2354,6 +2359,7 @@ Status Process::DeallocateMemory(addr_t ptr) { ModuleSP Process::ReadModuleFromMemory(const FileSpec &file_spec, lldb::addr_t header_addr, size_t size_to_read) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Host); if (log) { LLDB_LOGF(log, @@ -2431,6 +2437,7 @@ Process::WaitForProcessStopPrivate(EventSP &event_sp, } void Process::LoadOperatingSystemPlugin(bool flush) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL if (flush) m_thread_list.Clear(); m_os_up.reset(OperatingSystem::FindPlugin(this, nullptr)); @@ -2757,6 +2764,8 @@ ListenerSP ProcessAttachInfo::GetListenerForProcess(Debugger &debugger) { } Status Process::Attach(ProcessAttachInfo &attach_info) { + LLDB_PERFORMANCE_LOG("Attach start"); // OHOS_LOCAL + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL m_abi_sp.reset(); m_process_input_reader.reset(); m_dyld_up.reset(); @@ -2881,6 +2890,7 @@ void Process::CompleteAttach() { Log *log(GetLog(LLDBLog::Process | LLDBLog::Target)); LLDB_LOGF(log, "Process::%s()", __FUNCTION__); + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL // Let the process subclass figure out at much as it can about the process // before we go looking for a dynamic loader plug-in. ArchSpec process_arch; @@ -3005,9 +3015,11 @@ void Process::CompleteAttach() { : ""); } } + LLDB_PERFORMANCE_LOG("CompleteAttach end"); // OHOS_LOCAL } Status Process::ConnectRemote(llvm::StringRef remote_url) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL m_abi_sp.reset(); m_process_input_reader.reset(); @@ -3040,6 +3052,7 @@ Status Process::ConnectRemote(llvm::StringRef remote_url) { } Status Process::PrivateResume() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL Log *log(GetLog(LLDBLog::Process | LLDBLog::Step)); LLDB_LOGF(log, "Process::PrivateResume() m_stop_id = %u, public state: %s " @@ -3348,6 +3361,7 @@ uint32_t Process::GetAddressByteSize() const { } bool Process::ShouldBroadcastEvent(Event *event_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL const StateType state = Process::ProcessEventData::GetStateFromEvent(event_ptr); bool return_value = true; @@ -3630,6 +3644,7 @@ void Process::SendAsyncInterrupt() { } void Process::HandlePrivateEvent(EventSP &event_sp) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Process); m_resume_requested = false; @@ -4008,6 +4023,7 @@ bool Process::ProcessEventData::ShouldStop(Event *event_ptr, } void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL ProcessSP process_sp(m_process_wp.lock()); if (!process_sp) @@ -5687,6 +5703,7 @@ addr_t Process::ResolveIndirectFunction(const Address *address, Status &error) { } void Process::ModulesDidLoad(ModuleList &module_list) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL // Inform the system runtime of the modified modules. SystemRuntime *sys_runtime = GetSystemRuntime(); if (sys_runtime) @@ -5853,6 +5870,7 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr, Status Process::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL if (const lldb::ABISP &abi = GetABI()) load_addr = abi->FixAnyAddress(load_addr); return DoGetMemoryRegionInfo(load_addr, range_info); diff --git a/lldb/source/Target/RegisterContext.cpp b/lldb/source/Target/RegisterContext.cpp index 7364660650e8fd2b41c8f5f0a0f229e686bbdcac..f7bf269e0e24f25d51969cca18c15fcd369ea7c0 100644 --- a/lldb/source/Target/RegisterContext.cpp +++ b/lldb/source/Target/RegisterContext.cpp @@ -19,6 +19,7 @@ #include "lldb/Utility/Endian.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -298,6 +299,7 @@ bool RegisterContext::HardwareSingleStep(bool enable) { return false; } Status RegisterContext::ReadRegisterValueFromMemory( const RegisterInfo *reg_info, lldb::addr_t src_addr, uint32_t src_len, RegisterValue ®_value) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL Status error; if (reg_info == nullptr) { error.SetErrorString("invalid register info argument."); diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp index 2da40ba2bf61e04ca015d0522bd51d363a21cdb4..0b68fc80a893977ba2f4dbbb7960bcb57998a1b7 100644 --- a/lldb/source/Target/RegisterContextUnwind.cpp +++ b/lldb/source/Target/RegisterContextUnwind.cpp @@ -36,6 +36,7 @@ #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/VASPrintf.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "lldb/lldb-private.h" #include @@ -64,6 +65,7 @@ RegisterContextUnwind::RegisterContextUnwind(Thread &thread, m_behaves_like_zeroth_frame(false), m_sym_ctx(sym_ctx), m_sym_ctx_valid(false), m_frame_number(frame_number), m_registers(), m_parent_unwind(unwind_lldb) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_UNWIND); // OHOS_LOCAL m_sym_ctx.Clear(false); m_sym_ctx_valid = false; diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 4fb5ba0b735e6baf021d99f3f8554777eee09a12..2b2db4c9beb2b1b81da68479661e7e78f8c423aa 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -32,6 +32,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "lldb/lldb-enumerations.h" @@ -297,6 +298,7 @@ Block *StackFrame::GetFrameBlock() { // one will ever have to look things up manually. const SymbolContext & StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL std::lock_guard guard(m_mutex); // Copy our internal symbol context into "sc". if ((m_flags.Get() & resolve_scope) != resolve_scope) { @@ -421,6 +423,7 @@ StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) { } VariableList *StackFrame::GetVariableList(bool get_file_globals) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL std::lock_guard guard(m_mutex); if (m_flags.IsClear(RESOLVED_VARIABLES)) { m_flags.Set(RESOLVED_VARIABLES); diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index 14663e4b7c7b3039cf6d05699799533c7ab894b3..98d64122a1566b02e6e180928b609dff0d5ad425 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -23,6 +23,7 @@ #include "lldb/Target/Unwind.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "llvm/ADT/SmallPtrSet.h" #include @@ -436,6 +437,7 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) { void StackFrameList::GetFramesUpTo(uint32_t end_idx) { // Do not fetch frames for an invalid thread. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (!m_thread.IsValid()) return; @@ -646,6 +648,7 @@ void StackFrameList::Dump(Stream *s) { } StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL StackFrameSP frame_sp; std::lock_guard guard(m_mutex); uint32_t original_idx = idx; @@ -848,6 +851,7 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t first_frame, uint32_t num_frames_with_source, bool show_unique, const char *selected_frame_marker) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL size_t num_frames_displayed = 0; if (num_frames == 0) diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index c0903ab0e717463764a8a0042e4392c2f4ddbfdf..3d8cf52358a8f5f0ab008951b694a2440ad70a53 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -24,6 +24,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -145,6 +146,7 @@ public: StopReason GetStopReason() const override { return eStopReasonBreakpoint; } bool ShouldStopSynchronous(Event *event_ptr) override { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL ThreadSP thread_sp(m_thread_wp.lock()); if (thread_sp) { if (!m_should_stop_is_valid) { @@ -699,6 +701,7 @@ protected: // StopInfoWatchpoint::ShouldStop() and // Event::DoOnRemoval()->Process::ProcessEventData::DoOnRemoval()-> // StopInfoWatchpoint::PerformAction(). + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_PROCESS); // OHOS_LOCAL if (m_should_stop_is_valid) return m_should_stop; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index f16fc6b5da85f62a48fdecca75f3949303a69f78..c6609b39199af74c5de299315b62e244eac1ce2e 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -206,6 +206,7 @@ const lldb::ProcessSP &Target::CreateProcess(ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file, bool can_connect) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL if (!listener_sp) listener_sp = GetDebugger().GetListener(); DeleteCurrentProcess(); @@ -354,6 +355,7 @@ BreakpointSP Target::CreateBreakpoint(const FileSpecList *containingModules, LazyBool skip_prologue, bool internal, bool hardware, LazyBool move_to_nearest_code) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL FileSpec remapped_file; if (!GetSourcePathMap().ReverseRemapPath(file, remapped_file)) remapped_file = file; @@ -405,6 +407,7 @@ BreakpointSP Target::CreateBreakpoint(const FileSpecList *containingModules, BreakpointSP Target::CreateBreakpoint(lldb::addr_t addr, bool internal, bool hardware) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL Address so_addr; // Check for any reason we want to move this breakpoint to other address. @@ -425,6 +428,7 @@ BreakpointSP Target::CreateBreakpoint(lldb::addr_t addr, bool internal, BreakpointSP Target::CreateBreakpoint(const Address &addr, bool internal, bool hardware) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL SearchFilterSP filter_sp( new SearchFilterForUnconstrainedSearches(shared_from_this())); BreakpointResolverSP resolver_sp( @@ -436,6 +440,7 @@ lldb::BreakpointSP Target::CreateAddressInModuleBreakpoint(lldb::addr_t file_addr, bool internal, const FileSpec *file_spec, bool request_hardware) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL SearchFilterSP filter_sp( new SearchFilterForUnconstrainedSearches(shared_from_this())); BreakpointResolverSP resolver_sp(new BreakpointResolverAddress( @@ -659,6 +664,7 @@ BreakpointSP Target::CreateBreakpoint(SearchFilterSP &filter_sp, } void Target::AddBreakpoint(lldb::BreakpointSP bp_sp, bool internal) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL if (!bp_sp) return; if (internal) @@ -946,6 +952,7 @@ void Target::EnableAllowedBreakpoints() { } bool Target::RemoveBreakpointByID(break_id_t break_id) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_BREAKPOINTS); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Breakpoints); LLDB_LOGF(log, "Target::%s (break_id = %i, internal = %s)\n", __FUNCTION__, break_id, LLDB_BREAK_ID_IS_INTERNAL(break_id) ? "yes" : "no"); @@ -1360,6 +1367,7 @@ bool Target::IgnoreWatchpointByID(lldb::watch_id_t watch_id, } ModuleSP Target::GetExecutableModule() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL // search for the first executable in the module list for (size_t i = 0; i < m_images.GetSize(); ++i) { ModuleSP module_sp = m_images.GetModuleAtIndex(i); @@ -1626,6 +1634,7 @@ void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) { } void Target::ModulesDidLoad(ModuleList &module_list) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL const size_t num_images = module_list.GetSize(); if (m_valid && num_images) { for (size_t idx = 0; idx < num_images; ++idx) { @@ -3201,6 +3210,7 @@ llvm::Expected Target::GetTraceOrCreate() { } Status Target::Attach(ProcessAttachInfo &attach_info, Stream *stream) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL m_stats.SetLaunchOrAttachTime(); auto state = eStateInvalid; auto process_sp = GetProcessSP(); @@ -3421,6 +3431,7 @@ bool Target::ResetSignalFromDummy(UnixSignalsSP signals_sp, void Target::UpdateSignalsFromDummy(UnixSignalsSP signals_sp, StreamSP warning_stream_sp) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_TARGET); // OHOS_LOCAL if (!signals_sp) return; diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index f63b57fd4e62818a4a684d46e5f6de4c5e0eaa96..4ff923d74eb7bccf327514c48a7b413033ec1f91 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -50,6 +50,7 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include "lldb/lldb-enumerations.h" #include @@ -663,6 +664,7 @@ void Thread::SetupForResume() { bool Thread::ShouldResume(StateType resume_state) { // At this point clear the completed plan stack. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL GetPlans().WillResume(); m_override_should_notify = eLazyBoolCalculate; @@ -1015,6 +1017,7 @@ Vote Thread::ShouldReportStop(Event *event_ptr) { } Vote Thread::ShouldReportRun(Event *event_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL StateType thread_state = GetResumeState(); if (thread_state == eStateSuspended || thread_state == eStateInvalid) { @@ -1148,6 +1151,7 @@ ThreadPlan *Thread::GetPreviousPlan(ThreadPlan *current_plan) const{ Status Thread::QueueThreadPlan(ThreadPlanSP &thread_plan_sp, bool abort_other_plans) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL Status status; StreamString s; if (!thread_plan_sp->ValidatePlan(&s)) { @@ -1247,6 +1251,7 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOverRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_withoug_debug_info) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL ThreadPlanSP thread_plan_sp; thread_plan_sp = std::make_shared( *this, range, addr_context, stop_other_threads, @@ -1262,6 +1267,7 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOverRange( bool abort_other_plans, const LineEntry &line_entry, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_withoug_debug_info) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL const bool include_inlined_functions = true; auto address_range = line_entry.GetSameLineContiguousAddressRange(include_inlined_functions); @@ -1305,6 +1311,7 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOut( bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL ThreadPlanSP thread_plan_sp(new ThreadPlanStepOut( *this, addr_context, first_insn, stop_other_threads, report_stop_vote, report_run_vote, frame_idx, step_out_avoids_code_without_debug_info)); @@ -1593,6 +1600,7 @@ Status Thread::JumpToLine(const FileSpec &file, uint32_t line, void Thread::DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL ExecutionContext exe_ctx(shared_from_this()); Process *process = exe_ctx.GetProcessPtr(); if (process == nullptr) @@ -1708,6 +1716,7 @@ size_t Thread::GetStatus(Stream &strm, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format, bool only_stacks) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL if (!only_stacks) { ExecutionContext exe_ctx(shared_from_this()); Target *target = exe_ctx.GetTargetPtr(); diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp index 7359bfcd3cfc290861fc6a4bd9c9e04616efa6b0..2bbc8debe5a6b7c33527e9d702525ff262ba6079 100644 --- a/lldb/source/Target/ThreadList.cpp +++ b/lldb/source/Target/ThreadList.cpp @@ -19,6 +19,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -226,6 +227,7 @@ ThreadSP ThreadList::FindThreadByIndexID(uint32_t index_id, bool can_update) { bool ThreadList::ShouldStop(Event *event_ptr) { // Running events should never stop, obviously... + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Step); // The ShouldStop method of the threads can do a whole lot of work, figuring @@ -487,6 +489,7 @@ bool ThreadList::WillResume() { // do this for threads that are running, user suspended threads stay where // they are. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL std::lock_guard guard(GetMutex()); m_process->UpdateThreadListIfNeeded(); @@ -618,6 +621,7 @@ bool ThreadList::WillResume() { } void ThreadList::DidResume() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL std::lock_guard guard(GetMutex()); collection::iterator pos, end = m_threads.end(); for (pos = m_threads.begin(); pos != end; ++pos) { @@ -659,6 +663,7 @@ ThreadSP ThreadList::GetSelectedThread() { } bool ThreadList::SetSelectedThreadByID(lldb::tid_t tid, bool notify) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL std::lock_guard guard(GetMutex()); ThreadSP selected_thread_sp(FindThreadByID(tid)); if (selected_thread_sp) { diff --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp index 9913ecb591fa718574182bc5d644c6228e987f2b..5a7ff8ba1e50c0173cfffde3383b023e20604940 100644 --- a/lldb/source/Target/ThreadPlan.cpp +++ b/lldb/source/Target/ThreadPlan.cpp @@ -15,6 +15,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -92,6 +93,7 @@ Vote ThreadPlan::ShouldReportStop(Event *event_ptr) { } Vote ThreadPlan::ShouldReportRun(Event *event_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_THREAD); // OHOS_LOCAL if (m_report_run_vote == eVoteNoOpinion) { ThreadPlan *prev_plan = GetPreviousPlan(); if (prev_plan) @@ -114,6 +116,7 @@ void ThreadPlan::SetStopOthers(bool new_value) { } bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL m_cached_plan_explains_stop = eLazyBoolCalculate; if (current_plan) { diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp index 7bf1d2a8b579c1b6b99846f9ac4e32aa26d84bba..58a7f6a7f32291e6d6db55ab2bcb5162376d6fd0 100644 --- a/lldb/source/Target/ThreadPlanStepOut.cpp +++ b/lldb/source/Target/ThreadPlanStepOut.cpp @@ -23,6 +23,7 @@ #include "lldb/Target/ThreadPlanStepThrough.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL #include @@ -269,6 +270,7 @@ bool ThreadPlanStepOut::ValidatePlan(Stream *error) { bool ThreadPlanStepOut::DoPlanExplainsStop(Event *event_ptr) { // If the step out plan is done, then we just need to step through the // inlined frame. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (m_step_out_to_inline_plan_sp) { return m_step_out_to_inline_plan_sp->MischiefManaged(); } else if (m_step_through_inline_plan_sp) { @@ -335,6 +337,7 @@ bool ThreadPlanStepOut::DoPlanExplainsStop(Event *event_ptr) { } bool ThreadPlanStepOut::ShouldStop(Event *event_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (IsPlanComplete()) return true; @@ -406,6 +409,7 @@ bool ThreadPlanStepOut::DoWillResume(StateType resume_state, } bool ThreadPlanStepOut::WillStop() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (m_return_bp_id != LLDB_INVALID_BREAK_ID) { Breakpoint *return_bp = GetTarget().GetBreakpointByID(m_return_bp_id).get(); if (return_bp != nullptr) @@ -416,6 +420,7 @@ bool ThreadPlanStepOut::WillStop() { } bool ThreadPlanStepOut::MischiefManaged() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (IsPlanComplete()) { // Did I reach my breakpoint? If so I'm done. // @@ -433,6 +438,7 @@ bool ThreadPlanStepOut::MischiefManaged() { } ThreadPlan::MischiefManaged(); + LLDB_PERFORMANCE_LOG("Completed step out."); // OHOS_LOCAL return true; } else { return false; diff --git a/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp b/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp index edf86c7b8e96cc179f655ff56dbe75410093fd09..b719f5a44b64cb62a15eb06f1ec803b46f936a7f 100644 --- a/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp +++ b/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp @@ -13,6 +13,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -169,6 +170,7 @@ bool ThreadPlanStepOverBreakpoint::WillStop() { void ThreadPlanStepOverBreakpoint::DidPop() { ReenableBreakpointSite(); } bool ThreadPlanStepOverBreakpoint::MischiefManaged() { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL lldb::addr_t pc_addr = GetThread().GetRegisterContext()->GetPC(); if (pc_addr == m_breakpoint_addr || m_handling_signal) { diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp index b1cb070e0a3d0c272359fd916d362b8db1422181..fb18ea10db330e369058d916a473d45a7006ce9f 100644 --- a/lldb/source/Target/ThreadPlanStepOverRange.cpp +++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp @@ -20,6 +20,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb_private; using namespace lldb; @@ -125,6 +126,7 @@ bool ThreadPlanStepOverRange::IsEquivalentContext( } bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Step); Thread &thread = GetThread(); @@ -342,6 +344,7 @@ bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event *event_ptr) { // breakpoint. Note, unlike the step in range plan, we don't mark ourselves // complete if we hit an unexplained breakpoint/crash. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL Log *log = GetLog(LLDBLog::Step); StopInfoSP stop_info_sp = GetPrivateStopInfo(); bool return_value; @@ -367,6 +370,7 @@ bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event *event_ptr) { bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state, bool current_plan) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (resume_state != eStateSuspended && m_first_resume) { m_first_resume = false; if (resume_state == eStateStepping && current_plan) { diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp index d08805460ee1f851eecd6bfb580f11513655f5e3..f4aae3d0e350c8bbe2cd8503b9e20499dc78203e 100644 --- a/lldb/source/Target/ThreadPlanStepRange.cpp +++ b/lldb/source/Target/ThreadPlanStepRange.cpp @@ -22,6 +22,7 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -447,6 +448,7 @@ bool ThreadPlanStepRange::MischiefManaged() { // instance, when stepping over inlined code that is in the middle of the // current line. + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_STEP); // OHOS_LOCAL if (!m_no_more_plans) return false; @@ -465,6 +467,7 @@ bool ThreadPlanStepRange::MischiefManaged() { LLDB_LOGF(log, "Completed step through range plan."); ClearNextBranchBreakpoint(); ThreadPlan::MischiefManaged(); + LLDB_PERFORMANCE_LOG("Completed step through range."); // OHOS_LOCAL return true; } else { return false; diff --git a/lldb/source/Target/UnwindLLDB.cpp b/lldb/source/Target/UnwindLLDB.cpp index 1d8bf2f88ae67ba5be468204d3ba27bfc0fd09ad..cd8157efeee30909ad5ce34a8fe5b610503175b1 100644 --- a/lldb/source/Target/UnwindLLDB.cpp +++ b/lldb/source/Target/UnwindLLDB.cpp @@ -19,6 +19,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Timer.h" // OHOS_LOCAL using namespace lldb; using namespace lldb_private; @@ -391,6 +392,7 @@ bool UnwindLLDB::AddOneMoreFrame(ABI *abi) { bool UnwindLLDB::DoGetFrameInfoAtIndex(uint32_t idx, addr_t &cfa, addr_t &pc, bool &behaves_like_zeroth_frame) { + LLDB_MODULE_TIMER(LLDBPerformanceTagName::TAG_UNWIND); // OHOS_LOCAL if (m_frames.size() == 0) { if (!AddFirstFrame()) return false; diff --git a/lldb/source/Utility/LLDBLog.cpp b/lldb/source/Utility/LLDBLog.cpp index 71c534a9cfc1ba1205c19217515270d524737722..c4d671c7143ded30b781f9f42ac44c1f60237c1a 100644 --- a/lldb/source/Utility/LLDBLog.cpp +++ b/lldb/source/Utility/LLDBLog.cpp @@ -63,6 +63,7 @@ static constexpr Log::Category g_categories[] = { {{"on-demand"}, {"log symbol on-demand related activities"}, LLDBLog::OnDemand}, + {{"performance"}, {"log performance monitoring point"}, LLDBLog::Performance}, // OHOS_LOCAL }; static Log::Channel g_log_channel(g_categories, @@ -71,7 +72,8 @@ static Log::Channel g_log_channel(g_categories, LLDBLog::Breakpoints | LLDBLog::Watchpoints | LLDBLog::Step | LLDBLog::State | LLDBLog::Symbols | - LLDBLog::Target | LLDBLog::Commands); + LLDBLog::Target | LLDBLog::Commands | + LLDBLog::Performance); // OHOS_LOCAL template <> Log::Channel &lldb_private::LogChannelFor() { return g_log_channel; diff --git a/llvm-build/build.py b/llvm-build/build.py index 3f84c5de03dfcc1efb3618f7a4ace14a5d6a9edc..2cc5c48cb06eefa966563cda9d7c793ff62bd0c7 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -61,6 +61,7 @@ class BuildConfig(): self.need_lldb_tools = self.need_lldb_server or self.build_lldb_static self.build_libxml2 = args.build_libxml2 self.lldb_timeout = args.lldb_timeout + self.enable_monitoring = args.enable_monitoring self.discover_paths() @@ -212,6 +213,12 @@ class BuildConfig(): action='store_true', default=False, help='Automatically exit when timeout (currently effective for lldb-server)') + + parser.add_argument( + '--enable-monitoring', + action='store_true', + default=False, + help='Enable lldb performance monitoring') def parse_args(self): @@ -671,6 +678,9 @@ class LlvmCore(BuildUtils): if self.build_config.build_libxml2: llvm_defines['LLDB_ENABLE_LIBXML2'] = 'ON' llvm_defines['LIBXML2_INCLUDE_DIR'] = os.path.join(self.get_prebuilts_dir('libxml2'), self.use_platform(), 'include', 'libxml2') + + if self.build_config.enable_monitoring: + llvm_defines['LLDB_ENABLE_PERFORMANCE'] = 'ON' def llvm_compile(self, build_name, @@ -790,6 +800,9 @@ class LlvmCore(BuildUtils): windows_defines['LIBXML2_INCLUDE_DIR'] = os.path.join(self.get_prebuilts_dir('libxml2'), 'windows-x86_64', 'include', 'libxml2') windows_defines['LIBXML2_LIBRARY'] = os.path.join(self.get_prebuilts_dir('libxml2'), 'windows-x86_64', 'lib', 'libxml2.dll.a') + if self.build_config.enable_monitoring: + windows_defines['LLDB_ENABLE_PERFORMANCE'] = 'ON' + def llvm_compile_windows_flags(self, windows_defines, windowstool_path, @@ -1389,6 +1402,9 @@ class LlvmLibs(BuildUtils): lldb_defines['LLVM_TARGET_ARCH'] = arch lldb_defines['LLVM_TARGETS_TO_BUILD'] = self.build_config.TARGETS + if self.build_config.enable_monitoring: + lldb_defines['LLDB_ENABLE_PERFORMANCE'] = 'ON' + lldb_target = ['lldb-server'] if self.build_config.need_lldb_server else [] if self.build_config.build_lldb_static and llvm_triple in ['aarch64-linux-ohos', 'arm-linux-ohos']: