[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-02-06 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294202: Switch std::call_once to llvm::call_once (authored 
by kamil).

Changed prior to commit:
  https://reviews.llvm.org/D29288?vs=87153=87252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29288

Files:
  lldb/trunk/include/lldb/Core/Debugger.h
  lldb/trunk/source/Commands/CommandObjectPlatform.cpp
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Host/common/Editline.cpp
  lldb/trunk/source/Host/common/HostInfoBase.cpp
  lldb/trunk/source/Host/linux/HostInfoLinux.cpp
  lldb/trunk/source/Host/windows/HostInfoWindows.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/trunk/source/Plugins/Language/Go/GoLanguage.cpp
  lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp
  lldb/trunk/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
  lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp
  lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
  lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/trunk/source/Symbol/ClangASTContext.cpp
  lldb/trunk/source/Symbol/GoASTContext.cpp
  lldb/trunk/source/Target/Language.cpp
  lldb/trunk/source/Utility/ConstString.cpp
  lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp

Index: lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
===
--- lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp
+++ lldb/trunk/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;
+  static llvm::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: lldb/trunk/source/Host/common/HostInfoBase.cpp
===
--- lldb/trunk/source/Host/common/HostInfoBase.cpp
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp
@@ -22,9 +22,10 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
 
-#include  // std::once
+#include 
 #include 
 
 using namespace lldb;
@@ -79,45 +80,45 @@
 }
 
 uint32_t HostInfoBase::GetNumberCPUS() {
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, []() {
+  static llvm::once_flag g_once_flag;
+  llvm::call_once(g_once_flag, []() {
 g_fields->m_number_cpus = std::thread::hardware_concurrency();
   });
   return g_fields->m_number_cpus;
 }
 
 uint32_t HostInfoBase::GetMaxThreadNameLength() { return 0; }
 
 llvm::StringRef HostInfoBase::GetVendorString() {
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, []() {
+  static llvm::once_flag g_once_flag;
+  llvm::call_once(g_once_flag, []() {
 g_fields->m_vendor_string =
 HostInfo::GetArchitecture().GetTriple().getVendorName().str();
   });
   return g_fields->m_vendor_string;
 }
 
 llvm::StringRef HostInfoBase::GetOSString() {
-  static std::once_flag g_once_flag;
-  std::call_once(g_once_flag, []() {
+  static llvm::once_flag g_once_flag;
+  llvm::call_once(g_once_flag, []() {
 g_fields->m_os_string =
 std::move(HostInfo::GetArchitecture().GetTriple().getOSName());
   });
   return g_fields->m_os_string;
 }
 
 llvm::StringRef HostInfoBase::GetTargetTriple() {
-  static std::once_flag g_once_flag;
-  

[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-02-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Thanks for doing the right thing in LLVM first, looks great!


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

2017-02-06 Thread Kamil Rytarowski via Phabricator via lldb-commits
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;
 

clayborg wrote:
> Is there a valid default initializer for the llvm::once_flag? If so, we are 
> good to go, if not, we need to either initialize it manually, probably by 
> adding another macro to llvm to do the initialization. Static versions might 
> rely on the compiler zeroing out the memory...
Yes, there is a valid default initializer for llvm::once_flag.

Related entry in LLVM - D29566


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

2017-02-05 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski updated this revision to Diff 87153.
krytarowski added a comment.

Revamp to new llvm::once_flag


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;
+  static llvm::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 () {
-  static std::once_flag g_pool_initialization_flag;
+  static llvm::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 () {
   static LanguagesMap *g_map = nullptr;
-  static std::once_flag g_initialize;
+  static llvm::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 () {
   static std::mutex *g_mutex = nullptr;
-  static std::once_flag g_initialize;
+  static llvm::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/ExecutionContext.h"
 #include 

[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-02-05 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

https://reviews.llvm.org/D29566 I filed a patch in 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


[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-02-04 Thread Kamil Rytarowski via Phabricator via lldb-commits
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


[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-02-04 Thread Kamil Rytarowski via Phabricator via lldb-commits
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

2017-02-04 Thread Kamil Rytarowski via Phabricator via lldb-commits
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(, Wait, Uninitialized);
  +sys::cas_flag old_val = sys::CompareAndSwap(, Wait, 
Uninitialized);
   if (old_val == Uninitialized) {
 std::forward(F)(std::forward(ArgList)...);
 sys::MemoryFence();
 TsanIgnoreWritesBegin();
  -  TsanHappensBefore();
  -  flag = Done;
  +  TsanHappensBefore();
  +  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();
  +TsanHappensAfter();
   #endif
 }
   



- there is one exception, I don't understand:

  const DWARFDataExtractor &
  SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type,
DWARFDataSegment _segment) {
  #if 0
llvm::call_once(data_segment.m_flag, ::LoadSectionData, 
this,
   sect_type, std::ref(data_segment.m_data));
  #else
llvm::call_once(data_segment.m_flag,
  [this, sect_type, _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

2017-01-30 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D29288#660703, @mehdi_amini wrote:

> In https://reviews.llvm.org/D29288#660677, @krytarowski wrote:
>
> > In https://reviews.llvm.org/D29288#660636, @clayborg wrote:
> >
> > > Be very careful when using this, you can't change member variables that 
> > > used to be std::once to be statics. We also don't need the llvm namespace 
> > > to be included with "using namespace llvm;" in many of the files.
> >
> >
> > `using namespace llvm;` is currently required in order to get this 
> > functional:
>
>
> What about just updating the macro in LLVM to make it not needed?
>
>   #define LLVM_DEFINE_ONCE_FLAG(flag) static llvm::once_flag flag = 
> Uninitialized
>


Right, this looks cleaner. I will propose this patch as a separated review.


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

2017-01-30 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

  namespace llvm {
namespace sys {
  void MemoryFence();
  
  #ifdef _MSC_VER
  typedef long cas_flag;
  #else
  typedef uint32_t cas_flag;
  #endif
  cas_flag CompareAndSwap(volatile cas_flag* ptr,
  cas_flag new_value,
  cas_flag old_value);
}
  }



- `include/llvm/Support/Atomic.h` of 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


[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-01-30 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

In https://reviews.llvm.org/D29288#660636, @clayborg wrote:

> Be very careful when using this, you can't change member variables that used 
> to be std::once to be statics. We also don't need the llvm namespace to be 
> included with "using namespace llvm;" in many of the files.


`using namespace llvm;` is currently required in order to get this functional:

enum InitStatus { Uninitialized = 0, Wait = 1, Done = 2 };
typedef volatile sys::cas_flag once_flag;
/// This macro is the only way you should define your once flag for LLVM's
/// call_once.
  #define LLVM_DEFINE_ONCE_FLAG(flag) static once_flag flag = Uninitialized

`sys::cas_flag` is a member of the `llvm` namespace.


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

2017-01-30 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Be very careful when using this, you can't change member variables that used to 
be std::once to be statics. We also don't need the llvm namespace to be 
included with "using namespace llvm;" in many of the files.




Comment at: include/lldb/Core/Debugger.h:376
   Broadcaster m_sync_broadcaster;
   lldb::ListenerSP m_forward_listener_sp;
 

There must be an in ivar for m_clear_once. This can't be a static. 
Debugger::Clear() can only be called once per debugger instance, not just once 
ever.



Comment at: source/Core/Debugger.cpp:68
 using namespace lldb_private;
+using namespace llvm;
 

Why was this added? Remove if not needed.



Comment at: source/Core/Debugger.cpp:768-769
   //--
-  std::call_once(m_clear_once, [this]() {
+  LLVM_DEFINE_ONCE_FLAG(m_clear_once);
+  llvm::call_once(m_clear_once, [this]() {
 ClearIOHandlers();

This is wrong, it must be in ivar. We are trying to make sure Debugger::Clear() 
gets calls only once for each instance of a Debugger. Read the comment.



Comment at: source/Core/ModuleList.cpp:33
 using namespace lldb_private;
+using namespace llvm;
 

Why was this using added? Remove please.



Comment at: source/Host/common/Editline.cpp:27
 using namespace lldb_private::line_editor;
+using namespace llvm;
 

Why was this added? Remove if not needed? I hope the LLVM_DEFINE_ONCE_FLAG 
doesn't require the using directive. If it does, it should be fixed.



Comment at: source/Host/common/HostInfoBase.cpp:33
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Host/linux/HostInfoLinux.cpp:22
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Host/windows/HostInfoWindows.cpp:24
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp:38
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:47
 using namespace lldb_private::formatters;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Language/Go/GoLanguage.cpp:30
 using namespace lldb_private::formatters;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Language/Java/JavaLanguage.cpp:32
 using namespace lldb_private::formatters;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Language/ObjC/ObjCLanguage.cpp:39
 using namespace lldb_private::formatters;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:51
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:51
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp:53
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp:24
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Process/Windows/Common/ProcessWindows.cpp:44
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp:20
 using namespace lldb_private;
+using namespace llvm;
 

Remove



Comment at: source/Plugins/Process/elf-core/ProcessElfCore.cpp:40
 using namespace lldb_private;
+using namespace llvm;
 

rm



Comment at: 
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp:48
 using namespace lldb_private::process_gdb_remote;
+using namespace llvm;
 

rm



Comment at: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:90
 using namespace lldb_private::process_gdb_remote;
+using namespace llvm;
 

rm



Comment at: source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp:24
 using namespace lldb_private::process_gdb_remote;
+using namespace llvm;
 

rm



Comment at: source/Plugins/Process/mach-core/ProcessMachCore.cpp:50
 using namespace lldb_private;
+using namespace llvm;
 

rm



[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-01-30 Thread Mehdi AMINI via Phabricator via lldb-commits
mehdi_amini added a comment.

I'm fine with this change, but I'll leave the approval to one of the LLDB 
developer :)

(Thanks for following-up with the libstdc++ on these platforms!)


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

2017-01-30 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

I can build and test this patch on NetBSD/amd64.

I don't have access right now to a performant FreeBSD, Linux, Android, Windows 
and FreeBSD hosts to test build and execute tests for this patch on other 
platforms. Please check.

I was in touch with `libstdc++` developers and the reason why `std::call_once` 
crashes is still cryptic. A combination of TLS, shared library and pointer to a 
function passed to `pthread_once`(3) results in a crash. Switch LLDB to the 
standard LLVM wrapper for `std::cal_once`.

Few months back discussed with @mehdi_amini in the context of 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


[Lldb-commits] [PATCH] D29288: Switch std::call_once to llvm::call_once

2017-01-30 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski created this revision.
krytarowski added a project: LLDB.

The std::call_once implementation in libstdc++ has problems on few systems: 
NetBSD, OpenBSD and Linux PPC. LLVM ships with a homegrown implementation 
llvm::call_once to help on these platforms.

  

This change is required in the NetBSD LLDB port. std::call_once with libstdc++ 
results with crashing the debugger.


Repository:
  rL LLVM

https://reviews.llvm.org/D29288

Files:
  include/lldb/Core/Debugger.h
  source/Commands/CommandObjectPlatform.cpp
  source/Core/ConstString.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
  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/Target/Language.cpp
===
--- source/Target/Language.cpp
+++ source/Target/Language.cpp
@@ -20,29 +20,32 @@
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Target/Target.h"
 
+#include "llvm/Support/Threading.h"
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::formatters;
+using namespace llvm;
 
 typedef std::unique_ptr LanguageUP;
 typedef std::map LanguagesMap;
 
 static LanguagesMap () {
   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 () {
   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,10 +25,13 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Target.h"
 
+#include "llvm/Support/Threading.h"
+
 #include "Plugins/ExpressionParser/Go/GoUserExpression.h"
 #include "Plugins/SymbolFile/DWARF/DWARFASTParserGo.h"
 
 using namespace lldb;
+using namespace llvm;
 
 namespace lldb_private {
 class GoArray;
@@ -593,8 +596,8 @@
   if (name) {
 typedef UniqueCStringMap TypeNameToBasicTypeMap;
 static TypeNameToBasicTypeMap g_type_map;
-static std::once_flag g_once_flag;
-std::call_once(g_once_flag,