[Lldb-commits] [PATCH] D20224: Unbreak build on NetBSD-7.0

2016-05-12 Thread Kamil Rytarowski via lldb-commits
krytarowski created this revision.
krytarowski added reviewers: joerg, emaste, clayborg.
krytarowski added a subscriber: lldb-commits.
krytarowski set the repository for this revision to rL LLVM.

NetBSD 7.0 ships with too old libstdc++ and it lacks .

It's no longer true in the current version -- it has been tested with 7.99.28.

This arbitrary value is an temporary version just to retain building on 7.0 and 
head for fully functional NetBSD-8.0.

Repository:
  rL LLVM

http://reviews.llvm.org/D20224

Files:
  include/lldb/Host/Editline.h

Index: include/lldb/Host/Editline.h
===
--- include/lldb/Host/Editline.h
+++ include/lldb/Host/Editline.h
@@ -23,6 +23,15 @@
 
 #ifndef liblldb_Editline_h_
 #define liblldb_Editline_h_
+
+#if defined(__NetBSD__)
+#include 
+#if __NetBSD_Prereq__(7,99,28)
+#define NETBSD_USE_WCHAR
+#endif
+#endif
+
+
 #if defined(__cplusplus)
 
 #include 
@@ -32,7 +41,7 @@
 // components needed to handle wide characters ( , codecvt_utf8, 
libedit built with '--enable-widec' )
 // are available on some platforms. The wchar_t versions of libedit functions 
will only be
 // used in cases where this is true.  This is a compile time dependecy, for 
now selected per target Platform
-#if defined (__APPLE__) || defined(__NetBSD__)
+#if defined (__APPLE__) || defined(NETBSD_USE_WCHAR)
 #define LLDB_EDITLINE_USE_WCHAR 1
 #include 
 #else


Index: include/lldb/Host/Editline.h
===
--- include/lldb/Host/Editline.h
+++ include/lldb/Host/Editline.h
@@ -23,6 +23,15 @@
 
 #ifndef liblldb_Editline_h_
 #define liblldb_Editline_h_
+
+#if defined(__NetBSD__)
+#include 
+#if __NetBSD_Prereq__(7,99,28)
+#define NETBSD_USE_WCHAR
+#endif
+#endif
+
+
 #if defined(__cplusplus)
 
 #include 
@@ -32,7 +41,7 @@
 // components needed to handle wide characters ( , codecvt_utf8, libedit built with '--enable-widec' )
 // are available on some platforms. The wchar_t versions of libedit functions will only be
 // used in cases where this is true.  This is a compile time dependecy, for now selected per target Platform
-#if defined (__APPLE__) || defined(__NetBSD__)
+#if defined (__APPLE__) || defined(NETBSD_USE_WCHAR)
 #define LLDB_EDITLINE_USE_WCHAR 1
 #include 
 #else
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r269377 - Fix some long standing issues that caused tests to be flaky.

2016-05-12 Thread Jim Ingham via lldb-commits

> On May 12, 2016, at 3:58 PM, Greg Clayton via lldb-commits 
>  wrote:
> 
> +class EventDataReceipt : public EventData
> +{
> +public:
> +EventDataReceipt() :
> +EventData(),
> +m_predicate(false)
> +{
> +}
> +
> +~EventDataReceipt() override
> +{
> +}
> +
> +static const ConstString &
> +GetFlavorString ()
> +{
> +static ConstString g_flavor("Process::ProcessEventData");
> +return g_flavor;
> +}


I don't think it is a good idea to have this general EventDataReciept claim to 
be a ProcessEventData.

> +
> +const ConstString &
> +GetFlavor () const override
> +{
> +return GetFlavorString();
> +}
> +
> +bool
> +WaitForEventReceived (const TimeValue *abstime = nullptr, bool 
> *timed_out = nullptr)
> +{
> +return m_predicate.WaitForValueEqualTo(true, abstime, timed_out);
> +}
> +
> +private:
> +Predicate m_predicate;
> +
> +void
> +DoOnRemoval (Event *event_ptr)  override
> +{
> +m_predicate.SetValue(true, eBroadcastAlways);
> +}
> +};
> +

Jim

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


[Lldb-commits] [lldb] r269378 - Add a check for version 15 of the shared cache format

2016-05-12 Thread Enrico Granata via lldb-commits
Author: enrico
Date: Thu May 12 18:04:43 2016
New Revision: 269378

URL: http://llvm.org/viewvc/llvm-project?rev=269378&view=rev
Log:
Add a check for version 15 of the shared cache format




Modified:

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=269378&r1=269377&r2=269378&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 Thu May 12 18:04:43 2016
@@ -241,7 +241,7 @@ __lldb_apple_objc_v2_get_shared_cache_cl
 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", 
objc_opt->headeropt_offset);
 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", 
objc_opt->clsopt_offset);
 }
-if (objc_opt->version == 12 || objc_opt->version == 13 || 
objc_opt->version == 14)
+if (objc_opt->version == 12 || objc_opt->version == 13 || 
objc_opt->version == 14 || objc_opt->version == 15)
 {
 const objc_clsopt_t* clsopt = NULL;
 if (is_v14_format)


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


[Lldb-commits] [lldb] r269377 - Fix some long standing issues that caused tests to be flaky.

2016-05-12 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Thu May 12 17:58:52 2016
New Revision: 269377

URL: http://llvm.org/viewvc/llvm-project?rev=269377&view=rev
Log:
Fix some long standing issues that caused tests to be flaky. 

The main issues were:
- Listeners recently were converted over to used by getting a shared pointer to 
a listener. And when they listened to broadcasters they would get a strong 
reference added to them meaning the listeners would never go away. This caused 
memory usage to increase and would cause performance issue if many steps were 
done.
- The lldb_private::Process private state thread had an issue where if a "stop" 
contol signal was attempted to be sent to that thread, it could end up not 
responding in 2 seconds and end up getting cancelled which might cause us to 
cancel a thread that had a mutex locked and it would deadlock the test.

This change makes broadcasters hold onto weak references to listeners. It also 
fixes some bad threading code that had races inside of it by making the 
m_events_mutex be non-recursive and getting rid of fragile use of a 
Predicate to say that new events are available, and replacing it with 
using the m_events_mutex with a new m_events_condition to control access to the 
events in a safer way.

The private state thread now uses a safer way to communicate that the control 
event has been received by the private state thread: it makes a 
EventDataReceipt instance that it attaches to the event that sends the control 
to the private state thread and used this to synchronize the fact that the 
private state thread has received the event instead of using a Predicate 
to convey the info. When the signal event is received, it will pull the event 
off of the queue in the private state thread and cause the 
EventData::DoOnRemoval() to be called, which will signal that the event has 
been received. This cleans up the signal delivery notification so it doesn't 
rely on a member variable of the process class to convey the info.

std::shared_ptr event_receipt_sp(new EventDataReceipt());
m_private_state_control_broadcaster.BroadcastEvent(signal, event_receipt_sp);

 Listeners are being kept around longer than they 
should be due to recent changs
 Private process state thread can be cancelled and 
cause deadlocks in test suite


Modified:
lldb/trunk/include/lldb/Core/Broadcaster.h
lldb/trunk/include/lldb/Core/Event.h
lldb/trunk/include/lldb/Core/Listener.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Core/Broadcaster.cpp
lldb/trunk/source/Core/Event.cpp
lldb/trunk/source/Core/Listener.cpp
lldb/trunk/source/Host/posix/HostThreadPosix.cpp
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/include/lldb/Core/Broadcaster.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Broadcaster.h?rev=269377&r1=269376&r2=269377&view=diff
==
--- lldb/trunk/include/lldb/Core/Broadcaster.h (original)
+++ lldb/trunk/include/lldb/Core/Broadcaster.h Thu May 12 17:58:52 2016
@@ -12,6 +12,8 @@
 
 // C Includes
 // C++ Includes
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -99,10 +101,10 @@ public:
 ~BroadcasterManager() = default;
 
 uint32_t
-RegisterListenerForEvents (lldb::ListenerSP listener_sp, 
BroadcastEventSpec event_spec);
+RegisterListenerForEvents (const lldb::ListenerSP &listener_sp, 
BroadcastEventSpec event_spec);
 
 bool
-UnregisterListenerForEvents (lldb::ListenerSP listener_sp, 
BroadcastEventSpec event_spec);
+UnregisterListenerForEvents (const lldb::ListenerSP &listener_sp, 
BroadcastEventSpec event_spec);
 
 lldb::ListenerSP
 GetListenerForEventSpec (BroadcastEventSpec event_spec) const;
@@ -111,7 +113,7 @@ public:
 SignUpListenersForBroadcaster (Broadcaster &broadcaster);
 
 void
-RemoveListener (lldb::ListenerSP listener_sp);
+RemoveListener (const lldb::ListenerSP &listener_sp);
 
 void
 RemoveListener (Listener *listener);
@@ -170,8 +172,7 @@ private:
 class ListenerMatchesAndSharedBits
 {
 public:
-ListenerMatchesAndSharedBits (BroadcastEventSpec broadcaster_spec, 
-   const lldb::ListenerSP 
listener_sp) :
+explicit ListenerMatchesAndSharedBits (BroadcastEventSpec 
broadcaster_spec, const lldb::ListenerSP listener_sp) :
 m_broadcaster_spec (broadcaster_spec),
 m_listener_sp (listener_sp)
 {
@@ -194,7 +195,7 @@ private:
 class ListenerMatches
 {
 public:
-ListenerMatches (const lldb::ListenerSP in_listener_sp) :
+explicit ListenerMatches (const lldb::ListenerSP in_listener_sp) :
 m_listener_sp (in_listener_sp)
 {
 }
@@ -331,6 +332,12 @@ public:
 }
 
 void
+BroadcastEvent(uint32_t event_type, const lldb::EventDataSP &event_data_sp)
+{

Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Cameron via lldb-commits
I added the makefile with r269366. The tests seem to be working now:
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/14641
Sorry about that!

On Thu, May 12, 2016 at 6:07 PM, Cameron  wrote:

> Thanks Jim, I'll definitely use that as a template next time!
>
> Ah, I think I found the problem with the test. The makefile was in the
> patch but wasn't committed. Trying that out now.
>
> On Thu, May 12, 2016 at 5:45 PM, Jim Ingham  wrote:
>
>>
>> > On May 12, 2016, at 2:25 PM, Cameron  wrote:
>> >
>> > Sorry to break the build! Apparently 'make clean' isn't executing
>> cleanly during the build step of the test, but I haven't the faintest idea
>> why. It builds/runs fine locally for me (then again, I'm on Windows). The
>> makefile is dead simple, and is identical to that of some other tests. Has
>> anyone seen something like this before?
>> >
>> > Ah, I would have written a test using the APIs if I knew. I didn't see
>> any other similar tests that set up LLDB from scratch without going through
>> the command line. For reference, can you point me to one of these tests I
>> can use as an example for the next time?
>>
>> expression_command/fixits/TestFixIts.py is one.  It makes a target, runs
>> it hits breakpoints and does some other stuff.  Most of the Python API
>> tests start by creating the target in Python - whereas the command-line
>> tests tend to use the file command.  So you can find lots of examples by
>> searching for the string "self.dbg.CreateTarget" in all the .py files.
>>
>> Jim
>>
>> >
>> > On Thu, May 12, 2016 at 5:17 PM, Jim Ingham  wrote:
>> > Note that while adding a "expr --allow-jit" flag to control this was
>> great, there already was an SBExpressionOptions option and the appropriate
>> flags available for this, so it was testable.  I was just checking because
>> there really shouldn't be anything we can do from a command that we can't
>> do from the SB API's, but in this case the thing was already in the
>> expression options.
>> >
>> > We do prefer not to write tests with the command line when you can do
>> it with the Python API's.  In our experience, command line tests have
>> tended to be more fragile.  It's not necessary to change the test, there
>> are plenty of other command line tests lying around.  Just for future
>> reference...
>> >
>> > Jim
>> >
>> > > On May 9, 2016, at 1:01 PM, Sean Callanan via lldb-commits <
>> lldb-commits@lists.llvm.org> wrote:
>> > >
>> > > spyffe accepted this revision.
>> > > spyffe added a comment.
>> > > This revision is now accepted and ready to land.
>> > >
>> > > This patch is fine.  I especially appreciate the time you took making
>> the IRInterpreter properly testable.  I will use this myself.
>> > >
>> > >
>> > > 
>> > > Comment at: source/Commands/CommandObjectExpression.cpp:67
>> > > @@ -67,1 +66,3 @@
>> > > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",
>> 'p', OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,
>>  "Interpret the expression as top-level definitions rather than code to be
>> immediately executed."},
>> > > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit",
>> 'j', OptionParser::eRequiredArgument, nullptr, nullptr, 0,
>> eArgTypeBoolean,"Controls whether the expression can fall back to being
>> JITted if it's not supported by the interpreter (defaults to true)."}
>> > > };
>> > > 
>> > > This is a great feature which I will use in test cases.
>> > >
>> > > 
>> > > Comment at: source/Expression/IRInterpreter.cpp:1102
>> > > @@ -1058,1 +1101,3 @@
>> > > +}
>> > > +break;
>> > > case Instruction::GetElementPtr:
>> > > 
>> > > Looks all right to me.  Thank you!
>> > >
>> > >
>> > > http://reviews.llvm.org/D19124
>> > >
>> > >
>> > >
>> > > ___
>> > > lldb-commits mailing list
>> > > lldb-commits@lists.llvm.org
>> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>> >
>> >
>>
>>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r269373 - Don't crash when a process' task port goes bad.

2016-05-12 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Thu May 12 17:36:47 2016
New Revision: 269373

URL: http://llvm.org/viewvc/llvm-project?rev=269373&view=rev
Log:
Don't crash when a process' task port goes bad.




Modified:
lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp?rev=269373&r1=269372&r2=269373&view=diff
==
--- lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Thu May 12 
17:36:47 2016
@@ -436,7 +436,6 @@ MachException::Message::Reply(MachProces
 if (state.task_port == process->Task().TaskPort())
 {
 DNBLogThreaded("error: mach_msg() returned an error when 
replying to a mach exception: error = %u", err.Error());
-abort ();
 }
 else
 {


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


[Lldb-commits] [lldb] r269372 - Fix libstdc++ failure where is not able to be imported on Darwin systems.

2016-05-12 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Thu May 12 17:33:02 2016
New Revision: 269372

URL: http://llvm.org/viewvc/llvm-project?rev=269372&view=rev
Log:
Fix libstdc++ failure where  is not able to be imported on Darwin 
systems.

The adding of  to test_common.h broke 12 tests on Darwin. We work 
around this by not including  when building on darwin for libstdc++ 
tests.


Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile
lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile?rev=269372&r1=269371&r2=269372&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-skip-summary/Makefile
 Thu May 12 17:33:02 2016
@@ -1,6 +1,7 @@
 LEVEL = ../../../make
 
 CXX_SOURCES := main.cpp
+USE_LIBSTDCPP := 1
 
 # clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD 
 # targets.  Other targets do not, which causes this test to fail.
@@ -12,8 +13,3 @@ endif
 include $(LEVEL)/Makefile.rules
 
 CXXFLAGS += -O0
-
-ifeq (,$(findstring gcc,$(CC)))
-CXXFLAGS += -stdlib=libstdc++
-LDFLAGS += -stdlib=libstdc++
-endif

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=269372&r1=269371&r2=269372&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Thu May 12 
17:33:02 2016
@@ -306,7 +306,7 @@ endif
 ifeq (1,$(USE_LIBSTDCPP))
# Clang requires an extra flag: -stdlib=libstdc++
ifneq (,$(findstring clang,$(CC)))
-   CXXFLAGS += -stdlib=libstdc++
+   CXXFLAGS += -stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP
LDFLAGS += -stdlib=libstdc++
endif
 endif

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h?rev=269372&r1=269371&r2=269372&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/test_common.h Thu May 12 
17:33:02 2016
@@ -43,6 +43,13 @@
 
 #endif
 
+#if defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP)  
+
+// on Darwin, libstdc++ is missing , so this would cause any test to 
fail building
+// since this header file is being included in every C-family test case, we 
need to not include it
+// on Darwin, most tests use libc++ by default, so this will only affect tests 
that explicitly require libstdc++
+
+#else
 #ifdef __cplusplus
 #include 
 
@@ -65,3 +72,4 @@ typedef std::atomic pseudo_barrier_
 (barrier) = (count);\
 } while (0)
 #endif // __cplusplus
+#endif // defined(__APPLE__) && defined(LLDB_USING_LIBSTDCPP)


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


[Lldb-commits] [lldb] r269366 - Added missing makefile from patch D19124 (should fix the corresponding commit rL269340)

2016-05-12 Thread Cameron Desrochers via lldb-commits
Author: cameron314
Date: Thu May 12 17:10:16 2016
New Revision: 269366

URL: http://llvm.org/viewvc/llvm-project?rev=269366&view=rev
Log:
Added missing makefile from patch D19124 (should fix the corresponding commit 
rL269340)

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/Makefile

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/Makefile?rev=269366&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/Makefile
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/Makefile
 Thu May 12 17:10:16 2016
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules


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


Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Cameron via lldb-commits
Thanks Jim, I'll definitely use that as a template next time!

Ah, I think I found the problem with the test. The makefile was in the
patch but wasn't committed. Trying that out now.

On Thu, May 12, 2016 at 5:45 PM, Jim Ingham  wrote:

>
> > On May 12, 2016, at 2:25 PM, Cameron  wrote:
> >
> > Sorry to break the build! Apparently 'make clean' isn't executing
> cleanly during the build step of the test, but I haven't the faintest idea
> why. It builds/runs fine locally for me (then again, I'm on Windows). The
> makefile is dead simple, and is identical to that of some other tests. Has
> anyone seen something like this before?
> >
> > Ah, I would have written a test using the APIs if I knew. I didn't see
> any other similar tests that set up LLDB from scratch without going through
> the command line. For reference, can you point me to one of these tests I
> can use as an example for the next time?
>
> expression_command/fixits/TestFixIts.py is one.  It makes a target, runs
> it hits breakpoints and does some other stuff.  Most of the Python API
> tests start by creating the target in Python - whereas the command-line
> tests tend to use the file command.  So you can find lots of examples by
> searching for the string "self.dbg.CreateTarget" in all the .py files.
>
> Jim
>
> >
> > On Thu, May 12, 2016 at 5:17 PM, Jim Ingham  wrote:
> > Note that while adding a "expr --allow-jit" flag to control this was
> great, there already was an SBExpressionOptions option and the appropriate
> flags available for this, so it was testable.  I was just checking because
> there really shouldn't be anything we can do from a command that we can't
> do from the SB API's, but in this case the thing was already in the
> expression options.
> >
> > We do prefer not to write tests with the command line when you can do it
> with the Python API's.  In our experience, command line tests have tended
> to be more fragile.  It's not necessary to change the test, there are
> plenty of other command line tests lying around.  Just for future
> reference...
> >
> > Jim
> >
> > > On May 9, 2016, at 1:01 PM, Sean Callanan via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> > >
> > > spyffe accepted this revision.
> > > spyffe added a comment.
> > > This revision is now accepted and ready to land.
> > >
> > > This patch is fine.  I especially appreciate the time you took making
> the IRInterpreter properly testable.  I will use this myself.
> > >
> > >
> > > 
> > > Comment at: source/Commands/CommandObjectExpression.cpp:67
> > > @@ -67,1 +66,3 @@
> > > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",
> 'p', OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,
>  "Interpret the expression as top-level definitions rather than code to be
> immediately executed."},
> > > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit",
> 'j', OptionParser::eRequiredArgument, nullptr, nullptr, 0,
> eArgTypeBoolean,"Controls whether the expression can fall back to being
> JITted if it's not supported by the interpreter (defaults to true)."}
> > > };
> > > 
> > > This is a great feature which I will use in test cases.
> > >
> > > 
> > > Comment at: source/Expression/IRInterpreter.cpp:1102
> > > @@ -1058,1 +1101,3 @@
> > > +}
> > > +break;
> > > case Instruction::GetElementPtr:
> > > 
> > > Looks all right to me.  Thank you!
> > >
> > >
> > > http://reviews.llvm.org/D19124
> > >
> > >
> > >
> > > ___
> > > lldb-commits mailing list
> > > lldb-commits@lists.llvm.org
> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> >
> >
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Jim Ingham via lldb-commits

> On May 12, 2016, at 2:25 PM, Cameron  wrote:
> 
> Sorry to break the build! Apparently 'make clean' isn't executing cleanly 
> during the build step of the test, but I haven't the faintest idea why. It 
> builds/runs fine locally for me (then again, I'm on Windows). The makefile is 
> dead simple, and is identical to that of some other tests. Has anyone seen 
> something like this before?
> 
> Ah, I would have written a test using the APIs if I knew. I didn't see any 
> other similar tests that set up LLDB from scratch without going through the 
> command line. For reference, can you point me to one of these tests I can use 
> as an example for the next time?

expression_command/fixits/TestFixIts.py is one.  It makes a target, runs it 
hits breakpoints and does some other stuff.  Most of the Python API tests start 
by creating the target in Python - whereas the command-line tests tend to use 
the file command.  So you can find lots of examples by searching for the string 
"self.dbg.CreateTarget" in all the .py files.

Jim 

> 
> On Thu, May 12, 2016 at 5:17 PM, Jim Ingham  wrote:
> Note that while adding a "expr --allow-jit" flag to control this was great, 
> there already was an SBExpressionOptions option and the appropriate flags 
> available for this, so it was testable.  I was just checking because there 
> really shouldn't be anything we can do from a command that we can't do from 
> the SB API's, but in this case the thing was already in the expression 
> options.
> 
> We do prefer not to write tests with the command line when you can do it with 
> the Python API's.  In our experience, command line tests have tended to be 
> more fragile.  It's not necessary to change the test, there are plenty of 
> other command line tests lying around.  Just for future reference...
> 
> Jim
> 
> > On May 9, 2016, at 1:01 PM, Sean Callanan via lldb-commits 
> >  wrote:
> >
> > spyffe accepted this revision.
> > spyffe added a comment.
> > This revision is now accepted and ready to land.
> >
> > This patch is fine.  I especially appreciate the time you took making the 
> > IRInterpreter properly testable.  I will use this myself.
> >
> >
> > 
> > Comment at: source/Commands/CommandObjectExpression.cpp:67
> > @@ -67,1 +66,3 @@
> > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",  'p', 
> > OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,   
> > "Interpret the expression as top-level definitions rather than code to be 
> > immediately executed."},
> > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit",  'j', 
> > OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
> > "Controls whether the expression can fall back to being JITted if it's not 
> > supported by the interpreter (defaults to true)."}
> > };
> > 
> > This is a great feature which I will use in test cases.
> >
> > 
> > Comment at: source/Expression/IRInterpreter.cpp:1102
> > @@ -1058,1 +1101,3 @@
> > +}
> > +break;
> > case Instruction::GetElementPtr:
> > 
> > Looks all right to me.  Thank you!
> >
> >
> > http://reviews.llvm.org/D19124
> >
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> 
> 

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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala added a comment.

In http://reviews.llvm.org/D20193#428971, @zturner wrote:

> I had to leave early today, can I check it tomorrow?


Sure, sounds good.


http://reviews.llvm.org/D20193



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


Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Cameron via lldb-commits
Sorry to break the build! Apparently 'make clean' isn't executing cleanly
during the build step of the test, but I haven't the faintest idea why. It
builds/runs fine locally for me (then again, I'm on Windows). The makefile
is dead simple, and is identical to that of some other tests. Has anyone
seen something like this before?

Ah, I would have written a test using the APIs if I knew. I didn't see any
other similar tests that set up LLDB from scratch without going through the
command line. For reference, can you point me to one of these tests I can
use as an example for the next time?

On Thu, May 12, 2016 at 5:17 PM, Jim Ingham  wrote:

> Note that while adding a "expr --allow-jit" flag to control this was
> great, there already was an SBExpressionOptions option and the appropriate
> flags available for this, so it was testable.  I was just checking because
> there really shouldn't be anything we can do from a command that we can't
> do from the SB API's, but in this case the thing was already in the
> expression options.
>
> We do prefer not to write tests with the command line when you can do it
> with the Python API's.  In our experience, command line tests have tended
> to be more fragile.  It's not necessary to change the test, there are
> plenty of other command line tests lying around.  Just for future
> reference...
>
> Jim
>
> > On May 9, 2016, at 1:01 PM, Sean Callanan via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
> >
> > spyffe accepted this revision.
> > spyffe added a comment.
> > This revision is now accepted and ready to land.
> >
> > This patch is fine.  I especially appreciate the time you took making
> the IRInterpreter properly testable.  I will use this myself.
> >
> >
> > 
> > Comment at: source/Commands/CommandObjectExpression.cpp:67
> > @@ -67,1 +66,3 @@
> > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",
> 'p', OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,
>  "Interpret the expression as top-level definitions rather than code to be
> immediately executed."},
> > +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit",
> 'j', OptionParser::eRequiredArgument, nullptr, nullptr, 0,
> eArgTypeBoolean,"Controls whether the expression can fall back to being
> JITted if it's not supported by the interpreter (defaults to true)."}
> > };
> > 
> > This is a great feature which I will use in test cases.
> >
> > 
> > Comment at: source/Expression/IRInterpreter.cpp:1102
> > @@ -1058,1 +1101,3 @@
> > +}
> > +break;
> > case Instruction::GetElementPtr:
> > 
> > Looks all right to me.  Thank you!
> >
> >
> > http://reviews.llvm.org/D19124
> >
> >
> >
> > ___
> > lldb-commits mailing list
> > lldb-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Zachary Turner via lldb-commits
I had to leave early today, can I check it tomorrow?
On Thu, May 12, 2016 at 2:10 PM Todd Fiala  wrote:

> tfiala marked an inline comment as done.
> tfiala added a comment.
>
> @Zturner I think this is ready to go now.  Can you give this a try on
> Windows?
>
> Also, can you try the following part in cmd.exe?
>
>   cd packages\Python\lldbsuite\test_event
>   python -m unittest discover -s test\src -p 'Test*.py'
>
> That should run 2 tests and they should pass, assuming no extra bits need
> to be added to the dotest.py that is called internally by them.  The
> event_collector.py class, used to test the test infrastructure, builds a
> 'python dotest.py' command line that does what a dotest inferior will do
> during a normal test run.  The output of that gets verified in the
> TestCatchInvalidDecorator.py test.
>
>
> http://reviews.llvm.org/D20193
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Jim Ingham via lldb-commits
Note that while adding a "expr --allow-jit" flag to control this was great, 
there already was an SBExpressionOptions option and the appropriate flags 
available for this, so it was testable.  I was just checking because there 
really shouldn't be anything we can do from a command that we can't do from the 
SB API's, but in this case the thing was already in the expression options.

We do prefer not to write tests with the command line when you can do it with 
the Python API's.  In our experience, command line tests have tended to be more 
fragile.  It's not necessary to change the test, there are plenty of other 
command line tests lying around.  Just for future reference...

Jim

> On May 9, 2016, at 1:01 PM, Sean Callanan via lldb-commits 
>  wrote:
> 
> spyffe accepted this revision.
> spyffe added a comment.
> This revision is now accepted and ready to land.
> 
> This patch is fine.  I especially appreciate the time you took making the 
> IRInterpreter properly testable.  I will use this myself.
> 
> 
> 
> Comment at: source/Commands/CommandObjectExpression.cpp:67
> @@ -67,1 +66,3 @@
> +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",  'p', 
> OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,   
> "Interpret the expression as top-level definitions rather than code to be 
> immediately executed."},
> +{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit",  'j', 
> OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
> "Controls whether the expression can fall back to being JITted if it's not 
> supported by the interpreter (defaults to true)."}
> };
> 
> This is a great feature which I will use in test cases.
> 
> 
> Comment at: source/Expression/IRInterpreter.cpp:1102
> @@ -1058,1 +1101,3 @@
> +}
> +break;
> case Instruction::GetElementPtr:
> 
> Looks all right to me.  Thank you!
> 
> 
> http://reviews.llvm.org/D19124
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala marked an inline comment as done.
tfiala added a comment.

@Zturner I think this is ready to go now.  Can you give this a try on Windows?

Also, can you try the following part in cmd.exe?

  cd packages\Python\lldbsuite\test_event
  python -m unittest discover -s test\src -p 'Test*.py'

That should run 2 tests and they should pass, assuming no extra bits need to be 
added to the dotest.py that is called internally by them.  The 
event_collector.py class, used to test the test infrastructure, builds a 
'python dotest.py' command line that does what a dotest inferior will do during 
a normal test run.  The output of that gets verified in the 
TestCatchInvalidDecorator.py test.


http://reviews.llvm.org/D20193



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


Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Oleksiy Vyalov via lldb-commits
ovyalov added a subscriber: ovyalov.
ovyalov added a comment.

Looks like this CL broke CMake build bot - 
http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/14634, 
could you take a look?


Repository:
  rL LLVM

http://reviews.llvm.org/D19124



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


Re: [Lldb-commits] [PATCH] D14182: Centos 5 compile fixes for lldb

2016-05-12 Thread Kamil Rytarowski via lldb-commits
krytarowski resigned from this revision.
krytarowski removed a reviewer: krytarowski.
krytarowski added a comment.

This patch looks dead -- no activity.


Repository:
  rL LLVM

http://reviews.llvm.org/D14182



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


[Lldb-commits] [lldb] r269340 - [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Marianne Mailhot-Sarrasin via lldb-commits
Author: mamai
Date: Thu May 12 15:00:53 2016
New Revision: 269340

URL: http://llvm.org/viewvc/llvm-project?rev=269340&view=rev
Log:
[LLDB] Added support for PHI nodes to IR interpreter

This allows expressions such as 'i == 1 || i == 2` to be executed using the IR 
interpreter, instead of relying on JIT code injection (which may not be 
available on some platforms).

Patch by cameron314

Differential Revision: http://reviews.llvm.org/D19124

Added:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/

lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py

lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
Modified:
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Commands/CommandObjectExpression.h
lldb/trunk/source/Expression/IRInterpreter.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py?rev=269340&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py
 Thu May 12 15:00:53 2016
@@ -0,0 +1,40 @@
+"""
+Test PHI nodes work in the IR interpreter.
+"""
+
+import os, os.path
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class IRInterpreterPHINodesTestCase(TestBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def test_phi_node_support(self):
+"""Test support for PHI nodes in the IR interpreter."""
+
+self.build()
+exe = os.path.join(os.getcwd(), 'a.out')
+self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)
+
+# Break on the first assignment to i
+line = line_number('main.cpp', 'i = 5')
+lldbutil.run_break_set_by_file_and_line(self, 'main.cpp', line, 
num_expected_locations=1, loc_exact=True)
+
+self.runCmd('run', RUN_SUCCEEDED)
+
+# The stop reason of the thread should be breakpoint
+self.expect('thread list', STOPPED_DUE_TO_BREAKPOINT,
+substrs = ['stopped', 'stop reason = breakpoint'])
+
+self.runCmd('s')
+
+# The logical 'or' causes a PHI node to be generated. Execute without 
JIT
+# to test that the interpreter can handle this
+self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['true'])
+
+self.runCmd('s')
+self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['false'])
+self.runCmd('s')
+self.expect('expr -j 0 -- i == 3 || i == 5', substrs=['true'])

Added: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp?rev=269340&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
 Thu May 12 15:00:53 2016
@@ -0,0 +1,17 @@
+//===-- main.cpp *- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+int main()
+{
+int i;
+i = 5;
+i = 2;
+i = 3;
+return 0;
+}

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=269340&r1=269339&r2=269340&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu May 12 15:00:53 
2016
@@ -63,7 +63,8 @@ CommandObjectExpression::CommandOptions:
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language",   'l', 
OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,   
"Specifies the Language to use when parsing the expression.  If not set the 
target.language setting is used." },
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits",   'X', 
OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLang

Re: [Lldb-commits] [PATCH] D19124: [LLDB] Added support for PHI nodes to IR interpreter

2016-05-12 Thread Marianne Mailhot-Sarrasin via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269340: [LLDB] Added support for PHI nodes to IR interpreter 
(authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19124?vs=54134&id=57093#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19124

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/TestIRInterpreterPHINodes.py
  
lldb/trunk/packages/Python/lldbsuite/test/expression_command/ir-interpreter-phi-nodes/main.cpp
  lldb/trunk/source/Commands/CommandObjectExpression.cpp
  lldb/trunk/source/Commands/CommandObjectExpression.h
  lldb/trunk/source/Expression/IRInterpreter.cpp

Index: lldb/trunk/source/Commands/CommandObjectExpression.h
===
--- lldb/trunk/source/Commands/CommandObjectExpression.h
+++ lldb/trunk/source/Commands/CommandObjectExpression.h
@@ -57,6 +57,7 @@
 booltop_level;
 boolunwind_on_error;
 boolignore_breakpoints;
+boolallow_jit;
 boolshow_types;
 boolshow_summary;
 booldebug;
Index: lldb/trunk/source/Commands/CommandObjectExpression.cpp
===
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp
@@ -63,7 +63,8 @@
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language",   'l', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,   "Specifies the Language to use when parsing the expression.  If not set the target.language setting is used." },
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits",   'X', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,   "If true, simple FixIt hints will be automatically applied to the expression." },
 { LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, nullptr, g_description_verbosity_type, 0, eArgTypeDescriptionVerbosity,"How verbose should the output of this expression be, if the object description is asked for."},
-{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",  'p', OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,   "Interpret the expression as top-level definitions rather than code to be immediately executed."}
+{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level",  'p', OptionParser::eNoArgument  , NULL, NULL, 0, eArgTypeNone,   "Interpret the expression as top-level definitions rather than code to be immediately executed."},
+{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit",  'j', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,"Controls whether the expression can fall back to being JITted if it's not supported by the interpreter (defaults to true)."}
 };
 
 uint32_t
@@ -111,6 +112,18 @@
 error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
 break;
 }
+
+case 'j':
+{
+bool success;
+bool tmp_value = Args::StringToBoolean(option_arg, true, &success);
+if (success)
+allow_jit = tmp_value;
+else
+error.SetErrorStringWithFormat("could not convert \"%s\" to a boolean value.", option_arg);
+break;
+}
+
 case 't':
 {
 bool success;
@@ -197,6 +210,7 @@
 m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityCompact;
 auto_apply_fixits = eLazyBoolCalculate;
 top_level = false;
+allow_jit = true;
 }
 
 const OptionDefinition*
@@ -325,6 +339,9 @@
 options.SetTryAllThreads(m_command_options.try_all_threads);
 options.SetDebug(m_command_options.debug);
 options.SetLanguage(m_command_options.language);
+options.SetExecutionPolicy(m_command_options.allow_jit ?
+EvaluateExpressionOptions::default_execution_policy :
+lldb_private::eExecutionPolicyNever);
 
 bool auto_apply_fixits;
 if (m_command_options.auto_apply_fixits == eLazyBoolCalculate)
Index: lldb/trunk/source/Expression/IRInterpreter.cpp
===
--- lldb/trunk/source/Expression/IRInterpreter.cpp
+++ lldb/trunk/source/Expression/IRInterpreter.cpp
@@ -106,6 +106,7 @@
 DataLayout &m_target_data;
 lldb_private::IRExecutionUnit  &m_execution_unit;
 const BasicBlock   *m_bb;
+const BasicBlock   *m_prev_bb;
 BasicBlock::const_iterator  m_ii;
 BasicBlock::const_iterator  m_ie;
 
@@ -121,7 +122,9 @@
lldb::addr_t stack_frame_bottom,
lldb::addr_t stack_frame_top) 

Re: [Lldb-commits] [PATCH] D15067: Add CMake bits necessary for standalone build

2016-05-12 Thread Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269332: Add CMake bits necessary for standalone build 
(authored by kamil).

Changed prior to commit:
  http://reviews.llvm.org/D15067?vs=56970&id=57091#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15067

Files:
  lldb/trunk/cmake/modules/LLDBStandalone.cmake
  lldb/trunk/scripts/CMakeLists.txt

Index: lldb/trunk/scripts/CMakeLists.txt
===
--- lldb/trunk/scripts/CMakeLists.txt
+++ lldb/trunk/scripts/CMakeLists.txt
@@ -9,6 +9,8 @@
   ${LLDB_SOURCE_DIR}/include/lldb/lldb-versioning.h
 )
 
+include(FindPythonInterp)
+
 find_package(SWIG REQUIRED)
 add_custom_command(
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -6,57 +6,78 @@
 
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
-  set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
-"Path to LLVM source code. Not necessary if using an installed LLVM.")
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
-"Path to the directory where LLVM was built or installed.")
-
-  set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
-"Path to Clang source code. Not necessary if using an installed Clang.")
-  set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
-"Path to the directory where Clang was built or installed.")
-
-  if (LLDB_PATH_TO_LLVM_SOURCE)
-if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
-  message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
-  "directory of LLVM source code.")
+  # Rely on llvm-config.
+  set(CONFIG_OUTPUT)
+  find_program(LLVM_CONFIG "llvm-config")
+  if(LLVM_CONFIG)
+message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+set(CONFIG_COMMAND ${LLVM_CONFIG}
+  "--assertion-mode"
+  "--bindir"
+  "--libdir"
+  "--includedir"
+  "--prefix"
+  "--src-root")
+execute_process(
+  COMMAND ${CONFIG_COMMAND}
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE CONFIG_OUTPUT
+)
+if(NOT HAD_ERROR)
+  string(REGEX REPLACE
+"[ \t]*[\r\n]+[ \t]*" ";"
+CONFIG_OUTPUT ${CONFIG_OUTPUT})
+
 else()
-  get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
- ABSOLUTE)
-  set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
+  message(STATUS "${CONFIG_COMMAND_STR}")
+  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
 endif()
-  endif()
-
-  if (LLDB_PATH_TO_CLANG_SOURCE)
-  get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
- ABSOLUTE)
-  set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
-  endif()
-
-  list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
-
-  if (LLDB_PATH_TO_LLVM_BUILD)
-get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
-   ABSOLUTE)
   else()
-message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_BUILD to the root "
-"directory of LLVM build or install site.")
+message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
   endif()
 
-  if (LLDB_PATH_TO_CLANG_BUILD)
-get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
-   ABSOLUTE)
+  list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
+  list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
+  list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+
+  if(NOT MSVC_IDE)
+set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
+  CACHE BOOL "Enable assertions")
+# Assertions should follow llvm-config's.
+mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
+  endif()
+
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+
+  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
+NO_DEFAULT_PATH)
+
+  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
+  if(EXISTS ${LLVMCONFIG_FILE})
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+include(${LLVMCONFIG_FILE})
  

[Lldb-commits] [lldb] r269332 - Add CMake bits necessary for standalone build

2016-05-12 Thread Kamil Rytarowski via lldb-commits
Author: kamil
Date: Thu May 12 14:49:17 2016
New Revision: 269332

URL: http://llvm.org/viewvc/llvm-project?rev=269332&view=rev
Log:
Add CMake bits necessary for standalone build

Summary: Developed on NetBSD with pkgsrc.

Reviewers: zturner, labath

Subscribers: jevinskie, zturner, tfiala, Eugene.Zelenko, artagnon, joerg, 
lldb-commits

Differential Revision: http://reviews.llvm.org/D15067

Modified:
lldb/trunk/cmake/modules/LLDBStandalone.cmake
lldb/trunk/scripts/CMakeLists.txt

Modified: lldb/trunk/cmake/modules/LLDBStandalone.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/LLDBStandalone.cmake?rev=269332&r1=269331&r2=269332&view=diff
==
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake (original)
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake Thu May 12 14:49:17 2016
@@ -6,57 +6,78 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
-  set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
-"Path to LLVM source code. Not necessary if using an installed LLVM.")
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
-"Path to the directory where LLVM was built or installed.")
-
-  set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
-"Path to Clang source code. Not necessary if using an installed Clang.")
-  set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
-"Path to the directory where Clang was built or installed.")
-
-  if (LLDB_PATH_TO_LLVM_SOURCE)
-if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
-  message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
-  "directory of LLVM source code.")
+  # Rely on llvm-config.
+  set(CONFIG_OUTPUT)
+  find_program(LLVM_CONFIG "llvm-config")
+  if(LLVM_CONFIG)
+message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+set(CONFIG_COMMAND ${LLVM_CONFIG}
+  "--assertion-mode"
+  "--bindir"
+  "--libdir"
+  "--includedir"
+  "--prefix"
+  "--src-root")
+execute_process(
+  COMMAND ${CONFIG_COMMAND}
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE CONFIG_OUTPUT
+)
+if(NOT HAD_ERROR)
+  string(REGEX REPLACE
+"[ \t]*[\r\n]+[ \t]*" ";"
+CONFIG_OUTPUT ${CONFIG_OUTPUT})
+
 else()
-  get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
- ABSOLUTE)
-  set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
+  message(STATUS "${CONFIG_COMMAND_STR}")
+  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
 endif()
-  endif()
-
-  if (LLDB_PATH_TO_CLANG_SOURCE)
-  get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
- ABSOLUTE)
-  set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
-  endif()
-
-  list(APPEND CMAKE_MODULE_PATH 
"${LLDB_PATH_TO_LLVM_BUILD}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
-
-  if (LLDB_PATH_TO_LLVM_BUILD)
-get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
-   ABSOLUTE)
   else()
-message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_BUILD to the root "
-"directory of LLVM build or install site.")
+message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
   endif()
 
-  if (LLDB_PATH_TO_CLANG_BUILD)
-get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
-   ABSOLUTE)
+  list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
+  list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
+  list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+
+  if(NOT MSVC_IDE)
+set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
+  CACHE BOOL "Enable assertions")
+# Assertions should follow llvm-config's.
+mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
+  endif()
+
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+
+  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
+NO_DEFAULT_PATH)
+
+  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
+  if(EXISTS ${LLVMCONFIG_FILE})
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+include(${LLVMCONFIG_FILE})
   else()
-message(FATAL_ERROR "Please set LLDB_PATH_TO_CLANG_BUILD to the 

Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala updated this revision to Diff 57090.
tfiala added a comment.

Now addresses the remaining review comment from Pavel.  ResultsFormatter 
instances are now told if their file is a stream rather than a block/char file.

The pickling formatter uses two different serializers, one for streaming and 
one for not.


http://reviews.llvm.org/D20193

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/issue_verification/TestInvalidDecorator.py.park
  packages/Python/lldbsuite/test_event/event_builder.py
  packages/Python/lldbsuite/test_event/formatter/__init__.py
  packages/Python/lldbsuite/test_event/formatter/curses.py
  packages/Python/lldbsuite/test_event/formatter/pickled.py
  packages/Python/lldbsuite/test_event/formatter/results_formatter.py
  packages/Python/lldbsuite/test_event/formatter/xunit.py
  
packages/Python/lldbsuite/test_event/test/resources/invalid_decorator/TestInvalidDecorator.py
  packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
  packages/Python/lldbsuite/test_event/test/src/event_collector.py

Index: packages/Python/lldbsuite/test_event/test/src/event_collector.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test_event/test/src/event_collector.py
@@ -0,0 +1,85 @@
+from __future__ import absolute_import
+from __future__ import print_function
+
+import os
+import subprocess
+import sys
+import tempfile
+
+# noinspection PyUnresolvedReferences
+from six.moves import cPickle
+
+
+def path_to_dotest_py():
+return os.path.join(
+os.path.dirname(__file__),
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+"test",
+"dotest.py")
+
+
+def _make_pickled_events_filename():
+with tempfile.NamedTemporaryFile(
+prefix="lldb_test_event_pickled_event_output",
+delete=False) as temp_file:
+return temp_file.name
+
+
+def _collect_events_with_command(command, events_filename):
+# Run the single test with dotest.py, outputting
+# the raw pickled events to a temp file.
+with open(os.devnull, 'w') as dev_null_file:
+subprocess.call(
+command,
+stdout=dev_null_file,
+stderr=dev_null_file)
+
+# Unpickle the events
+events = []
+if os.path.exists(events_filename):
+with open(events_filename, "rb") as events_file:
+while True:
+try:
+# print("reading event")
+event = cPickle.load(events_file)
+# print("read event: {}".format(event))
+if event:
+events.append(event)
+except EOFError:
+# This is okay.
+break
+os.remove(events_filename)
+return events
+
+
+def collect_events_whole_file(test_filename):
+events_filename = _make_pickled_events_filename()
+command = [
+sys.executable,
+path_to_dotest_py(),
+"--inferior",
+"--results-formatter=lldbsuite.test_event.formatter.pickled.RawPickledFormatter",
+"--results-file={}".format(events_filename),
+"-p", os.path.basename(test_filename),
+os.path.dirname(test_filename)
+]
+return _collect_events_with_command(command, events_filename)
+
+
+def collect_events_for_directory_with_filter(test_filename, filter_desc):
+events_filename = _make_pickled_events_filename()
+command = [
+sys.executable,
+path_to_dotest_py(),
+"--inferior",
+"--results-formatter=lldbsuite.test_event.formatter.pickled.RawPickledFormatter",
+"--results-file={}".format(events_filename),
+"-f", filter_desc,
+os.path.dirname(test_filename)
+]
+return _collect_events_with_command(command, events_filename)
Index: packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+"""
+Tests that the event system reports issues during decorator
+handling as errors.
+"""
+# System-provided imports
+import os
+import unittest
+
+# Local-provided imports
+import event_collector
+
+
+class TestCatchInvalidDecorator(unittest.TestCase):
+
+TEST_DIR = os.path.join(
+os.path.dirname(__file__),
+os.path.pardir,
+"resources",
+"invalid_decorator")
+
+def test_with_whole_file(self):
+"""
+Test that a non-existent decorator generates a test-event error
+when running all tests in the file.
+"""
+# Determine the test case file we're using.
+test_file = os.path.join(self.TEST_DIR, "TestInvalidDecorator.py")
+
+# Collect a

[Lldb-commits] [lldb] r269330 - Turn on LLDB_EDITLINE_USE_WCHAR on NetBSD

2016-05-12 Thread Kamil Rytarowski via lldb-commits
Author: kamil
Date: Thu May 12 14:46:08 2016
New Revision: 269330

URL: http://llvm.org/viewvc/llvm-project?rev=269330&view=rev
Log:
Turn on LLDB_EDITLINE_USE_WCHAR on NetBSD

Summary: The editline(3) library in NetBSD is by default internally wide.

Reviewers: clayborg, emaste

Subscribers: joerg, lldb-commits

Differential Revision: http://reviews.llvm.org/D20188

Modified:
lldb/trunk/include/lldb/Host/Editline.h

Modified: lldb/trunk/include/lldb/Host/Editline.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=269330&r1=269329&r2=269330&view=diff
==
--- lldb/trunk/include/lldb/Host/Editline.h (original)
+++ lldb/trunk/include/lldb/Host/Editline.h Thu May 12 14:46:08 2016
@@ -27,11 +27,12 @@
 
 #include 
 #include 
+#include 
 
 // components needed to handle wide characters ( , codecvt_utf8, 
libedit built with '--enable-widec' )
-// are not consistenly available on non-OSX platforms.  The wchar_t versions 
of libedit functions will only be
+// are available on some platforms. The wchar_t versions of libedit functions 
will only be
 // used in cases where this is true.  This is a compile time dependecy, for 
now selected per target Platform
-#if defined (__APPLE__)
+#if defined (__APPLE__) || defined(__NetBSD__)
 #define LLDB_EDITLINE_USE_WCHAR 1
 #include 
 #else


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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala marked 4 inline comments as done.


Comment at: packages/Python/lldbsuite/test/dotest.py:725
@@ +724,3 @@
+test_filename = os.path.abspath(os.path.join(dir, name))
+if test_filename.endswith(".pyc"):
+test_filename = test_filename[0:-1]

tfiala wrote:
> labath wrote:
> > Will this ever be executed? I mean, if we get a pyc file, we shouldn't even 
> > get here due to the check on line 689.
> Ah yes, that is true.  Since we assert downstream from here if it was a .pyc 
> file, I was being safe.
> 
> This will get refactored per previous comment, and at that point I will need 
> it.
You were right, once I refactored I saw I didn't need this check.  I pulled it 
out.


Comment at: packages/Python/lldbsuite/test_event/formatter/pickled.py:57
@@ +56,3 @@
+# end.
+if self.use_send:
+# Send it as 
{serialized_length_of_serialized_bytes}{serialized_bytes}

labath wrote:
> tfiala wrote:
> > tfiala wrote:
> > > labath wrote:
> > > > Why do we need the format to be different based on the kind of object 
> > > > we are writing to? The added magic (introspection) seems like a bad 
> > > > tradeoff, if all it does is avoid a couple of lines in 
> > > > `event_collector.py`
> > > When we're using sockets, we have to be able to know the size of the full 
> > > info when reconstructing on the receiving side.  This is the normal mode 
> > > in which this is used.  However, that also complicates the parsing of the 
> > > data for the simple test driver.
> > > 
> > > The code later on in the test_event unit tests:
> > > 
> > > ```
> > > if os.path.exists(pickled_events_filename()):
> > > with open(pickled_events_filename(), "rb") as events_file:
> > > while True:
> > > try:
> > > # print("reading event")
> > > event = cPickle.load(events_file)
> > > # print("read event: {}".format(event))
> > > if event:
> > > events.append(event)
> > > except EOFError:
> > > # This is okay.
> > > Break
> > > ```
> > > 
> > > Would get considerably more complicated to deal with the same format that 
> > > is only required for going over a network-style protocol.  I prefer this 
> > > tradeoff.  In the unit tests, I just send the event output to a file, and 
> > > then read it with the simple loop I included above.
> > > 
> > > However, to verify that I really prefer it, I will try writing it the 
> > > other way.
> > > However, to verify that I really prefer it, I will try writing it the 
> > > other way.
> > 
> > The flip side is I can try to factor out the listener side logic that 
> > reconstructs these.  However, that is currently rather tightly coupled to 
> > the network listening transport.  And most of the work it does has purely 
> > to do with needing to receive the whole message before it can try to 
> > un-pickle it.  So I'm not really seeing that as a big win.  (Except for 
> > testability.  So maybe it's okay to break that out.)  I'll see what that 
> > looks like since that is probably the better high-level way to handle this 
> > if we didn't want the change I made to the sender side.
> The other alternative I see is to make pass in a "serializer" object (or a 
> lambda or something), which knows how to write to the right output. Then, you 
> can construct the correct serializer object depending on whether you got 
> passed `--results-file` or `--results-port`.
Still outstanding.


http://reviews.llvm.org/D20193



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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala updated this revision to Diff 57087.
tfiala added a comment.

Adjust last patch to include full context.


http://reviews.llvm.org/D20193

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/issue_verification/TestInvalidDecorator.py.park
  packages/Python/lldbsuite/test_event/event_builder.py
  packages/Python/lldbsuite/test_event/formatter/pickled.py
  
packages/Python/lldbsuite/test_event/test/resources/invalid_decorator/TestInvalidDecorator.py
  packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
  packages/Python/lldbsuite/test_event/test/src/event_collector.py

Index: packages/Python/lldbsuite/test_event/test/src/event_collector.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test_event/test/src/event_collector.py
@@ -0,0 +1,85 @@
+from __future__ import absolute_import
+from __future__ import print_function
+
+import os
+import subprocess
+import sys
+import tempfile
+
+# noinspection PyUnresolvedReferences
+from six.moves import cPickle
+
+
+def path_to_dotest_py():
+return os.path.join(
+os.path.dirname(__file__),
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+"test",
+"dotest.py")
+
+
+def _make_pickled_events_filename():
+with tempfile.NamedTemporaryFile(
+prefix="lldb_test_event_pickled_event_output",
+delete=False) as temp_file:
+return temp_file.name
+
+
+def _collect_events_with_command(command, events_filename):
+# Run the single test with dotest.py, outputting
+# the raw pickled events to a temp file.
+with open(os.devnull, 'w') as dev_null_file:
+subprocess.call(
+command,
+stdout=dev_null_file,
+stderr=dev_null_file)
+
+# Unpickle the events
+events = []
+if os.path.exists(events_filename):
+with open(events_filename, "rb") as events_file:
+while True:
+try:
+# print("reading event")
+event = cPickle.load(events_file)
+# print("read event: {}".format(event))
+if event:
+events.append(event)
+except EOFError:
+# This is okay.
+break
+os.remove(events_filename)
+return events
+
+
+def collect_events_whole_file(test_filename):
+events_filename = _make_pickled_events_filename()
+command = [
+sys.executable,
+path_to_dotest_py(),
+"--inferior",
+"--results-formatter=lldbsuite.test_event.formatter.pickled.RawPickledFormatter",
+"--results-file={}".format(events_filename),
+"-p", os.path.basename(test_filename),
+os.path.dirname(test_filename)
+]
+return _collect_events_with_command(command, events_filename)
+
+
+def collect_events_for_directory_with_filter(test_filename, filter_desc):
+events_filename = _make_pickled_events_filename()
+command = [
+sys.executable,
+path_to_dotest_py(),
+"--inferior",
+"--results-formatter=lldbsuite.test_event.formatter.pickled.RawPickledFormatter",
+"--results-file={}".format(events_filename),
+"-f", filter_desc,
+os.path.dirname(test_filename)
+]
+return _collect_events_with_command(command, events_filename)
Index: packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+"""
+Tests that the event system reports issues during decorator
+handling as errors.
+"""
+# System-provided imports
+import os
+import unittest
+
+# Local-provided imports
+import event_collector
+
+
+class TestCatchInvalidDecorator(unittest.TestCase):
+
+TEST_DIR = os.path.join(
+os.path.dirname(__file__),
+os.path.pardir,
+"resources",
+"invalid_decorator")
+
+def test_with_whole_file(self):
+"""
+Test that a non-existent decorator generates a test-event error
+when running all tests in the file.
+"""
+# Determine the test case file we're using.
+test_file = os.path.join(self.TEST_DIR, "TestInvalidDecorator.py")
+
+# Collect all test events generated for this file.
+error_results = _filter_error_results(
+event_collector.collect_events_whole_file(test_file))
+
+self.assertGreater(
+len(error_results),
+0,
+"At least one job or test error result should have been returned")
+
+def test_with_function_filter(self):
+"""
+Test that a non-existent decorator generates a test-event error
+ 

Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala updated this revision to Diff 57084.
tfiala added a comment.

Address most of Pavel's review comments.

New:

- Also catches multiple matching base names and converts that to a caught test 
error.

Comments from Pavel not covered:

- Modifying the dual behavior of the pickling results formatter.

I'm going to look at that one next.


http://reviews.llvm.org/D20193

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/issue_verification/TestInvalidDecorator.py.park
  packages/Python/lldbsuite/test_event/event_builder.py
  packages/Python/lldbsuite/test_event/formatter/pickled.py
  
packages/Python/lldbsuite/test_event/test/resources/invalid_decorator/TestInvalidDecorator.py
  packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
  packages/Python/lldbsuite/test_event/test/src/event_collector.py

Index: packages/Python/lldbsuite/test_event/test/src/event_collector.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test_event/test/src/event_collector.py
@@ -0,0 +1,85 @@
+from __future__ import absolute_import
+from __future__ import print_function
+
+import os
+import subprocess
+import sys
+import tempfile
+
+# noinspection PyUnresolvedReferences
+from six.moves import cPickle
+
+
+def path_to_dotest_py():
+return os.path.join(
+os.path.dirname(__file__),
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+os.path.pardir,
+"test",
+"dotest.py")
+
+
+def _make_pickled_events_filename():
+with tempfile.NamedTemporaryFile(
+prefix="lldb_test_event_pickled_event_output",
+delete=False) as temp_file:
+return temp_file.name
+
+
+def _collect_events_with_command(command, events_filename):
+# Run the single test with dotest.py, outputting
+# the raw pickled events to a temp file.
+with open(os.devnull, 'w') as dev_null_file:
+subprocess.call(
+command,
+stdout=dev_null_file,
+stderr=dev_null_file)
+
+# Unpickle the events
+events = []
+if os.path.exists(events_filename):
+with open(events_filename, "rb") as events_file:
+while True:
+try:
+# print("reading event")
+event = cPickle.load(events_file)
+# print("read event: {}".format(event))
+if event:
+events.append(event)
+except EOFError:
+# This is okay.
+break
+os.remove(events_filename)
+return events
+
+
+def collect_events_whole_file(test_filename):
+events_filename = _make_pickled_events_filename()
+command = [
+sys.executable,
+path_to_dotest_py(),
+"--inferior",
+"--results-formatter=lldbsuite.test_event.formatter.pickled.RawPickledFormatter",
+"--results-file={}".format(events_filename),
+"-p", os.path.basename(test_filename),
+os.path.dirname(test_filename)
+]
+return _collect_events_with_command(command, events_filename)
+
+
+def collect_events_for_directory_with_filter(test_filename, filter_desc):
+events_filename = _make_pickled_events_filename()
+command = [
+sys.executable,
+path_to_dotest_py(),
+"--inferior",
+"--results-formatter=lldbsuite.test_event.formatter.pickled.RawPickledFormatter",
+"--results-file={}".format(events_filename),
+"-f", filter_desc,
+os.path.dirname(test_filename)
+]
+return _collect_events_with_command(command, events_filename)
Index: packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
===
--- /dev/null
+++ packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+"""
+Tests that the event system reports issues during decorator
+handling as errors.
+"""
+# System-provided imports
+import os
+import unittest
+
+# Local-provided imports
+import event_collector
+
+
+class TestCatchInvalidDecorator(unittest.TestCase):
+
+TEST_DIR = os.path.join(
+os.path.dirname(__file__),
+os.path.pardir,
+"resources",
+"invalid_decorator")
+
+def test_with_whole_file(self):
+"""
+Test that a non-existent decorator generates a test-event error
+when running all tests in the file.
+"""
+# Determine the test case file we're using.
+test_file = os.path.join(self.TEST_DIR, "TestInvalidDecorator.py")
+
+# Collect all test events generated for this file.
+error_results = _filter_error_results(
+event_collector.collect_events_whole_file(test_file))
+
+self.assertGreater(
+len(error_results),
+  

Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Pavel Labath via lldb-commits
labath added inline comments.


Comment at: packages/Python/lldbsuite/test_event/formatter/pickled.py:57
@@ +56,3 @@
+# end.
+if self.use_send:
+# Send it as 
{serialized_length_of_serialized_bytes}{serialized_bytes}

tfiala wrote:
> tfiala wrote:
> > labath wrote:
> > > Why do we need the format to be different based on the kind of object we 
> > > are writing to? The added magic (introspection) seems like a bad 
> > > tradeoff, if all it does is avoid a couple of lines in 
> > > `event_collector.py`
> > When we're using sockets, we have to be able to know the size of the full 
> > info when reconstructing on the receiving side.  This is the normal mode in 
> > which this is used.  However, that also complicates the parsing of the data 
> > for the simple test driver.
> > 
> > The code later on in the test_event unit tests:
> > 
> > ```
> > if os.path.exists(pickled_events_filename()):
> > with open(pickled_events_filename(), "rb") as events_file:
> > while True:
> > try:
> > # print("reading event")
> > event = cPickle.load(events_file)
> > # print("read event: {}".format(event))
> > if event:
> > events.append(event)
> > except EOFError:
> > # This is okay.
> > Break
> > ```
> > 
> > Would get considerably more complicated to deal with the same format that 
> > is only required for going over a network-style protocol.  I prefer this 
> > tradeoff.  In the unit tests, I just send the event output to a file, and 
> > then read it with the simple loop I included above.
> > 
> > However, to verify that I really prefer it, I will try writing it the other 
> > way.
> > However, to verify that I really prefer it, I will try writing it the other 
> > way.
> 
> The flip side is I can try to factor out the listener side logic that 
> reconstructs these.  However, that is currently rather tightly coupled to the 
> network listening transport.  And most of the work it does has purely to do 
> with needing to receive the whole message before it can try to un-pickle it.  
> So I'm not really seeing that as a big win.  (Except for testability.  So 
> maybe it's okay to break that out.)  I'll see what that looks like since that 
> is probably the better high-level way to handle this if we didn't want the 
> change I made to the sender side.
The other alternative I see is to make pass in a "serializer" object (or a 
lambda or something), which knows how to write to the right output. Then, you 
can construct the correct serializer object depending on whether you got passed 
`--results-file` or `--results-port`.


http://reviews.llvm.org/D20193



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


Re: [Lldb-commits] [PATCH] D15067: Add CMake bits necessary for standalone build

2016-05-12 Thread Eugene Zelenko via lldb-commits
Eugene.Zelenko added a comment.

In http://reviews.llvm.org/D15067#428146, @krytarowski wrote:

> @Eugene.Zelenko do you agree with this patch and what @labath wrote?


If CMake works that way, it's what I need :-)


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala added a comment.

In http://reviews.llvm.org/D20193#428364, @zturner wrote:

> I will look at this in more detail later, but hold off on committing until
>  i have a chance to run it on Windows


Hi Zachary.

No worries - I need to update the patch.  Pavel caught one thing in the test 
for the new code that won't work on Windows that I forgot to fix up in the 
initial implementation.  You might just as well wait for the next patch set to 
review it.


http://reviews.llvm.org/D20193



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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Zachary Turner via lldb-commits
I will look at this in more detail later, but hold off on committing until
i have a chance to run it on Windows
On Thu, May 12, 2016 at 8:05 AM Todd Fiala  wrote:

> tfiala added inline comments.
>
> 
> Comment at: packages/Python/lldbsuite/test_event/formatter/pickled.py:57
> @@ +56,3 @@
> +# end.
> +if self.use_send:
> +# Send it as
> {serialized_length_of_serialized_bytes}{serialized_bytes}
> 
> tfiala wrote:
> > labath wrote:
> > > Why do we need the format to be different based on the kind of object
> we are writing to? The added magic (introspection) seems like a bad
> tradeoff, if all it does is avoid a couple of lines in `event_collector.py`
> > When we're using sockets, we have to be able to know the size of the
> full info when reconstructing on the receiving side.  This is the normal
> mode in which this is used.  However, that also complicates the parsing of
> the data for the simple test driver.
> >
> > The code later on in the test_event unit tests:
> >
> > ```
> > if os.path.exists(pickled_events_filename()):
> > with open(pickled_events_filename(), "rb") as events_file:
> > while True:
> > try:
> > # print("reading event")
> > event = cPickle.load(events_file)
> > # print("read event: {}".format(event))
> > if event:
> > events.append(event)
> > except EOFError:
> > # This is okay.
> > Break
> > ```
> >
> > Would get considerably more complicated to deal with the same format
> that is only required for going over a network-style protocol.  I prefer
> this tradeoff.  In the unit tests, I just send the event output to a file,
> and then read it with the simple loop I included above.
> >
> > However, to verify that I really prefer it, I will try writing it the
> other way.
> > However, to verify that I really prefer it, I will try writing it the
> other way.
>
> The flip side is I can try to factor out the listener side logic that
> reconstructs these.  However, that is currently rather tightly coupled to
> the network listening transport.  And most of the work it does has purely
> to do with needing to receive the whole message before it can try to
> un-pickle it.  So I'm not really seeing that as a big win.  (Except for
> testability.  So maybe it's okay to break that out.)  I'll see what that
> looks like since that is probably the better high-level way to handle this
> if we didn't want the change I made to the sender side.
>
>
> http://reviews.llvm.org/D20193
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala added inline comments.


Comment at: packages/Python/lldbsuite/test_event/formatter/pickled.py:57
@@ +56,3 @@
+# end.
+if self.use_send:
+# Send it as 
{serialized_length_of_serialized_bytes}{serialized_bytes}

tfiala wrote:
> labath wrote:
> > Why do we need the format to be different based on the kind of object we 
> > are writing to? The added magic (introspection) seems like a bad tradeoff, 
> > if all it does is avoid a couple of lines in `event_collector.py`
> When we're using sockets, we have to be able to know the size of the full 
> info when reconstructing on the receiving side.  This is the normal mode in 
> which this is used.  However, that also complicates the parsing of the data 
> for the simple test driver.
> 
> The code later on in the test_event unit tests:
> 
> ```
> if os.path.exists(pickled_events_filename()):
> with open(pickled_events_filename(), "rb") as events_file:
> while True:
> try:
> # print("reading event")
> event = cPickle.load(events_file)
> # print("read event: {}".format(event))
> if event:
> events.append(event)
> except EOFError:
> # This is okay.
> Break
> ```
> 
> Would get considerably more complicated to deal with the same format that is 
> only required for going over a network-style protocol.  I prefer this 
> tradeoff.  In the unit tests, I just send the event output to a file, and 
> then read it with the simple loop I included above.
> 
> However, to verify that I really prefer it, I will try writing it the other 
> way.
> However, to verify that I really prefer it, I will try writing it the other 
> way.

The flip side is I can try to factor out the listener side logic that 
reconstructs these.  However, that is currently rather tightly coupled to the 
network listening transport.  And most of the work it does has purely to do 
with needing to receive the whole message before it can try to un-pickle it.  
So I'm not really seeing that as a big win.  (Except for testability.  So maybe 
it's okay to break that out.)  I'll see what that looks like since that is 
probably the better high-level way to handle this if we didn't want the change 
I made to the sender side.


http://reviews.llvm.org/D20193



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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Todd Fiala via lldb-commits
tfiala added a comment.

I'll make some adjustments per your review, Pavel.  Thanks!  I'll put up 
another patch set at that point.



Comment at: packages/Python/lldbsuite/test/dotest.py:695
@@ -694,3 +694,3 @@
 
 # Try to match the regexp pattern, if specified.
 if configuration.regexp:

labath wrote:
> This function (`visit`) is getting quite big, and due to the way it's 
> structured, you were forced to duplicate some code. We could solve both 
> problems with a bit of refactoring.
> 
> How about this:
> - put everything inside the for loop below this line into a separate function 
> (`visit_file` ?)
> - put the try-catch block around the call to `visit_file` in this function
> 
> This way we will have less duplication and will reduce the nesting depth of 
> this function.
> 
> What do you think?
Sounds like a good change.


Comment at: packages/Python/lldbsuite/test/dotest.py:725
@@ +724,3 @@
+test_filename = os.path.abspath(os.path.join(dir, name))
+if test_filename.endswith(".pyc"):
+test_filename = test_filename[0:-1]

labath wrote:
> Will this ever be executed? I mean, if we get a pyc file, we shouldn't even 
> get here due to the check on line 689.
Ah yes, that is true.  Since we assert downstream from here if it was a .pyc 
file, I was being safe.

This will get refactored per previous comment, and at that point I will need it.


Comment at: packages/Python/lldbsuite/test_event/formatter/pickled.py:57
@@ +56,3 @@
+# end.
+if self.use_send:
+# Send it as 
{serialized_length_of_serialized_bytes}{serialized_bytes}

labath wrote:
> Why do we need the format to be different based on the kind of object we are 
> writing to? The added magic (introspection) seems like a bad tradeoff, if all 
> it does is avoid a couple of lines in `event_collector.py`
When we're using sockets, we have to be able to know the size of the full info 
when reconstructing on the receiving side.  This is the normal mode in which 
this is used.  However, that also complicates the parsing of the data for the 
simple test driver.

The code later on in the test_event unit tests:

```
if os.path.exists(pickled_events_filename()):
with open(pickled_events_filename(), "rb") as events_file:
while True:
try:
# print("reading event")
event = cPickle.load(events_file)
# print("read event: {}".format(event))
if event:
events.append(event)
except EOFError:
# This is okay.
Break
```

Would get considerably more complicated to deal with the same format that is 
only required for going over a network-style protocol.  I prefer this tradeoff. 
 In the unit tests, I just send the event output to a file, and then read it 
with the simple loop I included above.

However, to verify that I really prefer it, I will try writing it the other way.


Comment at: 
packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py:38
@@ +37,3 @@
+
+self.assertTrue(
+len(results) > 0,

labath wrote:
> I don't fully understand the whole event collector logic yet, but I would 
> expect to see a check that the returned result is in fact an error result, no?
> 
> (Also, I prefer using `assertGreater(foo, bar)`, as it provides a more 
> descriptive error message.)
> .. but I would expect to see a check that the returned result is in fact an 
> error result, no?

Ah yes.  That is missing.  (Before, we weren't getting any job_result or 
test_result events).

I'll add that.

> (Also, I prefer using assertGreater(foo, bar), as it provides a more 
> descriptive error message.)

Haha okay so I looked for that method when I originally worked this.  The 
Python 2.7 page has a link to take to the assertion methods in a table.  The 
table it points to doesn't have that call.  However, they helpfully have two or 
three more tables below that.  Not sure why all those calls don't go into the 
same table, particularly on a link for assertion methods from earlier in the 
page.

I totally agree, I'll change that.


Comment at: packages/Python/lldbsuite/test_event/test/src/event_collector.py:25
@@ +24,3 @@
+def pickled_events_filename():
+return "/tmp/lldb_test_event_pickled_event_output.dat"
+

labath wrote:
> I'm pretty sure this won't work on windows.. :)
> `tempfile.NamedTemporaryFile` looks like a portable alternative.
Oh yes.  That's right.  I was thinking I'd get around to trying this on Windows 
myself, but that didn't happen.  At that point I was going to crack out the 
docs on the temp file handling.

Thanks for catching.


http://reviews.llvm.org/D20193



_

Re: [Lldb-commits] [lldb] r269025 - Fix race in TestExitDuringStep and unify pseudo_barrier handling

2016-05-12 Thread Ed Maste via lldb-commits
On 11 May 2016 at 11:39, Pavel Labath  wrote:
>
> Working around it this way is quite ugly. Let's try something else.
> Would getting rid of the do{}while loop in the macro fix the problem?
> I added it to make the macro a bit more safe, but I don't think it's
> really necessary...

Indeed, the test passes with the do while(0) removed from pseudo_barrier_wait.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20188: Turn on LLDB_EDITLINE_USE_WCHAR on NetBSD

2016-05-12 Thread Ed Maste via lldb-commits
emaste accepted this revision.
emaste added a comment.

Thanks.

(The reason I mentioned it is that I'll add __FreeBSD__ shortly.)


http://reviews.llvm.org/D20188



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


[Lldb-commits] [lldb] r269281 - Fix a race in ProcessGDBRemote::MonitorDebugServerProcess

2016-05-12 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 12 06:10:01 2016
New Revision: 269281

URL: http://llvm.org/viewvc/llvm-project?rev=269281&view=rev
Log:
Fix a race in ProcessGDBRemote::MonitorDebugServerProcess

Summary:
MonitorDebugServerProcess went to a lot of effort to make sure its asynchronous 
invocation does
not cause any mischief, but it was still not race-free. Specifically, in a 
quick stop-restart
sequence (like the one in TestAddressBreakpoints) the copying of the process 
shared pointer via
target_sp->GetProcessSP() was racing with the resetting of the pointer in 
DeleteCurrentProcess,
as they were both accessing the same shared_ptr object.

To avoid this, I simply pass in a weak_ptr to the process when the callback is 
created. Locking
this pointer is race-free as they are two separate object even though they 
point to the same
process instance. This also removes the need for the complicated tap-dance 
around retrieving the
process pointer.

Reviewers: clayborg

Subscribers: tberghammer, lldb-commits

Differential Revision: http://reviews.llvm.org/D20107

Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=269281&r1=269280&r2=269281&view=diff
==
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu May 
12 06:10:01 2016
@@ -3597,7 +3597,8 @@ ProcessGDBRemote::LaunchAndConnectToDebu
 // special terminal key sequences (^C) don't affect debugserver.
 debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
 
-
debugserver_launch_info.SetMonitorProcessCallback(std::bind(MonitorDebugserverProcess,
 this, _1, _2, _3, _4),
+const std::weak_ptr this_wp = 
std::static_pointer_cast(shared_from_this());
+
debugserver_launch_info.SetMonitorProcessCallback(std::bind(MonitorDebugserverProcess,
 this_wp, _1, _2, _3, _4),
   false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
@@ -3660,87 +3661,58 @@ ProcessGDBRemote::LaunchAndConnectToDebu
 }
 
 bool
-ProcessGDBRemote::MonitorDebugserverProcess(ProcessGDBRemote *process, 
lldb::pid_t debugserver_pid,
+ProcessGDBRemote::MonitorDebugserverProcess(std::weak_ptr 
process_wp, lldb::pid_t debugserver_pid,
 bool exited,// True if the 
process did exit
 int signo,  // Zero for no 
signal
 int exit_status // Exit value of 
process if signal is zero
 )
 {
-// The baton is a "ProcessGDBRemote *". Now this class might be gone
-// and might not exist anymore, so we need to carefully try to get the
-// target for this process first since we have a race condition when
-// we are done running between getting the notice that the inferior
-// process has died and the debugserver that was debugging this process.
-// In our test suite, we are also continually running process after
-// process, so we must be very careful to make sure:
-// 1 - process object hasn't been deleted already
-// 2 - that a new process object hasn't been recreated in its place
-
 // "debugserver_pid" argument passed in is the process ID for
 // debugserver that we are tracking...
 Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+const bool handled = true;
 
-// Get a shared pointer to the target that has a matching process pointer.
-// This target could be gone, or the target could already have a new 
process
-// object inside of it
-TargetSP target_sp (Debugger::FindTargetWithProcess(process));
+if (log)
+log->Printf("ProcessGDBRemote::%s(process_wp, pid=%" PRIu64 ", 
signo=%i (0x%x), exit_status=%i)", __FUNCTION__,
+debugserver_pid, signo, signo, exit_status);
 
+std::shared_ptr process_sp = process_wp.lock();
 if (log)
-log->Printf("ProcessGDBRemote::%s(process=%p, pid=%" PRIu64 ", 
signo=%i (0x%x), exit_status=%i)", __FUNCTION__,
-process, debugserver_pid, signo, signo, exit_status);
+log->Printf("ProcessGDBRemote::%s(process = %p)", __FUNCTION__, 
process_sp.get());
+if (!process_sp || process_sp->m_debugserver_pid != debugserver_pid)
+return handled;
+
+// Sleep for a half a second to make sure our inferior process has
+// time to set its exit status before we set it incorrectly when
+// both the debugserver and the inferior process shut down.
+usleep(50

Re: [Lldb-commits] [PATCH] D20107: Fix a race in ProcessGDBRemote::MonitorDebugServerProcess

2016-05-12 Thread Pavel Labath via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269281: Fix a race in 
ProcessGDBRemote::MonitorDebugServerProcess (authored by labath).

Changed prior to commit:
  http://reviews.llvm.org/D20107?vs=56722&id=57016#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20107

Files:
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h

Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -405,7 +405,8 @@
 AsyncThread (void *arg);
 
 static bool
-MonitorDebugserverProcess(ProcessGDBRemote *process, lldb::pid_t pid, bool exited, int signo, int exit_status);
+MonitorDebugserverProcess(std::weak_ptr process_wp, lldb::pid_t pid, bool exited, int signo,
+  int exit_status);
 
 lldb::StateType
 SetThreadStopInfo (StringExtractor& stop_packet);
Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3597,7 +3597,8 @@
 // special terminal key sequences (^C) don't affect debugserver.
 debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
 
-debugserver_launch_info.SetMonitorProcessCallback(std::bind(MonitorDebugserverProcess, this, _1, _2, _3, _4),
+const std::weak_ptr this_wp = std::static_pointer_cast(shared_from_this());
+debugserver_launch_info.SetMonitorProcessCallback(std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4),
   false);
 debugserver_launch_info.SetUserID(process_info.GetUserID());
 
@@ -3660,87 +3661,58 @@
 }
 
 bool
-ProcessGDBRemote::MonitorDebugserverProcess(ProcessGDBRemote *process, lldb::pid_t debugserver_pid,
+ProcessGDBRemote::MonitorDebugserverProcess(std::weak_ptr process_wp, lldb::pid_t debugserver_pid,
 bool exited,// True if the process did exit
 int signo,  // Zero for no signal
 int exit_status // Exit value of process if signal is zero
 )
 {
-// The baton is a "ProcessGDBRemote *". Now this class might be gone
-// and might not exist anymore, so we need to carefully try to get the
-// target for this process first since we have a race condition when
-// we are done running between getting the notice that the inferior
-// process has died and the debugserver that was debugging this process.
-// In our test suite, we are also continually running process after
-// process, so we must be very careful to make sure:
-// 1 - process object hasn't been deleted already
-// 2 - that a new process object hasn't been recreated in its place
-
 // "debugserver_pid" argument passed in is the process ID for
 // debugserver that we are tracking...
 Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
-
-// Get a shared pointer to the target that has a matching process pointer.
-// This target could be gone, or the target could already have a new process
-// object inside of it
-TargetSP target_sp (Debugger::FindTargetWithProcess(process));
+const bool handled = true;
 
 if (log)
-log->Printf("ProcessGDBRemote::%s(process=%p, pid=%" PRIu64 ", signo=%i (0x%x), exit_status=%i)", __FUNCTION__,
-process, debugserver_pid, signo, signo, exit_status);
-
-if (target_sp)
-{
-// We found a process in a target that matches, but another thread
-// might be in the process of launching a new process that will
-// soon replace it, so get a shared pointer to the process so we
-// can keep it alive.
-ProcessSP process_sp (target_sp->GetProcessSP());
-// Now we have a shared pointer to the process that can't go away on us
-// so we now make sure it was the same as the one passed in, and also make
-// sure that our previous "process *" didn't get deleted and have a new
-// "process *" created in its place with the same pointer. To verify this
-// we make sure the process has our debugserver process ID. If we pass all
-// of these tests, then we are sure that this process is the one we were
-// looking for.
-if (process_sp && process == process_sp.get() && process->m_debugserver_pid == debugserver_pid)
-{
-// Sleep for a half a second to make sure our i

Re: [Lldb-commits] [PATCH] D15067: Add CMake bits necessary for standalone build

2016-05-12 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

@Eugene.Zelenko do you agree with this patch and what @labath wrote?


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



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


Re: [Lldb-commits] [PATCH] D15067: Add CMake bits necessary for standalone build

2016-05-12 Thread Pavel Labath via lldb-commits
labath accepted this revision.
labath added a comment.

In http://reviews.llvm.org/D15067#427848, @Eugene.Zelenko wrote:

> In http://reviews.llvm.org/D15067#427834, @krytarowski wrote:
>
> > In http://reviews.llvm.org/D15067#427814, @Eugene.Zelenko wrote:
> >
> > > I would like to see implemented my comment about LLVM_CONFIG and 
> > > find_program().
> >
> >
> > Could you first push this to clang? I don't want to drift from clang myself.
>
>
> I'm not sure about Clang make files, but I built Clang with LLVM. LLDB is 
> more problematic, so I build it standalone with previously build Clang. This 
> why I'd like to specify path in CMake parameters, not relying in 
> find_program().


From cmake documentation on find program:

  This command is used to find a program. A cache entry named by  is 
created to store the result of this command. If the program is found the result 
is stored in the variable and the search will not be repeated unless the 
variable is cleared. 

So, I think the functionality you request is already baked into find_program 
and we should not duplicate it. I made a quick test and setting the variable 
via `-DLLVM_CONFIG` on the cmake command line does indeed prevent find-program 
from doing anything. (which is not surprising, as it is a fairly common use 
case for people to want to specify their own paths to things...)

I think this is good to go know. I don't think we need to wait for @zturner, as 
his objections were about the regular expression thing, which has been removed 
now.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



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


Re: [Lldb-commits] [PATCH] D20188: Turn on LLDB_EDITLINE_USE_WCHAR on NetBSD

2016-05-12 Thread Kamil Rytarowski via lldb-commits
krytarowski removed rL LLVM as the repository for this revision.
krytarowski updated this revision to Diff 57011.

http://reviews.llvm.org/D20188

Files:
  include/lldb/Host/Editline.h

Index: include/lldb/Host/Editline.h
===
--- include/lldb/Host/Editline.h
+++ include/lldb/Host/Editline.h
@@ -27,11 +27,12 @@
 
 #include 
 #include 
+#include 
 
 // components needed to handle wide characters ( , codecvt_utf8, 
libedit built with '--enable-widec' )
-// are not consistenly available on non-OSX platforms.  The wchar_t versions 
of libedit functions will only be
+// are available on some platforms. The wchar_t versions of libedit functions 
will only be
 // used in cases where this is true.  This is a compile time dependecy, for 
now selected per target Platform
-#if defined (__APPLE__)
+#if defined (__APPLE__) || defined(__NetBSD__)
 #define LLDB_EDITLINE_USE_WCHAR 1
 #include 
 #else


Index: include/lldb/Host/Editline.h
===
--- include/lldb/Host/Editline.h
+++ include/lldb/Host/Editline.h
@@ -27,11 +27,12 @@
 
 #include 
 #include 
+#include 
 
 // components needed to handle wide characters ( , codecvt_utf8, libedit built with '--enable-widec' )
-// are not consistenly available on non-OSX platforms.  The wchar_t versions of libedit functions will only be
+// are available on some platforms. The wchar_t versions of libedit functions will only be
 // used in cases where this is true.  This is a compile time dependecy, for now selected per target Platform
-#if defined (__APPLE__)
+#if defined (__APPLE__) || defined(__NetBSD__)
 #define LLDB_EDITLINE_USE_WCHAR 1
 #include 
 #else
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D20188: Turn on LLDB_EDITLINE_USE_WCHAR on NetBSD

2016-05-12 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

I changed the string to "some platforms".


http://reviews.llvm.org/D20188



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


Re: [Lldb-commits] [PATCH] D20193: test infra: catch bad decorators and import-time errors

2016-05-12 Thread Pavel Labath via lldb-commits
labath added a comment.

I'm glad to see this getting fixed. I have a couple comments though. :)



Comment at: packages/Python/lldbsuite/test/dotest.py:695
@@ -694,3 +694,3 @@
 
 # Try to match the regexp pattern, if specified.
 if configuration.regexp:

This function (`visit`) is getting quite big, and due to the way it's 
structured, you were forced to duplicate some code. We could solve both 
problems with a bit of refactoring.

How about this:
- put everything inside the for loop below this line into a separate function 
(`visit_file` ?)
- put the try-catch block around the call to `visit_file` in this function

This way we will have less duplication and will reduce the nesting depth of 
this function.

What do you think?


Comment at: packages/Python/lldbsuite/test/dotest.py:725
@@ +724,3 @@
+test_filename = os.path.abspath(os.path.join(dir, name))
+if test_filename.endswith(".pyc"):
+test_filename = test_filename[0:-1]

Will this ever be executed? I mean, if we get a pyc file, we shouldn't even get 
here due to the check on line 689.


Comment at: packages/Python/lldbsuite/test_event/formatter/pickled.py:57
@@ +56,3 @@
+# end.
+if self.use_send:
+# Send it as 
{serialized_length_of_serialized_bytes}{serialized_bytes}

Why do we need the format to be different based on the kind of object we are 
writing to? The added magic (introspection) seems like a bad tradeoff, if all 
it does is avoid a couple of lines in `event_collector.py`


Comment at: 
packages/Python/lldbsuite/test_event/test/src/TestCatchInvalidDecorator.py:38
@@ +37,3 @@
+
+self.assertTrue(
+len(results) > 0,

I don't fully understand the whole event collector logic yet, but I would 
expect to see a check that the returned result is in fact an error result, no?

(Also, I prefer using `assertGreater(foo, bar)`, as it provides a more 
descriptive error message.)


Comment at: packages/Python/lldbsuite/test_event/test/src/event_collector.py:25
@@ +24,3 @@
+def pickled_events_filename():
+return "/tmp/lldb_test_event_pickled_event_output.dat"
+

I'm pretty sure this won't work on windows.. :)
`tempfile.NamedTemporaryFile` looks like a portable alternative.


http://reviews.llvm.org/D20193



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