[Lldb-commits] [PATCH] D30702: Fix remaining threading issues in Log.h

2017-03-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.






Comment at: include/lldb/Utility/Log.h:152
 
-  Flags &GetOptions();
+  const Flags GetOptions() const;
 

eugene wrote:
> Seems like const on return value is not really needed.
Well... otherwise people could write something like: 
`log.GetOptions().Reset(foo)` and expect that it will change underlying log 
object. This worked before this patch, so this seems like a good idea -- make 
sure accidental usage like that results in a compiler error rather than 
silently fail.



Comment at: include/lldb/Utility/Log.h:163
+  std::atomic m_options{0};
+  std::atomic m_mask{0};
+

eugene wrote:
> Do we actually need atomics here? 
> 
> It seems like the stream itself is protected by the mutex, and It doesn't 
> seem to affect performance.
> Can we use the same (or a different) mutex to protect flags and options?
The difference is that these variables are accessed even when logging is 
disabled -- `GetLogIfAll` fetches the mask to decide whether it should log 
things. The stream mutex is only taken if logging is enabled **and** you are 
actually logging something (also only the read side is taken, so it is 
contention-free unless someone actually is modifying the stream at the same 
time).

I don't think doing this with a mutex would drastically hurt our performance, 
but I'm trying to avoid the case where enabling logging introduces enough 
thread synchronization than the race condition you were debugging disappears.



Comment at: source/Utility/Log.cpp:90-91
   uint32_t options, uint32_t flags) {
-  log.GetMask().Set(flags);
-  if (log.GetMask().Get()) {
-log.GetOptions().Reset(options);
+  uint32_t mask = log.m_mask.load(std::memory_order_acquire) | flags;
+  log.m_mask.store(mask, std::memory_order_release);
+  if (mask) {

zturner wrote:
> How about 
> 
> ```
> uint32_t old_mask = log.m_mask.fetch_or(flags);
> if (old_mask  & flags) {
>   ...
> }
> ```
> 
> Also, there is still a race if two people call this function at the same time.
That is not the race I was trying to solve here, but it seems making sure that 
is safe wouldn't be too hard, and it should make this easier to reason about. 
I'll reuse the stream mutex for this case.



Comment at: source/Utility/Log.cpp:116
+const Flags Log::GetMask() const {
+  return m_mask.load(std::memory_order_acquire);
+}

zturner wrote:
> Any reason you always use the explicit `load(memory_order_acquire)` syntax 
> instead of using the default sequentially consistent ordering?
The sequentially consistent ordering is more heavy, particularly on weakly 
ordered systems, and it's not necessary here - all I need is to make sure the 
value is read correctly. In fact, I was considering dropping this all the way 
to memory_order_relaxed.


https://reviews.llvm.org/D30702



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D30698: Resubmit "Use LLVM for all stat related calls"

2017-03-08 Thread Pavel Labath via lldb-commits
I've tried it out not and it works -- I think it's good to go then.

The unit tests, was that a debug build by any chance? I think we are
missing some dependency there which shows up only on debug builds, but
I haven't dug into that yet.

On 7 March 2017 at 22:28, Zachary Turner  wrote:
> I can run build TargetTests though (I guess it doesn't depend on editline),
> and that one passes.
>
> On Tue, Mar 7, 2017 at 2:26 PM Zachary Turner  wrote:
>>
>> =
>> Issue Details
>> =
>> UNEXPECTED SUCCESS: test_and_run_command_dwarf
>> (lang/c/register_variables/TestRegisterVariables.py)
>> UNEXPECTED SUCCESS: test_and_run_command_dwo
>> (lang/c/register_variables/TestRegisterVariables.py)
>> UNEXPECTED SUCCESS: test_dwarf
>> (functionalities/thread/exit_during_break/TestExitDuringBreak.py)
>> UNEXPECTED SUCCESS: test_dwo
>> (functionalities/thread/exit_during_break/TestExitDuringBreak.py)
>> UNEXPECTED SUCCESS: test_lldbmi_gdb_set_target_async_off
>> (tools/lldb-mi/TestMiGdbSetShow.py)
>> UNEXPECTED SUCCESS: test_lldbmi_process_output
>> (tools/lldb-mi/syntax/TestMiSyntax.py)
>> UNEXPECTED SUCCESS: test_lldbmi_settings_set_target_run_args_after
>> (tools/lldb-mi/interpreter/TestMiInterpreterExec.py)
>> UNEXPECTED SUCCESS: test_multiple_debuggers_dwarf
>> (api/multiple-debuggers/TestMultipleDebuggers.py)
>> UNEXPECTED SUCCESS: test_process_interrupt_dwo
>> (functionalities/thread/state/TestThreadStates.py)
>> UNEXPECTED SUCCESS: test_sb_api_listener_resume_dwarf
>> (api/multithreaded/TestMultithreaded.py)
>> UNEXPECTED SUCCESS: test_sb_api_listener_resume_dwo
>> (api/multithreaded/TestMultithreaded.py)
>> UNEXPECTED SUCCESS: test_with_dwarf (lang/cpp/printf/TestPrintf.py)
>> UNEXPECTED SUCCESS: test_with_dwo (lang/cpp/printf/TestPrintf.py)
>>
>> ===
>> Test Result Summary
>> ===
>> Test Methods:   1905
>> Reruns:0
>> Success:1203
>> Expected Failure:117
>> Failure:   0
>> Error: 0
>> Exceptional Exit:  0
>> Unexpected Success:   13
>> Skip:572
>> Timeout:   0
>> Expected Timeout:  0
>>
>> I can't seem to run unittests because I'm getting undefined references to
>> editline which I haven't dug into, but the regular tests pass.
>>
>> On Tue, Mar 7, 2017 at 1:47 PM Pavel Labath via Phabricator
>>  wrote:
>>>
>>> labath accepted this revision.
>>> labath added a comment.
>>> This revision is now accepted and ready to land.
>>>
>>> OK, let's give this another shot. (I haven't tried it on linux yet, so if
>>> you haven't either then let's wait until tomorrow, or maybe @eugene could
>>> try it out (?)). I don't think we need to be worried about symlink overwrite
>>> in the ModuleCache test.
>>>
>>>
>>>
>>> 
>>> Comment at: llvm/include/llvm/Support/FileSystem.h:500
>>> +/// @param result Set to true if \a path is a directory (after following
>>> +///   symlinks, false if it is not. Undefined otherwise.
>>>  /// @returns errc::success if result has been successfully set,
>>> otherwise a
>>> 
>>> missing closing paren here
>>>
>>>
>>> https://reviews.llvm.org/D30698
>>>
>>>
>>>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30702: Fix remaining threading issues in Log.h

2017-03-08 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 90994.
labath added a comment.

I've repurposed the stream mutex to protect the entirety of enable/disable
operations. To make this flow better, I've also gotten rid of the LogAndChannel
struct and make Channel a member of Log directly (which required moving some
declarations from the cpp file to the header).

I've also updated all atomic operations to use relaxed memory order. For the
operations in the critical section in does not matter. for the fast path in the
logging code it is enough to makee sure that the reads are atomic and once we
get around to actually writing to the log,  the read lock on the mutex will make
sure the modifications to m_stream_sp are visible to the logging thread.


https://reviews.llvm.org/D30702

Files:
  include/lldb/Utility/Log.h
  source/Utility/Log.cpp
  unittests/Utility/LogTest.cpp

Index: unittests/Utility/LogTest.cpp
===
--- unittests/Utility/LogTest.cpp
+++ unittests/Utility/LogTest.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Utility/StreamString.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Threading.h"
+#include 
 #include 
 
 using namespace lldb;
@@ -214,3 +215,51 @@
   EXPECT_TRUE(stream_sp->str() == "" || stream_sp->str() == "Hello World\n")
   << "str(): " << stream_sp->str();
 }
+
+TEST_F(LogChannelTest, LogVerboseThread) {
+  // Test that we are able to concurrently check the verbose flag of a log
+  // channel and enable it.
+  std::string message;
+  std::shared_ptr stream_sp(
+  new llvm::raw_string_ostream(message));
+  StreamString err;
+  EXPECT_TRUE(Log::EnableLogChannel(stream_sp, 0, "chan", {}, err));
+
+  Log *log = test_channel.GetLogIfAll(FOO);
+
+  // Start logging on one thread. Concurrently, try enabling the log channel
+  // (with different log options).
+  std::thread log_thread([log] { LLDB_LOGV(log, "Hello World"); });
+  EXPECT_TRUE(Log::EnableLogChannel(stream_sp, LLDB_LOG_OPTION_VERBOSE, "chan",
+{}, err));
+  log_thread.join();
+  EXPECT_TRUE(Log::DisableLogChannel("chan", {}, err));
+
+  // The log thread either managed to write to the log, or it didn't. In either
+  // case, we should not trip any undefined behavior (run the test under TSAN to
+  // verify this).
+  EXPECT_TRUE(stream_sp->str() == "" || stream_sp->str() == "Hello World\n")
+  << "str(): " << stream_sp->str();
+}
+
+TEST_F(LogChannelTest, LogGetLogThread) {
+  // Test that we are able to concurrently get mask of a Log object and disable
+  // it.
+  std::string message;
+  std::shared_ptr stream_sp(
+  new llvm::raw_string_ostream(message));
+  StreamString err;
+  EXPECT_TRUE(Log::EnableLogChannel(stream_sp, 0, "chan", {}, err));
+  Log *log = test_channel.GetLogIfAll(FOO);
+
+  // Try fetching the log on one thread. Concurrently, try disabling the log
+  // channel.
+  uint32_t mask;
+  std::thread log_thread([log, &mask] { mask = log->GetMask().Get(); });
+  EXPECT_TRUE(Log::DisableLogChannel("chan", {}, err));
+  log_thread.join();
+
+  // The mask should be either zero of "FOO". In either case, we should not trip
+  // any undefined behavior (run the test under TSAN to verify this).
+  EXPECT_TRUE(mask == 0 || mask == FOO) << "mask: " << mask;
+}
Index: source/Utility/Log.cpp
===
--- source/Utility/Log.cpp
+++ source/Utility/Log.cpp
@@ -18,7 +18,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Chrono.h"
-#include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
@@ -36,27 +35,17 @@
 using namespace lldb;
 using namespace lldb_private;
 
-namespace {
-  struct ChannelAndLog {
-Log log;
-Log::Channel &channel;
+llvm::ManagedStatic Log::g_channel_map;
 
-ChannelAndLog(Log::Channel &channel) : channel(channel) {}
-  };
-  typedef llvm::StringMap ChannelMap;
-}
-
-static llvm::ManagedStatic g_channel_map;
-
-static void ListCategories(Stream &stream, const ChannelMap::value_type &entry) {
+void Log::ListCategories(Stream &stream, const ChannelMap::value_type &entry) {
   stream.Format("Logging categories for '{0}':\n", entry.first());
   stream.Format("  all - all available logging categories\n");
   stream.Format("  default - default set of logging categories\n");
-  for (const auto &category : entry.second.channel.categories)
+  for (const auto &category : entry.second.m_channel.categories)
 stream.Format("  {0} - {1}\n", category.name, category.description);
 }
 
-static uint32_t GetFlags(Stream &stream, const ChannelMap::value_type &entry,
+uint32_t Log::GetFlags(Stream &stream, const ChannelMap::value_type &entry,
  llvm::ArrayRef categories) {
   bool list_categories = false;
   uint32_t flags = 0;
@@ -66,13 +55,13 @@
   continue;
 }
 if (llvm::StringRe

Re: [Lldb-commits] [PATCH] D30698: Resubmit "Use LLVM for all stat related calls"

2017-03-08 Thread Zachary Turner via lldb-commits
Yes it was a debug build
On Wed, Mar 8, 2017 at 2:45 AM Pavel Labath  wrote:

> I've tried it out not and it works -- I think it's good to go then.
>
> The unit tests, was that a debug build by any chance? I think we are
> missing some dependency there which shows up only on debug builds, but
> I haven't dug into that yet.
>
> On 7 March 2017 at 22:28, Zachary Turner  wrote:
> > I can run build TargetTests though (I guess it doesn't depend on
> editline),
> > and that one passes.
> >
> > On Tue, Mar 7, 2017 at 2:26 PM Zachary Turner 
> wrote:
> >>
> >> =
> >> Issue Details
> >> =
> >> UNEXPECTED SUCCESS: test_and_run_command_dwarf
> >> (lang/c/register_variables/TestRegisterVariables.py)
> >> UNEXPECTED SUCCESS: test_and_run_command_dwo
> >> (lang/c/register_variables/TestRegisterVariables.py)
> >> UNEXPECTED SUCCESS: test_dwarf
> >> (functionalities/thread/exit_during_break/TestExitDuringBreak.py)
> >> UNEXPECTED SUCCESS: test_dwo
> >> (functionalities/thread/exit_during_break/TestExitDuringBreak.py)
> >> UNEXPECTED SUCCESS: test_lldbmi_gdb_set_target_async_off
> >> (tools/lldb-mi/TestMiGdbSetShow.py)
> >> UNEXPECTED SUCCESS: test_lldbmi_process_output
> >> (tools/lldb-mi/syntax/TestMiSyntax.py)
> >> UNEXPECTED SUCCESS: test_lldbmi_settings_set_target_run_args_after
> >> (tools/lldb-mi/interpreter/TestMiInterpreterExec.py)
> >> UNEXPECTED SUCCESS: test_multiple_debuggers_dwarf
> >> (api/multiple-debuggers/TestMultipleDebuggers.py)
> >> UNEXPECTED SUCCESS: test_process_interrupt_dwo
> >> (functionalities/thread/state/TestThreadStates.py)
> >> UNEXPECTED SUCCESS: test_sb_api_listener_resume_dwarf
> >> (api/multithreaded/TestMultithreaded.py)
> >> UNEXPECTED SUCCESS: test_sb_api_listener_resume_dwo
> >> (api/multithreaded/TestMultithreaded.py)
> >> UNEXPECTED SUCCESS: test_with_dwarf (lang/cpp/printf/TestPrintf.py)
> >> UNEXPECTED SUCCESS: test_with_dwo (lang/cpp/printf/TestPrintf.py)
> >>
> >> ===
> >> Test Result Summary
> >> ===
> >> Test Methods:   1905
> >> Reruns:0
> >> Success:1203
> >> Expected Failure:117
> >> Failure:   0
> >> Error: 0
> >> Exceptional Exit:  0
> >> Unexpected Success:   13
> >> Skip:572
> >> Timeout:   0
> >> Expected Timeout:  0
> >>
> >> I can't seem to run unittests because I'm getting undefined references
> to
> >> editline which I haven't dug into, but the regular tests pass.
> >>
> >> On Tue, Mar 7, 2017 at 1:47 PM Pavel Labath via Phabricator
> >>  wrote:
> >>>
> >>> labath accepted this revision.
> >>> labath added a comment.
> >>> This revision is now accepted and ready to land.
> >>>
> >>> OK, let's give this another shot. (I haven't tried it on linux yet, so
> if
> >>> you haven't either then let's wait until tomorrow, or maybe @eugene
> could
> >>> try it out (?)). I don't think we need to be worried about symlink
> overwrite
> >>> in the ModuleCache test.
> >>>
> >>>
> >>>
> >>> 
> >>> Comment at: llvm/include/llvm/Support/FileSystem.h:500
> >>> +/// @param result Set to true if \a path is a directory (after
> following
> >>> +///   symlinks, false if it is not. Undefined otherwise.
> >>>  /// @returns errc::success if result has been successfully set,
> >>> otherwise a
> >>> 
> >>> missing closing paren here
> >>>
> >>>
> >>> https://reviews.llvm.org/D30698
> >>>
> >>>
> >>>
> >
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r297279 - Android.rules: fix computation of gcc toolchain directory on arm

2017-03-08 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Mar  8 08:57:15 2017
New Revision: 297279

URL: http://llvm.org/viewvc/llvm-project?rev=297279&view=rev
Log:
Android.rules: fix computation of gcc toolchain directory on arm

The toolchain directory for arm android targets was computed
incorrectly. The architecture part should be arm, and the environment
part androideabi. This fixes that.

Modified:
lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules?rev=297279&r1=297278&r2=297279&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Android.rules Wed Mar  8 
08:57:15 2017
@@ -14,34 +14,36 @@ endif
 ifeq "$(ARCH)" "arm"
SYSROOT_ARCH := arm
STL_ARCH := armeabi-v7a
-   TRIPLE_ARCH := armv7
+   TRIPLE := armv7-none-linux-androideabi
ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm
 else ifeq "$(ARCH)" "aarch64"
SYSROOT_ARCH := arm64
-   TRIPLE_ARCH := aarch64
+   TRIPLE := aarch64-none-linux-android
STL_ARCH := arm64-v8a
 else ifeq "$(ARCH)" "i386"
SYSROOT_ARCH := x86
STL_ARCH := x86
-   TRIPLE_ARCH := i686
+   TRIPLE := i686-none-linux-android
 else ifeq "$(ARCH)" "mips64r6"
SYSROOT_ARCH := mips64
STL_ARCH := mips64
-   TRIPLE_ARCH := mips64el
+   TRIPLE := mips64el-none-linux-android
 else ifeq "$(ARCH)" "mips32"
SYSROOT_ARCH := mips
STL_ARCH := mips
-   TRIPLE_ARCH := mipsel
+   TRIPLE := mipsel-none-linux-android
 else
SYSROOT_ARCH := $(ARCH)
STL_ARCH := $(ARCH)
-   TRIPLE_ARCH := $(ARCH)
+   TRIPLE := $(ARCH)-none-linux-android
 endif
 
 ifeq "$(findstring 86,$(ARCH))" "86"
TOOLCHAIN_DIR := $(STL_ARCH)-4.9
+else ifeq "$(ARCH)" "arm"
+   TOOLCHAIN_DIR := arm-linux-androideabi-4.9
 else
-   TOOLCHAIN_DIR := $(TRIPLE_ARCH)-linux-android-4.9
+   TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9
 endif
 
 ifeq "$(HOST_OS)" "Linux"
@@ -53,11 +55,9 @@ else
 endif
 
 ifeq "$(findstring clang,$(CC))" "clang"
-   ARCH_CFLAGS += \
-   -target $(TRIPLE_ARCH)-none-linux-android \
+   ARCH_CFLAGS += -target $(TRIPLE) \
-gcc-toolchain 
$(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
-   ARCH_LDFLAGS += \
-   -target $(TRIPLE_ARCH)-none-linux-android \
+   ARCH_LDFLAGS += -target $(TRIPLE) \
-gcc-toolchain 
$(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
 endif
 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D30737: Android.rules: Add libc++ support

2017-03-08 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
Herald added a subscriber: srhines.
Herald added a reviewer: EricWF.

This adds support for building libc++ tests when targetting android. The
tests are still not passing due to several other problems, but this way
we can at least build them.


https://reviews.llvm.org/D30737

Files:
  packages/Python/lldbsuite/test/make/Android.rules
  packages/Python/lldbsuite/test/make/Makefile.rules


Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -324,15 +324,19 @@
 ifeq (1,$(USE_LIBCPP))
# Clang requires an extra flag: -stdlib=libstdc++
ifneq (,$(findstring clang,$(CC)))
+   CXXFLAGS += -DLLDB_USING_LIBCPP
ifeq "$(OS)" "Linux"
# This is the default install location on Ubuntu 14.04
ifneq ($(wildcard /usr/include/c++/v1/.),)
-   CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
+   CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
CXXFLAGS += -I/usr/include/c++/v1
endif
+   else ifeq "$(OS)" "Android"
+   # Nothing to do, this is already handled in
+   # Android.rules.
else
-   CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
+   CXXFLAGS += -stdlib=libc++
LDFLAGS += -stdlib=libc++
endif
endif
Index: packages/Python/lldbsuite/test/make/Android.rules
===
--- packages/Python/lldbsuite/test/make/Android.rules
+++ packages/Python/lldbsuite/test/make/Android.rules
@@ -61,11 +61,23 @@
-gcc-toolchain 
$(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
 endif
 
-ARCH_CFLAGS += \
-   
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
-   -isystem 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
-   -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
-ARCH_LDFLAGS += -lm \
-   
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
 \
-   
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)
+ARCH_CFLAGS += 
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)
+ARCH_LDFLAGS += 
--sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm
+
+ifeq (1,$(USE_LIBCPP))
+   ARCH_CFLAGS += \
+   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \
+   -isystem $(NDK_ROOT)/sources/android/support/include \
+   -isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include
+
+   ARCH_LDFLAGS += \
+   -L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \
+   
-l$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++.a
+else
+   ARCH_CFLAGS += \
+   -isystem $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include \
+   -isystem 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/include \
+   -isystem 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
+
+   ARCH_LDFLAGS += 
$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.9/libs/$(STL_ARCH)/libgnustl_static.a
+endif


Index: packages/Python/lldbsuite/test/make/Makefile.rules
===
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -324,15 +324,19 @@
 ifeq (1,$(USE_LIBCPP))
 	# Clang requires an extra flag: -stdlib=libstdc++
 	ifneq (,$(findstring clang,$(CC)))
+		CXXFLAGS += -DLLDB_USING_LIBCPP
 		ifeq "$(OS)" "Linux"
 			# This is the default install location on Ubuntu 14.04
 			ifneq ($(wildcard /usr/include/c++/v1/.),)
-CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
+CXXFLAGS += -stdlib=libc++
 LDFLAGS += -stdlib=libc++
 CXXFLAGS += -I/usr/include/c++/v1
 			endif
+		else ifeq "$(OS)" "Android"
+			# Nothing to do, this is already handled in
+			# Android.rules.
 		else
-			CXXFLAGS += -stdlib=libc++ -DLLDB_USING_LIBCPP
+			CXXFLAGS += -stdlib=libc++
 			LDFLAGS += -stdlib=libc++
 		endif
 	endif
Index: packages/Python/lldbsuite/test/make/Android.rules
===
--- packages/Python/lldbsuite/test/make/Android.rules
+++ packages/Python/lldbsuite/test/make/Android.rules
@@ -61,11 +61,23 @@
 		-gcc-toolchain $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG)
 endif
 
-ARCH_CFLAGS += \
-	--sysroot=$(NDK_ROOT)

[Lldb-commits] [PATCH] D30698: Resubmit "Use LLVM for all stat related calls"

2017-03-08 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL297300: Resubmit FileSystem changes. (authored by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D30698?vs=90905&id=91044#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30698

Files:
  lldb/trunk/include/lldb/Host/FileSpec.h
  lldb/trunk/include/lldb/Utility/Error.h
  lldb/trunk/source/API/SBPlatform.cpp
  lldb/trunk/source/Commands/CommandCompletions.cpp
  lldb/trunk/source/Commands/CommandObjectTarget.cpp
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/FileSpecList.cpp
  lldb/trunk/source/Core/Module.cpp
  lldb/trunk/source/Core/ModuleList.cpp
  lldb/trunk/source/Core/PluginManager.cpp
  lldb/trunk/source/Host/common/FileSpec.cpp
  lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
  lldb/trunk/source/Host/common/Symbols.cpp
  lldb/trunk/source/Host/macosx/Host.mm
  lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
  lldb/trunk/source/Host/macosx/Symbols.cpp
  lldb/trunk/source/Host/posix/FileSystem.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
  lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
  lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
  lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/trunk/source/Target/ModuleCache.cpp
  lldb/trunk/source/Target/Platform.cpp
  lldb/trunk/source/Target/TargetList.cpp
  lldb/trunk/source/Utility/Error.cpp
  llvm/trunk/include/llvm/Support/FileSystem.h
  llvm/trunk/lib/Support/Path.cpp

Index: lldb/trunk/include/lldb/Host/FileSpec.h
===
--- lldb/trunk/include/lldb/Host/FileSpec.h
+++ lldb/trunk/include/lldb/Host/FileSpec.h
@@ -22,6 +22,7 @@
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/Triple.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatVariadic.h"
 
 namespace lldb_private {
@@ -46,17 +47,6 @@
 //--
 class FileSpec {
 public:
-  typedef enum FileType {
-eFileTypeInvalid = -1,
-eFileTypeUnknown = 0,
-eFileTypeDirectory,
-eFileTypePipe,
-eFileTypeRegular,
-eFileTypeSocket,
-eFileTypeSymbolicLink,
-eFileTypeOther
-  } FileType;
-
   enum PathSyntax {
 ePathSyntaxPosix,
 ePathSyntaxWindows,
@@ -455,8 +445,6 @@
   //--
   ConstString GetFileNameStrippingExtension() const;
 
-  FileType GetFileType() const;
-
   //--
   /// Return the current permissions of the path.
   ///
@@ -471,20 +459,6 @@
   //--
   uint32_t GetPermissions() const;
 
-  bool IsDirectory() const {
-return GetFileType() == FileSpec::eFileTypeDirectory;
-  }
-
-  bool IsPipe() const { return GetFileType() == FileSpec::eFileTypePipe; }
-
-  bool IsRegularFile() const {
-return GetFileType() == FileSpec::eFileTypeRegular;
-  }
-
-  bool IsSocket() const { return GetFileType() == FileSpec::eFileTypeSocket; }
-
-  bool IsSymbolicLink() const;
-
   //--
   /// Get the memory cost of this object.
   ///
@@ -596,16 +570,16 @@
   };
 
   typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
-  void *baton, FileType file_type, const FileSpec &spec);
+  void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec);
 
   static EnumerateDirectoryResult
   EnumerateDirectory(llvm::StringRef dir_path, bool find_directories,
  bool find_files, bool find_other,
  EnumerateDirectoryCallbackType callback,
  void *callback_baton);
 
-  typedef std::function
+  typedef std::function
   DirectoryCallback;
 
   static EnumerateDir

[Lldb-commits] [lldb] r297300 - Resubmit FileSystem changes.

2017-03-08 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Wed Mar  8 11:56:08 2017
New Revision: 297300

URL: http://llvm.org/viewvc/llvm-project?rev=297300&view=rev
Log:
Resubmit FileSystem changes.

This was originall reverted due to some test failures in
ModuleCache and TestCompDirSymlink.  These issues have all
been resolved and the code now passes all tests.

Differential Revision: https://reviews.llvm.org/D30698

Modified:
lldb/trunk/include/lldb/Host/FileSpec.h
lldb/trunk/include/lldb/Utility/Error.h
lldb/trunk/source/API/SBPlatform.cpp
lldb/trunk/source/Commands/CommandCompletions.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/FileSpecList.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
lldb/trunk/source/Host/common/Symbols.cpp
lldb/trunk/source/Host/macosx/Host.mm
lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
lldb/trunk/source/Host/macosx/Symbols.cpp
lldb/trunk/source/Host/posix/FileSystem.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Target/ModuleCache.cpp
lldb/trunk/source/Target/Platform.cpp
lldb/trunk/source/Target/TargetList.cpp
lldb/trunk/source/Utility/Error.cpp

Modified: lldb/trunk/include/lldb/Host/FileSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=297300&r1=297299&r2=297300&view=diff
==
--- lldb/trunk/include/lldb/Host/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Host/FileSpec.h Wed Mar  8 11:56:08 2017
@@ -22,6 +22,7 @@
 #include "lldb/lldb-private.h"
 
 #include "llvm/ADT/Triple.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatVariadic.h"
 
 namespace lldb_private {
@@ -46,17 +47,6 @@ namespace lldb_private {
 //--
 class FileSpec {
 public:
-  typedef enum FileType {
-eFileTypeInvalid = -1,
-eFileTypeUnknown = 0,
-eFileTypeDirectory,
-eFileTypePipe,
-eFileTypeRegular,
-eFileTypeSocket,
-eFileTypeSymbolicLink,
-eFileTypeOther
-  } FileType;
-
   enum PathSyntax {
 ePathSyntaxPosix,
 ePathSyntaxWindows,
@@ -455,8 +445,6 @@ public:
   //--
   ConstString GetFileNameStrippingExtension() const;
 
-  FileType GetFileType() const;
-
   //--
   /// Return the current permissions of the path.
   ///
@@ -471,20 +459,6 @@ public:
   //--
   uint32_t GetPermissions() const;
 
-  bool IsDirectory() const {
-return GetFileType() == FileSpec::eFileTypeDirectory;
-  }
-
-  bool IsPipe() const { return GetFileType() == FileSpec::eFileTypePipe; }
-
-  bool IsRegularFile() const {
-return GetFileType() == FileSpec::eFileTypeRegular;
-  }
-
-  bool IsSocket() const { return GetFileType() == FileSpec::eFileTypeSocket; }
-
-  bool IsSymbolicLink() const;
-
   //--
   /// Get the memory cost of this object.
   ///
@@ -596,7 +570,7 @@ public:
   };
 
   typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)(
-  void *baton, FileType file_type, const FileSpec &spec);
+  void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec);
 
   static EnumerateDirectoryResult
   EnumerateDirecto

[Lldb-commits] [PATCH] D30702: Fix remaining threading issues in Log.h

2017-03-08 Thread Zachary Turner via Phabricator via lldb-commits
zturner accepted this revision.
zturner added inline comments.



Comment at: source/Utility/Log.cpp:82
+  if (mask | flags) {
+m_options.store(options, std::memory_order_release);
+m_stream_sp = stream_sp;

Might as well use `memory_order_relaxed` here.



Comment at: unittests/Utility/LogTest.cpp:16
 #include "llvm/Support/Threading.h"
+#include 
 #include 

Is this included needed?


https://reviews.llvm.org/D30702



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r297360 - Remove LLDB's recursive directory deletion function.

2017-03-08 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Wed Mar  8 23:12:36 2017
New Revision: 297360

URL: http://llvm.org/viewvc/llvm-project?rev=297360&view=rev
Log:
Remove LLDB's recursive directory deletion function.

LLVM now has such a function, so we use that instead.

Modified:
lldb/trunk/include/lldb/Host/FileSystem.h
lldb/trunk/source/Host/common/HostInfoBase.cpp
lldb/trunk/source/Host/posix/FileSystem.cpp
lldb/trunk/source/Host/windows/FileSystem.cpp
lldb/trunk/source/Target/ModuleCache.cpp

Modified: lldb/trunk/include/lldb/Host/FileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=297360&r1=297359&r2=297360&view=diff
==
--- lldb/trunk/include/lldb/Host/FileSystem.h (original)
+++ lldb/trunk/include/lldb/Host/FileSystem.h Wed Mar  8 23:12:36 2017
@@ -29,7 +29,6 @@ public:
   static FileSpec::PathSyntax GetNativePathSyntax();
 
   static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
-  static Error DeleteDirectory(const FileSpec &file_spec, bool recurse);
 
   static Error GetFilePermissions(const FileSpec &file_spec,
   uint32_t &file_permissions);

Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=297360&r1=297359&r2=297360&view=diff
==
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Wed Mar  8 23:12:36 2017
@@ -46,7 +46,7 @@ struct HostInfoBaseFields {
   // Remove the LLDB temporary directory if we have one. Set "recurse" to
   // true to all files that were created for the LLDB process can be 
cleaned
   // up.
-  FileSystem::DeleteDirectory(m_lldb_process_tmp_dir, true);
+  llvm::sys::fs::remove_directories(m_lldb_process_tmp_dir.GetPath());
 }
   }
 

Modified: lldb/trunk/source/Host/posix/FileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/FileSystem.cpp?rev=297360&r1=297359&r2=297360&view=diff
==
--- lldb/trunk/source/Host/posix/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/posix/FileSystem.cpp Wed Mar  8 23:12:36 2017
@@ -73,58 +73,6 @@ Error FileSystem::MakeDirectory(const Fi
   return Error("empty path");
 }
 
-Error FileSystem::DeleteDirectory(const FileSpec &file_spec, bool recurse) {
-  Error error;
-  if (file_spec) {
-if (recurse) {
-  // Save all sub directories in a list so we don't recursively call this
-  // function
-  // and possibly run out of file descriptors if the directory is too deep.
-  std::vector sub_directories;
-
-  FileSpec::ForEachItemInDirectory(
-  file_spec.GetCString(),
-  [&error, &sub_directories](
-  llvm::sys::fs::file_type ft,
-  const FileSpec &spec) -> FileSpec::EnumerateDirectoryResult {
-if (ft == llvm::sys::fs::file_type::directory_file) {
-  // Save all directorires and process them after iterating through
-  // this directory
-  sub_directories.push_back(spec);
-} else {
-  // Update sub_spec to point to the current file and delete it
-  error = FileSystem::Unlink(spec);
-}
-// If anything went wrong, stop iterating, else process the next
-// file
-if (error.Fail())
-  return FileSpec::eEnumerateDirectoryResultQuit;
-else
-  return FileSpec::eEnumerateDirectoryResultNext;
-  });
-
-  if (error.Success()) {
-// Now delete all sub directories with separate calls that aren't
-// recursively calling into this function _while_ this function is
-// iterating through the current directory.
-for (const auto &sub_directory : sub_directories) {
-  error = DeleteDirectory(sub_directory, recurse);
-  if (error.Fail())
-break;
-}
-  }
-}
-
-if (error.Success()) {
-  if (::rmdir(file_spec.GetCString()) != 0)
-error.SetErrorToErrno();
-}
-  } else {
-error.SetErrorString("empty path");
-  }
-  return error;
-}
-
 Error FileSystem::GetFilePermissions(const FileSpec &file_spec,
  uint32_t &file_permissions) {
   Error error;

Modified: lldb/trunk/source/Host/windows/FileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/FileSystem.cpp?rev=297360&r1=297359&r2=297360&view=diff
==
--- lldb/trunk/source/Host/windows/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/windows/FileSystem.cpp Wed Mar  8 23:12:36 2017
@@ -45,40 +45,6 @@ Error FileSystem::Mak