[Lldb-commits] [PATCH] D29266: Synchronize PlatformNetBSD with Linux
krytarowski updated this revision to Diff 87102. krytarowski added a comment. Sync this patch with SVN 294071. It is to be used at least for a reference in further code sharing. Repository: rL LLVM https://reviews.llvm.org/D29266 Files: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp source/Plugins/Platform/NetBSD/PlatformNetBSD.h Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.h === --- source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -14,96 +14,59 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Target/Platform.h" +#include "Plugins/Platform/POSIX/PlatformPOSIX.h" namespace lldb_private { namespace platform_netbsd { -class PlatformNetBSD : public Platform { +class PlatformNetBSD : public PlatformPOSIX { public: PlatformNetBSD(bool is_host); - ~PlatformNetBSD() override = default; + ~PlatformNetBSD() override; - // - // Class functions - // - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static void DebuggerInitialize(Debugger &debugger); static void Initialize(); static void Terminate(); - static ConstString GetPluginNameStatic(bool is_host); - - static const char *GetDescriptionStatic(bool is_host); - // // lldb_private::PluginInterface functions // - ConstString GetPluginName() override { return GetPluginNameStatic(IsHost()); } + static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); - uint32_t GetPluginVersion() override { return 1; } + static ConstString GetPluginNameStatic(bool is_host); - const char *GetDescription() override { -return GetDescriptionStatic(IsHost()); - } + static const char *GetPluginDescriptionStatic(bool is_host); + + ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override { return 1; } // // lldb_private::Platform functions // - bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, - ModuleSpec &module_spec) override; - - Error RunShellCommand(const char *command, const FileSpec &working_dir, -int *status_ptr, int *signo_ptr, -std::string *command_output, -uint32_t timeout_sec) override; - - bool GetRemoteOSVersion() override; - - bool GetRemoteOSBuildString(std::string &s) override; - - bool GetRemoteOSKernelDescription(std::string &s) override; - - // Remote Platform subclasses need to override this function - ArchSpec GetRemoteSystemArchitecture() override; - - bool IsConnected() const override; - - Error ConnectRemote(Args &args) override; - - Error DisconnectRemote() override; - - const char *GetHostname() override; - - const char *GetUserName(uint32_t uid) override; - - const char *GetGroupName(uint32_t gid) override; - - Error LaunchProcess(ProcessLaunchInfo &launch_info) override; + const char *GetDescription() override { +return GetPluginDescriptionStatic(IsHost()); + } - lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, - Target *target, Error &error) override; + void GetStatus(Stream &strm) override; - // NetBSD processes can not be launched by spawning and attaching. - bool CanDebugProcess() override { return false; } + bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; - Error GetSharedModule(const ModuleSpec &module_spec, Process *process, -lldb::ModuleSP &module_sp, -const FileSpecList *module_search_paths_ptr, -lldb::ModuleSP *old_module_sp_ptr, -bool *did_create_ptr) override; + int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override; - bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; + bool CanDebugProcess() override; - void GetStatus(Stream &strm) override; + lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, + Debugger &debugger, Target *target, + Error &error) override; void CalculateTrapHandlerSymbolNames() override; -protected: - lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a - // remote netbsd OS + uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, + unsigned flags) override; private: DISALLOW_COPY_AND_ASSIGN(Pla
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski updated this revision to Diff 87109. krytarowski added a comment. Revamp patch after recent changes in LLVM. Repository: rL LLVM https://reviews.llvm.org/D29288 Files: include/lldb/Core/Debugger.h source/Commands/CommandObjectPlatform.cpp source/Core/Debugger.cpp source/Core/ModuleList.cpp source/Host/common/Editline.cpp source/Host/common/HostInfoBase.cpp source/Host/linux/HostInfoLinux.cpp source/Host/windows/HostInfoWindows.cpp source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/Go/GoLanguage.cpp source/Plugins/Language/Java/JavaLanguage.cpp source/Plugins/Language/ObjC/ObjCLanguage.cpp source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp source/Plugins/Process/Linux/NativeProcessLinux.cpp source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp source/Plugins/Process/Windows/Common/ProcessWindows.cpp source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp source/Plugins/Process/elf-core/ProcessElfCore.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp source/Plugins/Process/mach-core/ProcessMachCore.cpp source/Plugins/Process/minidump/ProcessMinidump.cpp source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTContext.cpp source/Symbol/GoASTContext.cpp source/Target/Language.cpp source/Utility/ConstString.cpp tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp Index: tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp === --- tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp +++ tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp @@ -46,10 +46,10 @@ s_os_activity_stream_set_event_handler; bool LookupSPICalls() { - static std::once_flag s_once_flag; + LLVM_DEFINE_ONCE_FLAG(s_once_flag); static bool s_has_spi; - std::call_once(s_once_flag, [] { + llvm::call_once(s_once_flag, [] { dlopen ("/System/Library/PrivateFrameworks/LoggingSupport.framework/LoggingSupport", RTLD_NOW); s_os_activity_stream_for_pid = (os_activity_stream_for_pid_t)dlsym( RTLD_DEFAULT, "os_activity_stream_for_pid"); Index: source/Utility/ConstString.cpp === --- source/Utility/ConstString.cpp +++ source/Utility/ConstString.cpp @@ -20,6 +20,7 @@ #include "llvm/Support/RWMutex.h" // Project includes +#include "llvm/Support/Threading.h" #include "lldb/Utility/Stream.h" using namespace lldb_private; @@ -191,10 +192,10 @@ // touch ConstStrings is difficult. So we leak the pool instead. //-- static Pool &StringPool() { - static std::once_flag g_pool_initialization_flag; + LLVM_DEFINE_ONCE_FLAG(g_pool_initialization_flag); static Pool *g_string_pool = nullptr; - std::call_once(g_pool_initialization_flag, + llvm::call_once(g_pool_initialization_flag, []() { g_string_pool = new Pool(); }); return *g_string_pool; Index: source/Target/Language.cpp === --- source/Target/Language.cpp +++ source/Target/Language.cpp @@ -20,6 +20,8 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/Stream.h" +#include "llvm/Support/Threading.h" + using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; @@ -29,20 +31,20 @@ static LanguagesMap &GetLanguagesMap() { static LanguagesMap *g_map = nullptr; - static std::once_flag g_initialize; + LLVM_DEFINE_ONCE_FLAG(g_initialize); - std::call_once(g_initialize, [] { + llvm::call_once(g_initialize, [] { g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global // destructor chain }); return *g_map; } static std::mutex &GetLanguagesMutex() { static std::mutex *g_mutex = nullptr; - static std::once_flag g_initialize; + LLVM_DEFINE_ONCE_FLAG(g_initialize); - std::call_once(g_initialize, [] { + llvm::call_once(g_initialize, [] { g_mutex = new std::mutex(); // NOTE: INTENTIONAL LEAK due to global // destructor chain }); Index: source/Symbol/GoASTContext.cpp === --- source/Symbol/GoASTContext.cpp +++ source/Symbol/GoASTContext.cpp @@ -25,6 +25,8 @@
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski updated this revision to Diff 87120. krytarowski added a comment. Typo. Repository: rL LLVM https://reviews.llvm.org/D29288 Files: include/lldb/Core/Debugger.h source/Commands/CommandObjectPlatform.cpp source/Core/Debugger.cpp source/Core/ModuleList.cpp source/Host/common/Editline.cpp source/Host/common/HostInfoBase.cpp source/Host/linux/HostInfoLinux.cpp source/Host/windows/HostInfoWindows.cpp source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp source/Plugins/Language/Go/GoLanguage.cpp source/Plugins/Language/Java/JavaLanguage.cpp source/Plugins/Language/ObjC/ObjCLanguage.cpp source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp source/Plugins/Platform/MacOSX/PlatformDarwin.cpp source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp source/Plugins/Process/Linux/NativeProcessLinux.cpp source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp source/Plugins/Process/Windows/Common/ProcessWindows.cpp source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp source/Plugins/Process/elf-core/ProcessElfCore.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp source/Plugins/Process/mach-core/ProcessMachCore.cpp source/Plugins/Process/minidump/ProcessMinidump.cpp source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTContext.cpp source/Symbol/GoASTContext.cpp source/Target/Language.cpp source/Utility/ConstString.cpp tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp Index: tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp === --- tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp +++ tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp @@ -46,10 +46,10 @@ s_os_activity_stream_set_event_handler; bool LookupSPICalls() { - static std::once_flag s_once_flag; + LLVM_DEFINE_ONCE_FLAG(s_once_flag); static bool s_has_spi; - std::call_once(s_once_flag, [] { + llvm::call_once(s_once_flag, [] { dlopen ("/System/Library/PrivateFrameworks/LoggingSupport.framework/LoggingSupport", RTLD_NOW); s_os_activity_stream_for_pid = (os_activity_stream_for_pid_t)dlsym( RTLD_DEFAULT, "os_activity_stream_for_pid"); Index: source/Utility/ConstString.cpp === --- source/Utility/ConstString.cpp +++ source/Utility/ConstString.cpp @@ -20,6 +20,7 @@ #include "llvm/Support/RWMutex.h" // Project includes +#include "llvm/Support/Threading.h" #include "lldb/Utility/Stream.h" using namespace lldb_private; @@ -191,10 +192,10 @@ // touch ConstStrings is difficult. So we leak the pool instead. //-- static Pool &StringPool() { - static std::once_flag g_pool_initialization_flag; + LLVM_DEFINE_ONCE_FLAG(g_pool_initialization_flag); static Pool *g_string_pool = nullptr; - std::call_once(g_pool_initialization_flag, + llvm::call_once(g_pool_initialization_flag, []() { g_string_pool = new Pool(); }); return *g_string_pool; Index: source/Target/Language.cpp === --- source/Target/Language.cpp +++ source/Target/Language.cpp @@ -20,6 +20,8 @@ #include "lldb/Target/Target.h" #include "lldb/Utility/Stream.h" +#include "llvm/Support/Threading.h" + using namespace lldb; using namespace lldb_private; using namespace lldb_private::formatters; @@ -29,20 +31,20 @@ static LanguagesMap &GetLanguagesMap() { static LanguagesMap *g_map = nullptr; - static std::once_flag g_initialize; + LLVM_DEFINE_ONCE_FLAG(g_initialize); - std::call_once(g_initialize, [] { + llvm::call_once(g_initialize, [] { g_map = new LanguagesMap(); // NOTE: INTENTIONAL LEAK due to global // destructor chain }); return *g_map; } static std::mutex &GetLanguagesMutex() { static std::mutex *g_mutex = nullptr; - static std::once_flag g_initialize; + LLVM_DEFINE_ONCE_FLAG(g_initialize); - std::call_once(g_initialize, [] { + llvm::call_once(g_initialize, [] { g_mutex = new std::mutex(); // NOTE: INTENTIONAL LEAK due to global // destructor chain }); Index: source/Symbol/GoASTContext.cpp === --- source/Symbol/GoASTContext.cpp +++ source/Symbol/GoASTContext.cpp @@ -25,6 +25,8 @@ #include "lldb/Target/ExecutionContex
[Lldb-commits] [PATCH] D29510: Remove LIBLLDB_LOG_VERBOSE category
This revision was automatically updated to reflect the committed changes. Closed by commit rL294113: Remove LIBLLDB_LOG_VERBOSE category (authored by labath). Changed prior to commit: https://reviews.llvm.org/D29510?vs=87046&id=87125#toc Repository: rL LLVM https://reviews.llvm.org/D29510 Files: lldb/trunk/include/lldb/Core/Log.h lldb/trunk/include/lldb/Core/Logging.h lldb/trunk/include/lldb/Utility/ConstString.h lldb/trunk/source/API/SBBroadcaster.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/Core/DataBufferMemoryMap.cpp lldb/trunk/source/Core/Logging.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/trunk/source/Target/Memory.cpp lldb/trunk/source/Target/SectionLoadList.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Utility/ConstString.cpp lldb/trunk/unittests/Utility/CMakeLists.txt lldb/trunk/unittests/Utility/ConstStringTest.cpp Index: lldb/trunk/unittests/Utility/ConstStringTest.cpp === --- lldb/trunk/unittests/Utility/ConstStringTest.cpp +++ lldb/trunk/unittests/Utility/ConstStringTest.cpp @@ -0,0 +1,18 @@ +//===-- ConstStringTest.cpp -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "lldb/Utility/ConstString.h" +#include "llvm/Support/FormatVariadic.h" +#include "gtest/gtest.h" + +using namespace lldb_private; + +TEST(ConstStringTest, format_provider) { + EXPECT_EQ("foo", llvm::formatv("{0}", ConstString("foo")).str()); +} Index: lldb/trunk/unittests/Utility/CMakeLists.txt === --- lldb/trunk/unittests/Utility/CMakeLists.txt +++ lldb/trunk/unittests/Utility/CMakeLists.txt @@ -1,4 +1,5 @@ add_lldb_unittest(UtilityTests + ConstStringTest.cpp ModuleCacheTest.cpp StringExtractorTest.cpp TaskPoolTest.cpp Index: lldb/trunk/source/Utility/ConstString.cpp === --- lldb/trunk/source/Utility/ConstString.cpp +++ lldb/trunk/source/Utility/ConstString.cpp @@ -334,3 +334,9 @@ // Get the size of the static string pool return StringPool().MemorySize(); } + +void llvm::format_provider::format(const ConstString &CS, +llvm::raw_ostream &OS, +llvm::StringRef Options) { + format_provider::format(CS.AsCString(), OS, Options); +} Index: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp === --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -142,14 +142,9 @@ ~InitializePythonRAII() { if (m_was_already_initialized) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | - LIBLLDB_LOG_VERBOSE)); - - if (log) { -log->Printf("Releasing PyGILState. Returning to state = %slocked\n", -m_was_already_initialized == PyGILState_UNLOCKED ? "un" - : ""); - } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); + LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked", +m_was_already_initialized == PyGILState_UNLOCKED ? "un" : ""); PyGILState_Release(m_gil_state); } else { // We initialized the threads in this function, just unlock the GIL. @@ -174,15 +169,12 @@ void InitializeThreadsPrivate() { if (PyEval_ThreadsInitialized()) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT | - LIBLLDB_LOG_VERBOSE)); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT)); m_was_already_initialized = true; m_gil_state = PyGILState_Ensure(); - if (log) { -log->Printf("Ensured PyGILState. Previous state = %slocked\n", -m_gil_state == PyGILState_UNLOCKED ? "un" : ""); - } + LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n", +m_gil_state == PyGILState_UNLOCKED ? "un" : ""); return; } @
[Lldb-commits] [lldb] r294113 - Remove LIBLLDB_LOG_VERBOSE category
Author: labath Date: Sat Feb 4 18:44:54 2017 New Revision: 294113 URL: http://llvm.org/viewvc/llvm-project?rev=294113&view=rev Log: Remove LIBLLDB_LOG_VERBOSE category Summary: Per discussion in D28616, having two ways two request logging (log enable lldb XXX verbose && log enable -v lldb XXX) is confusing. This removes the first option and standardizes all code to use the second one. I've added a LLDB_LOGV macro as a shorthand for if(log && log->GetVerbose()) and switched most of the affected log statements to use that (I've only left a couple of cases that were doing complex computations in an if(log) block). Reviewers: jingham, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D29510 Added: lldb/trunk/unittests/Utility/ConstStringTest.cpp Modified: lldb/trunk/include/lldb/Core/Log.h lldb/trunk/include/lldb/Core/Logging.h lldb/trunk/include/lldb/Utility/ConstString.h lldb/trunk/source/API/SBBroadcaster.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/Core/DataBufferMemoryMap.cpp lldb/trunk/source/Core/Logging.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp lldb/trunk/source/Target/Memory.cpp lldb/trunk/source/Target/SectionLoadList.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Utility/ConstString.cpp lldb/trunk/unittests/Utility/CMakeLists.txt Modified: lldb/trunk/include/lldb/Core/Log.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=294113&r1=294112&r2=294113&view=diff == --- lldb/trunk/include/lldb/Core/Log.h (original) +++ lldb/trunk/include/lldb/Core/Log.h Sat Feb 4 18:44:54 2017 @@ -200,4 +200,11 @@ private: log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \ } while (0) +#define LLDB_LOGV(log, ...) \ + do { \ +::lldb_private::Log *log_private = (log); \ +if (log_private && log_private->GetVerbose()) \ + log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \ + } while (0) + #endif // liblldb_Log_h_ Modified: lldb/trunk/include/lldb/Core/Logging.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Logging.h?rev=294113&r1=294112&r2=294113&view=diff == --- lldb/trunk/include/lldb/Core/Logging.h (original) +++ lldb/trunk/include/lldb/Core/Logging.h Sat Feb 4 18:44:54 2017 @@ -19,7 +19,6 @@ //-- // Log Bits specific to logging in lldb //-- -#define LIBLLDB_LOG_VERBOSE (1u << 0) #define LIBLLDB_LOG_PROCESS (1u << 1) #define LIBLLDB_LOG_THREAD (1u << 2) #define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3) @@ -69,8 +68,6 @@ Log *GetLogIfAnyCategoriesSet(uint32_t m uint32_t GetLogMask(); -bool IsLogVerbose(); - void DisableLog(const char **categories, Stream *feedback_strm); Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options, Modified: lldb/trunk/include/lldb/Utility/ConstString.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ConstString.h?rev=294113&r1=294112&r2=294113&view=diff == --- lldb/trunk/include/lldb/Utility/ConstString.h (original) +++ lldb/trunk/include/lldb/Utility/ConstString.h Sat Feb 4 18:44:54 2017 @@ -476,4 +476,11 @@ Stream &operator<<(Stream &s, const Cons } // namespace lldb_private +namespace llvm { +template <> struct format_provider { + static void format(const lldb_private::ConstString &CS, llvm::raw_ostream &OS, + llvm::StringRef Options); +}; +} + #endif // liblldb_ConstString_h_ Modified: lldb/trunk/source/API/SBBroadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBroadcaster.cpp?rev=294113&r1=294112&r2=294113&view=diff == --- lldb/trunk/source/API/SBBroadcaster.cpp (original) +++ lldb/trunk/source/API/SBBroadcaster.cpp Sat Feb 4 18:44:54 2017 @@ -22,25 +22,15 @@ SBBroadcaster::SBBroadcaster() : m_opaqu SBBroadcaster::SBBroadcaster(const char *name) : m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) { m_opaque_ptr = m_opaque_sp.get(
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski added a comment. Related https://reviews.llvm.org/D29552 I'm requesting help to test this patch on !NetBSD with and without `LLVM_THREADING_USE_STD_CALL_ONCE` defined in `"llvm/Support/Threading.h"`. This issue is blocking me from adding functional changes for the NetBSD port. Repository: rL LLVM https://reviews.llvm.org/D29288 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r294114 - Clean up PlatformLinux code
Author: labath Date: Sat Feb 4 19:04:10 2017 New Revision: 294114 URL: http://llvm.org/viewvc/llvm-project?rev=294114&view=rev Log: Clean up PlatformLinux code don't create a platform.linux setting category, as it contains no actual settings, and I don't forsee adding any soon. Also remove some unused includes while I'm in there. Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=294114&r1=294113&r2=294114&view=diff == --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Sat Feb 4 19:04:10 2017 @@ -19,18 +19,12 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" -#include "lldb/Core/Module.h" -#include "lldb/Core/ModuleList.h" -#include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Interpreter/OptionValueProperties.h" -#include "lldb/Interpreter/Property.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Error.h" @@ -48,63 +42,6 @@ using namespace lldb_private::platform_l static uint32_t g_initialize_count = 0; //-- -/// Code to handle the PlatformLinux settings -//-- - -namespace { -class PlatformLinuxProperties : public Properties { -public: - PlatformLinuxProperties(); - - ~PlatformLinuxProperties() override = default; - - static ConstString &GetSettingName(); - -private: - static const PropertyDefinition *GetStaticPropertyDefinitions(); -}; - -typedef std::shared_ptr PlatformLinuxPropertiesSP; - -} // anonymous namespace - -PlatformLinuxProperties::PlatformLinuxProperties() : Properties() { - m_collection_sp.reset(new OptionValueProperties(GetSettingName())); - m_collection_sp->Initialize(GetStaticPropertyDefinitions()); -} - -ConstString &PlatformLinuxProperties::GetSettingName() { - static ConstString g_setting_name("linux"); - return g_setting_name; -} - -const PropertyDefinition * -PlatformLinuxProperties::GetStaticPropertyDefinitions() { - static PropertyDefinition g_properties[] = { - {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}}; - - return g_properties; -} - -static const PlatformLinuxPropertiesSP &GetGlobalProperties() { - static PlatformLinuxPropertiesSP g_settings_sp; - if (!g_settings_sp) -g_settings_sp.reset(new PlatformLinuxProperties()); - return g_settings_sp; -} - -void PlatformLinux::DebuggerInitialize(Debugger &debugger) { - if (!PluginManager::GetSettingForPlatformPlugin( - debugger, PlatformLinuxProperties::GetSettingName())) { -const bool is_global_setting = true; -PluginManager::CreateSettingForPlatformPlugin( -debugger, GetGlobalProperties()->GetValueProperties(), -ConstString("Properties for the PlatformLinux plug-in."), -is_global_setting); - } -} - -//-- PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); @@ -191,7 +128,7 @@ void PlatformLinux::Initialize() { PluginManager::RegisterPlugin( PlatformLinux::GetPluginNameStatic(false), PlatformLinux::GetPluginDescriptionStatic(false), -PlatformLinux::CreateInstance, PlatformLinux::DebuggerInitialize); +PlatformLinux::CreateInstance, nullptr); } } Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=294114&r1=294113&r2=294114&view=diff == --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Sat Feb 4 19:04:10 2017 @@ -10,10 +10,6 @@ #ifndef liblldb_PlatformLinux_h_ #define liblldb_PlatformLinux_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "Plugins/Platform/POSIX/PlatformPOSIX.h" namespace lldb_private { @@ -25,8 +21,6 @@ public: ~PlatformLinux() override; - static void DebuggerInitialize(Debugger &debugger); - static void Initialize(); static void Terminate(); ___ lldb-commits mailing list lldb-commits
[Lldb-commits] [PATCH] D29266: Synchronize PlatformNetBSD with Linux
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. Just sync once more please and I think we're done. We've removed enough code to offset the remaining bit of duplication here. DebugProcess is the only remaining candidate for merging, but we don't have a good class for it now. Maybe when Freebsd switches to lldb-server we can put it in processposix. Repository: rL LLVM https://reviews.llvm.org/D29266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
labath added inline comments. Comment at: include/lldb/Core/Debugger.h:379 lldb::ListenerSP m_forward_listener_sp; - std::once_flag m_clear_once; + llvm::once_flag m_clear_once; The code in llvm says you should only ever use the LLVM_DEFINE_ONCE_FLAG to declare flags. I am guessing it's because it forces the `static` keyword into the declaration, which in turn guarantees your object will be zero-initialized by the linker. If you declare the flag as a local variable like this, it will be initialized to a random value, and you will have a fun time debugging issues in the future (it will only affect netbsd, as std::call_once platforms will still be correctly initialized). Comment at: source/Core/ModuleList.cpp:648 static ModuleList &GetSharedModuleList() { static ModuleList *g_shared_module_list = nullptr; + LLVM_DEFINE_ONCE_FLAG(g_once_flag); This could be simplified to: ```static ModuleList *g_shared_module_list = new ModuleList();``` It's only written this way because MSVC at one point did not support thread-safe statics. Repository: rL LLVM https://reviews.llvm.org/D29288 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29266: Synchronize PlatformNetBSD with Linux
krytarowski added a comment. I'm syncing the code to get the changes from SVN revision 294114 "Clean up PlatformLinux code" Repository: rL LLVM https://reviews.llvm.org/D29266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29266: Synchronize PlatformNetBSD with Linux
krytarowski updated this revision to Diff 87126. krytarowski added a comment. Catch up after r294114 - Clean up PlatformLinux code Repository: rL LLVM https://reviews.llvm.org/D29266 Files: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp source/Plugins/Platform/NetBSD/PlatformNetBSD.h Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.h === --- source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -10,100 +10,57 @@ #ifndef liblldb_PlatformNetBSD_h_ #define liblldb_PlatformNetBSD_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Target/Platform.h" +#include "Plugins/Platform/POSIX/PlatformPOSIX.h" namespace lldb_private { namespace platform_netbsd { -class PlatformNetBSD : public Platform { +class PlatformNetBSD : public PlatformPOSIX { public: PlatformNetBSD(bool is_host); - ~PlatformNetBSD() override = default; - - // - // Class functions - // - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + ~PlatformNetBSD() override; static void Initialize(); static void Terminate(); - static ConstString GetPluginNameStatic(bool is_host); - - static const char *GetDescriptionStatic(bool is_host); - // // lldb_private::PluginInterface functions // - ConstString GetPluginName() override { return GetPluginNameStatic(IsHost()); } + static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); - uint32_t GetPluginVersion() override { return 1; } + static ConstString GetPluginNameStatic(bool is_host); - const char *GetDescription() override { -return GetDescriptionStatic(IsHost()); - } + static const char *GetPluginDescriptionStatic(bool is_host); + + ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override { return 1; } // // lldb_private::Platform functions // - bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, - ModuleSpec &module_spec) override; - - Error RunShellCommand(const char *command, const FileSpec &working_dir, -int *status_ptr, int *signo_ptr, -std::string *command_output, -uint32_t timeout_sec) override; - - bool GetRemoteOSVersion() override; - - bool GetRemoteOSBuildString(std::string &s) override; - - bool GetRemoteOSKernelDescription(std::string &s) override; - - // Remote Platform subclasses need to override this function - ArchSpec GetRemoteSystemArchitecture() override; - - bool IsConnected() const override; - - Error ConnectRemote(Args &args) override; - - Error DisconnectRemote() override; - - const char *GetHostname() override; - - const char *GetUserName(uint32_t uid) override; - - const char *GetGroupName(uint32_t gid) override; - - Error LaunchProcess(ProcessLaunchInfo &launch_info) override; + const char *GetDescription() override { +return GetPluginDescriptionStatic(IsHost()); + } - lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, - Target *target, Error &error) override; + void GetStatus(Stream &strm) override; - // NetBSD processes can not be launched by spawning and attaching. - bool CanDebugProcess() override { return false; } + bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; - Error GetSharedModule(const ModuleSpec &module_spec, Process *process, -lldb::ModuleSP &module_sp, -const FileSpecList *module_search_paths_ptr, -lldb::ModuleSP *old_module_sp_ptr, -bool *did_create_ptr) override; + int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override; - bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override; + bool CanDebugProcess() override; - void GetStatus(Stream &strm) override; + lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, + Debugger &debugger, Target *target, + Error &error) override; void CalculateTrapHandlerSymbolNames() override; -protected: - lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a - // remote netbsd OS + uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch, + unsigned flags) override; private: DISALLOW_COPY_AND_ASSIGN(PlatformNetBSD); I
[Lldb-commits] [PATCH] D29266: Synchronize PlatformNetBSD with Linux
krytarowski added a comment. OK to land it? FreeBSD can reuse almost exact the same code. I'm not sure if it's compatible with their Process Plugin. Repository: rL LLVM https://reviews.llvm.org/D29266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski added inline comments. Comment at: include/lldb/Core/Debugger.h:379 lldb::ListenerSP m_forward_listener_sp; - std::once_flag m_clear_once; + llvm::once_flag m_clear_once; labath wrote: > The code in llvm says you should only ever use the LLVM_DEFINE_ONCE_FLAG to > declare flags. I am guessing it's because it forces the `static` keyword into > the declaration, which in turn guarantees your object will be > zero-initialized by the linker. If you declare the flag as a local variable > like this, it will be initialized to a random value, and you will have a fun > time debugging issues in the future (it will only affect netbsd, as > std::call_once platforms will still be correctly initialized). I was thinking about it, there is `m_clear_once()` in `lldb/source/Core/Debugger.cpp` used in the initializer. But apparently there is no zeroing it with this. Similar case is in DWARFDataSegment. ``` struct DWARFDataSegment { llvm::once_flag m_flag; lldb_private::DWARFDataExtractor m_data; }; ``` And another one with `static llvm::ManagedStatic g_once_flag;` (I don't fully understand the impact here). Is there an option to turn `llvm::once_flag` to behave like `std::once_flag`? For example changing once_flag to a class like: ``` class once_flag { once_flag() : status(Uninitialized) {}; llvm::sys::cas_flag status; }; ``` and replace occurrences of `flag` with `flag.status`. Perhaps it would change the code to mechanical replacement of `std::once_flag` and `std::call_ones` to `llvm::` versions. Repository: rL LLVM https://reviews.llvm.org/D29288 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski added a comment. I've tried to build the LLDB code with mechanically * replaced `std::call_once` -> `llvm::call_once` and `std::once_flag` -> `llvm::once_flag`: --- /public/llvm/include/llvm/Support/Threading.h 2017-02-05 00:15:00.769574623 +0100 +++ /usr/pkg/include/llvm/Support/Threading.h 2017-02-05 04:14:03.334251557 +0100 @@ -62,12 +62,16 @@ /// This macro is the only way you should define your once flag for LLVM's /// call_once. -#define LLVM_DEFINE_ONCE_FLAG(flag) static ::llvm::once_flag flag +#define LLVM_DEFINE_ONCE_FLAG(flag) static once_flag flag #else enum InitStatus { Uninitialized = 0, Wait = 1, Done = 2 }; - typedef volatile sys::cas_flag once_flag; + class once_flag { + public: +once_flag() : status(::llvm::Uninitialized) {}; +volatile ::llvm::sys::cas_flag status; + }; /// This macro is the only way you should define your once flag for LLVM's /// call_once. @@ -96,24 +100,24 @@ #else // For other platforms we use a generic (if brittle) version based on our // atomics. -sys::cas_flag old_val = sys::CompareAndSwap(&flag, Wait, Uninitialized); +sys::cas_flag old_val = sys::CompareAndSwap(&flag.status, Wait, Uninitialized); if (old_val == Uninitialized) { std::forward(F)(std::forward(ArgList)...); sys::MemoryFence(); TsanIgnoreWritesBegin(); - TsanHappensBefore(&flag); - flag = Done; + TsanHappensBefore(&flag.status); + flag.status = Done; TsanIgnoreWritesEnd(); } else { // Wait until any thread doing the call has finished. - sys::cas_flag tmp = flag; + sys::cas_flag tmp = flag.status; sys::MemoryFence(); while (tmp != Done) { -tmp = flag; +tmp = flag.status; sys::MemoryFence(); } } -TsanHappensAfter(&flag); +TsanHappensAfter(&flag.status); #endif } - there is one exception, I don't understand: const DWARFDataExtractor & SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type, DWARFDataSegment &data_segment) { #if 0 llvm::call_once(data_segment.m_flag, &SymbolFileDWARF::LoadSectionData, this, sect_type, std::ref(data_segment.m_data)); #else llvm::call_once(data_segment.m_flag, [this, sect_type, &data_segment] { this->LoadSectionData(sect_type, std::ref(data_segment.m_data)); } ); #endif return data_segment.m_data; } This exception is valid for so far all versions of switches out of `std::once_flag`. Repository: rL LLVM https://reviews.llvm.org/D29288 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski added a comment. Test results for the above patch for LLVM and LLDB with "mechanical" switch to `llvm::call_once`. === Test Result Summary === Test Methods: 1224 Reruns:1 Success: 268 Expected Failure: 21 Failure: 324 Error: 166 Exceptional Exit: 0 Unexpected Success:1 Skip:441 Timeout: 3 Expected Timeout: 0 Results from Jan 21st === Test Result Summary === Test Methods: 1218 Reruns:1 Success: 264 Expected Failure: 20 Failure: 323 Error: 166 Exceptional Exit: 1 Unexpected Success:1 Skip:440 Timeout: 3 Expected Timeout: 0 It looks good to me. The patch on review with `LLVM_DEFINE_ONCE_FLAG` badly timeouts for me and I interrupted it. Repository: rL LLVM https://reviews.llvm.org/D29288 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once
krytarowski added a comment. Once someone could explain to me why `SymbolFileDWARF::GetCachedSectionData` cannot be switched mechanically to `llvm::call_once`, I would like to propose this revamped interface to llvm. Repository: rL LLVM https://reviews.llvm.org/D29288 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits