[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 94374.
beanz added a comment.

Some cleanup to the test case:

- Auto-select a port, which will make this more reliable
- Open listening sockets before the fork() so that the sockets are ready for 
connection (this avoids a race)
- Put test logic into reusable functions so that test logic can be reused for 
IPv6 tests when I add them


https://reviews.llvm.org/D31357

Files:
  tools/debugserver/source/CMakeLists.txt
  tools/debugserver/source/MacOSX/CMakeLists.txt
  unittests/CMakeLists.txt
  unittests/debugserver/CMakeLists.txt
  unittests/debugserver/RNBSocketTest.cpp
  unittests/debugserver/debugserver_LogCallback.cpp

Index: unittests/debugserver/debugserver_LogCallback.cpp
===
--- /dev/null
+++ unittests/debugserver/debugserver_LogCallback.cpp
@@ -0,0 +1,20 @@
+//===-- debugserver_LogCallback.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+//--
+// this function is defined in debugserver.cpp, but is needed to link the
+// debugserver Common library. It is for logging only, so it is left
+// unimplemented here.
+//--
+
+#include 
+#include 
+
+void FileLogCallback(void *baton, uint32_t flags, const char *format,
+ va_list args) {}
Index: unittests/debugserver/RNBSocketTest.cpp
===
--- /dev/null
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,137 @@
+//===-- RNBSocketTest.cpp ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include 
+#include 
+#include 
+
+#include "RNBSocket.h"
+#include "RNBDefs.h"
+#include "lldb/Host/Socket.h"
+#include "lldb/Host/StringConvert.h"
+#include "lldb/Host/common/TCPSocket.h"
+
+using namespace lldb_private;
+
+std::string Hello = "Hello, world!";
+std::string Goodbye = "Goodbye!";
+
+static void ServerCallbackv4(const void *baton, in_port_t port) {
+  auto ChildPID = fork();
+  if (ChildPID == 0) {
+Socket *ClientSocket;
+char AddrBuffer[256];
+sprintf(AddrBuffer, "%s:%d", baton, port);
+Error Err = Socket::TcpConnect(AddrBuffer, false, ClientSocket);
+if (Err.Fail())
+  abort();
+char Buffer[32];
+size_t ReadSize = 32;
+Err = ClientSocket->Read((void *)&Buffer[0], ReadSize);
+if (Err.Fail())
+  abort();
+std::string Recv(&Buffer[0], ReadSize);
+if (Recv != Hello)
+  abort();
+size_t WriteSize = Goodbye.length();
+Err = ClientSocket->Write(Goodbye.c_str(), WriteSize);
+if (Err.Fail())
+  abort();
+if (WriteSize != Goodbye.length())
+  abort();
+delete ClientSocket;
+exit(0);
+  }
+}
+
+void TestSocketListen(const char * addr) {
+  RNBSocket ServerSocket;
+  auto result =
+  ServerSocket.Listen(addr, 0, ServerCallbackv4, (const void *)addr);
+  ASSERT_TRUE(result == rnb_success);
+  result = ServerSocket.Write(Hello.c_str(), Hello.length());
+  ASSERT_TRUE(result == rnb_success);
+  std::string Bye;
+  result = ServerSocket.Read(Bye);
+  ASSERT_TRUE(result == rnb_success);
+  ASSERT_EQ(Bye, Goodbye);
+
+  int exit_status;
+  wait(&exit_status);
+  ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  TestSocketListen("127.0.0.1");
+}
+
+void TestSocketConnect(const char *addr) {
+  char addr_wrap[256];
+  sprintf(addr_wrap, "%s:0", addr);
+  
+  Socket *ServerSocket;
+  Predicate PortPredicate;
+  PortPredicate.SetValue(0, eBroadcastNever);
+  Error Err =
+  Socket::TcpListen(addr_wrap, false, ServerSocket, &PortPredicate);
+  ASSERT_FALSE(Err.Fail());
+
+  auto port = ((TCPSocket*)ServerSocket)->GetLocalPortNumber();
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ClientSocket;
+auto result = ClientSocket.Connect(addr, port);
+ASSERT_TRUE(result == rnb_success);
+result = ClientSocket.Write(Hello.c_str(), Hello.length());
+ASSERT_TRUE(result == rnb_success);
+std::string Bye;
+result = ClientSocket.Read(Bye);
+ASSERT_TRUE(result == rnb_success);
+ASSERT_EQ(Bye, Goodbye);
+  } else {
+Socket *ConnectedSocket;
+Err = ServerSocket->Accept(addr_wrap, false, ConnectedSocket);
+if (Err.Fail()) {
+  llvm::errs() << Err.AsCString();
+  abort();
+}
+char Buffer[32];
+size_t ReadSize

[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a reviewer: jingham.
beanz added a comment.

Adding Jim as a reviewer.

Jim, with the added comment about debugserver being Darwin-only, are you happy 
with this patch?


https://reviews.llvm.org/D31357



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


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

On the small points side: for lldb code we use lower-case, _ separated names 
for local variables, the point being that it allow you to tell at a glance 
what's a local and what's an ivar.  Looks like you use a mixture of the two 
styles?  exit_status, result, etc. alongside WriteSize, etc...  It doesn't 
matter as much for a test case, but still it's good to be consistent.

More substantial, what happens to a gtest case if the test case program aborts? 
 Remembering that the way the world works, this failure is bound to happen only 
intermittently on some server you can't access, so it's good to collect as much 
info as you can on failure.  If the tests report a good stack trace on abort, 
that's probably fine, but otherwise it would be good to figure out a way to 
back out and leave some trace.


https://reviews.llvm.org/D31357



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


[Lldb-commits] [PATCH] D31357: Support Unit Testing debugserver

2017-04-06 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

I will fix up the naming conventions. Switching back and forth between LLVM and 
LLDB conventions has done a number on my brain.

The test cases only abort on the child process side of the fork calls. This 
results in printing a stack trace, but it also will get captured as a failure 
because the parent process side checks the exit status of the child.


https://reviews.llvm.org/D31357



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


[Lldb-commits] [lldb] r299676 - iwyu fixes on lldbUtility.

2017-04-06 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Apr  6 13:12:24 2017
New Revision: 299676

URL: http://llvm.org/viewvc/llvm-project?rev=299676&view=rev
Log:
iwyu fixes on lldbUtility.

This patch makes adjustments to header file includes in
lldbUtility based on recommendations by the iwyu tool
(include-what-you-use).  The goal here is to make sure that
all files include the exact set of headers which are needed
for that file only, to eliminate cases of dead includes (e.g.
someone deleted some code but forgot to delete the header
includes that that code necessitated), and to eliminate the
case where header includes are picked up transitively.

Modified:
lldb/trunk/include/lldb/Core/ArchSpec.h
lldb/trunk/include/lldb/Host/Symbols.h
lldb/trunk/include/lldb/Symbol/DeclVendor.h
lldb/trunk/include/lldb/Utility/Baton.h
lldb/trunk/include/lldb/Utility/ConstString.h
lldb/trunk/include/lldb/Utility/DataBufferHeap.h
lldb/trunk/include/lldb/Utility/DataBufferLLVM.h
lldb/trunk/include/lldb/Utility/DataEncoder.h
lldb/trunk/include/lldb/Utility/DataExtractor.h
lldb/trunk/include/lldb/Utility/Error.h
lldb/trunk/include/lldb/Utility/FileSpec.h
lldb/trunk/include/lldb/Utility/History.h
lldb/trunk/include/lldb/Utility/JSON.h
lldb/trunk/include/lldb/Utility/LLDBAssert.h
lldb/trunk/include/lldb/Utility/Log.h
lldb/trunk/include/lldb/Utility/Range.h
lldb/trunk/include/lldb/Utility/RegularExpression.h
lldb/trunk/include/lldb/Utility/SelectHelper.h
lldb/trunk/include/lldb/Utility/SharingPtr.h
lldb/trunk/include/lldb/Utility/Stream.h
lldb/trunk/include/lldb/Utility/StreamCallback.h
lldb/trunk/include/lldb/Utility/StreamGDBRemote.h
lldb/trunk/include/lldb/Utility/StreamString.h
lldb/trunk/include/lldb/Utility/StringExtractor.h
lldb/trunk/include/lldb/Utility/StringLexer.h
lldb/trunk/include/lldb/Utility/StringList.h
lldb/trunk/include/lldb/Utility/TaskPool.h
lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h
lldb/trunk/include/lldb/Utility/UUID.h
lldb/trunk/include/lldb/Utility/UserID.h
lldb/trunk/include/lldb/Utility/VMRange.h
lldb/trunk/source/Host/common/Editline.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
lldb/trunk/source/Utility/Baton.cpp
lldb/trunk/source/Utility/ConstString.cpp
lldb/trunk/source/Utility/DataBufferLLVM.cpp
lldb/trunk/source/Utility/DataEncoder.cpp
lldb/trunk/source/Utility/DataExtractor.cpp
lldb/trunk/source/Utility/Error.cpp
lldb/trunk/source/Utility/FastDemangle.cpp
lldb/trunk/source/Utility/FileSpec.cpp
lldb/trunk/source/Utility/JSON.cpp
lldb/trunk/source/Utility/LLDBAssert.cpp
lldb/trunk/source/Utility/Log.cpp
lldb/trunk/source/Utility/Logging.cpp
lldb/trunk/source/Utility/Range.cpp
lldb/trunk/source/Utility/RegularExpression.cpp
lldb/trunk/source/Utility/SelectHelper.cpp
lldb/trunk/source/Utility/Stream.cpp
lldb/trunk/source/Utility/StreamCallback.cpp
lldb/trunk/source/Utility/StreamGDBRemote.cpp
lldb/trunk/source/Utility/StreamString.cpp
lldb/trunk/source/Utility/StringExtractor.cpp
lldb/trunk/source/Utility/StringExtractorGDBRemote.cpp
lldb/trunk/source/Utility/StringExtractorGDBRemote.h
lldb/trunk/source/Utility/StringLexer.cpp
lldb/trunk/source/Utility/StringList.cpp
lldb/trunk/source/Utility/TaskPool.cpp
lldb/trunk/source/Utility/TildeExpressionResolver.cpp
lldb/trunk/source/Utility/UUID.cpp
lldb/trunk/source/Utility/UriParser.cpp
lldb/trunk/source/Utility/VASprintf.cpp
lldb/trunk/source/Utility/VMRange.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp
lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=299676&r1=299675&r2=299676&view=diff
==
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Thu Apr  6 13:12:24 2017
@@ -13,7 +13,9 @@
 #if defined(__cplusplus)
 
 #include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
+#include "lldb/lldb-private-enumerations.h"
 #include "llvm/ADT/Triple.h"
 
 namespace lldb_private {

Modified: lldb/trunk/include/lldb/Host/Symbols.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Symbols.h?rev=299676&r1=299675&r2=299676&view=diff
==
--- lldb/trunk/include/lldb/Host/Symbols.h (original)
+++ lldb/trunk/include/lldb/Host/Symbols.h Thu Apr  6 13:12:24 2017
@@ -20,6 +20,10 @@
 
 namespace lldb_private {
 
+class ArchSpec;
+class ModuleSpec;
+class UUID;
+
 class Symbols {
 public:
   //---

[Lldb-commits] [lldb] r299677 - XFAIL TestDataFormatterLibcxxVBool on Linux & Android

2017-04-06 Thread Tamas Berghammer via lldb-commits
Author: tberghammer
Date: Thu Apr  6 13:15:43 2017
New Revision: 299677

URL: http://llvm.org/viewvc/llvm-project?rev=299677&view=rev
Log:
XFAIL TestDataFormatterLibcxxVBool on Linux & Android

The skipping logic for the test have been fixed recently but the test is
very flakey on the buildbot.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py?rev=299677&r1=299676&r2=299677&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py
 Thu Apr  6 13:15:43 2017
@@ -24,6 +24,7 @@ class LibcxxVBoolDataFormatterTestCase(T
 self.line = line_number('main.cpp', '// Set break point at this line.')
 
 @add_test_categories(["libc++"])
+@expectedFailureAll(oslist=["linux"], bugnumber="llvm.org/pr32553")
 def test_with_run_command(self):
 """Test that that file and class static variables display correctly."""
 self.build()


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


[Lldb-commits] [PATCH] D31784: Correct environ parsing on NetBSD

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

This replaces old code in Host::GetEnvironment for NetBSD
with the version from Linux. This makes parsing environment
variables correctly. It also fixes programs that depend on the
variables like curses(3) applications.

Long term this function should be moved to Process Plugin,
as currently env variables are not available with remote
debugging.

Other BSDs might want to catch up after this change.

Tested with NetBSD top(1).

Sponsored by 


Repository:
  rL LLVM

https://reviews.llvm.org/D31784

Files:
  source/Host/netbsd/Host.cpp


Index: source/Host/netbsd/Host.cpp
===
--- source/Host/netbsd/Host.cpp
+++ source/Host/netbsd/Host.cpp
@@ -52,15 +52,12 @@
 using namespace lldb_private;
 
 size_t Host::GetEnvironment(StringList &env) {
-  char *v;
-  char **var = environ;
-  for (; var != NULL && *var != NULL; ++var) {
-v = ::strchr(*var, (int)'-');
-if (v == NULL)
-  continue;
-env.AppendString(v);
-  }
-  return env.GetSize();
+  char **host_env = environ;
+  char *env_entry;
+  size_t i;
+  for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+env.AppendString(env_entry);
+  return i;
 }
 
 static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch 
*match_info_ptr,


Index: source/Host/netbsd/Host.cpp
===
--- source/Host/netbsd/Host.cpp
+++ source/Host/netbsd/Host.cpp
@@ -52,15 +52,12 @@
 using namespace lldb_private;
 
 size_t Host::GetEnvironment(StringList &env) {
-  char *v;
-  char **var = environ;
-  for (; var != NULL && *var != NULL; ++var) {
-v = ::strchr(*var, (int)'-');
-if (v == NULL)
-  continue;
-env.AppendString(v);
-  }
-  return env.GetSize();
+  char **host_env = environ;
+  char *env_entry;
+  size_t i;
+  for (i = 0; (env_entry = host_env[i]) != NULL; ++i)
+env.AppendString(env_entry);
+  return i;
 }
 
 static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r299705 - Try to fix FreeBSD build after iwyu changes.

2017-04-06 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Apr  6 15:51:22 2017
New Revision: 299705

URL: http://llvm.org/viewvc/llvm-project?rev=299705&view=rev
Log:
Try to fix FreeBSD build after iwyu changes.

Modified:
lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp

Modified: lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp?rev=299705&r1=299704&r2=299705&view=diff
==
--- lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp (original)
+++ lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp Thu Apr  6 15:51:22 2017
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace lldb_private;
 


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


[Lldb-commits] [lldb] r299718 - Fix build failure in unit test.

2017-04-06 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Apr  6 16:57:39 2017
New Revision: 299718

URL: http://llvm.org/viewvc/llvm-project?rev=299718&view=rev
Log:
Fix build failure in unit test.

Modified:
lldb/trunk/unittests/Core/BroadcasterTest.cpp

Modified: lldb/trunk/unittests/Core/BroadcasterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/BroadcasterTest.cpp?rev=299718&r1=299717&r2=299718&view=diff
==
--- lldb/trunk/unittests/Core/BroadcasterTest.cpp (original)
+++ lldb/trunk/unittests/Core/BroadcasterTest.cpp Thu Apr  6 16:57:39 2017
@@ -10,6 +10,7 @@
 #include "gtest/gtest.h"
 
 #include "lldb/Core/Broadcaster.h"
+#include "lldb/Core/Event.h"
 #include "lldb/Core/Listener.h"
 #include "lldb/Host/Predicate.h"
 


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


[Lldb-commits] [lldb] r299719 - Try to fix FreeBSD build after IWYU changes.

2017-04-06 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Thu Apr  6 17:18:59 2017
New Revision: 299719

URL: http://llvm.org/viewvc/llvm-project?rev=299719&view=rev
Log:
Try to fix FreeBSD build after IWYU changes.

Modified:
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=299719&r1=299718&r2=299719&view=diff
==
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Thu Apr  6 
17:18:59 2017
@@ -24,6 +24,7 @@
 
 // Other libraries and framework includes
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegisterValue.h"
 #include "lldb/Core/State.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Symbol/ObjectFile.h"


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


[Lldb-commits] [Diffusion] rL299714: iwyu fixes for lldbCore.

2017-04-06 Thread Tamas Berghammer via Phabricator via lldb-commits
tberghammer added subscribers: lldb-commits, tberghammer.
tberghammer added inline comments.

/lldb/trunk/include/lldb/Core/Address.h:21-50 I think we should try to merge 
these namespace definitions as in my view the current syntax makes the top of 
the file very noisy. What do you think?

Users:
  zturner (Author)

https://reviews.llvm.org/rL299714



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


Re: [Lldb-commits] [Diffusion] rL299714: iwyu fixes for lldbCore.

2017-04-06 Thread Zachary Turner via lldb-commits
Agreed.  Before I clang-formatted it, it looked fine, because each
definition was on a single line.  But clang-format made them 3 lines each.
So yea, we should definitely merge them.  I was copy/pasting the output
from IWYU, which is why it looks this way.  Thanks for bringing it up

On Thu, Apr 6, 2017 at 3:32 PM Tamas Berghammer via Phabricator <
revi...@reviews.llvm.org> wrote:

> tberghammer added subscribers: lldb-commits, tberghammer.
> tberghammer added inline comments.
>
> /lldb/trunk/include/lldb/Core/Address.h:21-50 I think we should try to
> merge these namespace definitions as in my view the current syntax makes
> the top of the file very noisy. What do you think?
>
> Users:
>   zturner (Author)
>
> https://reviews.llvm.org/rL299714
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r299721 - New C++ function name parsing logic (Resubmit)

2017-04-06 Thread Eugene Zemtsov via lldb-commits
Author: eugene
Date: Thu Apr  6 17:36:02 2017
New Revision: 299721

URL: http://llvm.org/viewvc/llvm-project?rev=299721&view=rev
Log:
New C++ function name parsing logic (Resubmit)

Current implementation of CPlusPlusLanguage::MethodName::Parse() doesn't
get anywhere close to covering full extent of possible function declarations.
It causes incorrect behavior in avoid-stepping and sometimes messes
printing of thread backtrace.

This change implements more methodical parsing logic based on clang
lexer and simple recursive parser.

Examples:
void std::vector>::_M_emplace_back_aux(Class const&)
void (*&std::_Any_data::_M_access())()

Previous version of this change (D31451) was rolled back due to an issue
with Objective-C selectors being incorrectly recognized as a C++ identifier.

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

Added:
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=299721&r1=299720&r2=299721&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Apr  6 17:36:02 2017
@@ -712,6 +712,7 @@
49DCF702170E70120092F75E /* Materializer.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 49DCF700170E70120092F75E /* Materializer.cpp */; 
};
49DEF1251CD7C6DF006A7C7D /* BlockPointer.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 49DEF11F1CD7BD90006A7C7D /* BlockPointer.cpp */; 
};
49E4F66B1C9CAD16008487EA /* DiagnosticManager.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 49E4F6681C9CAD12008487EA /* 
DiagnosticManager.cpp */; };
+   49F811F31E931B2100F4E163 /* CPlusPlusNameParser.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 49F811EF1E931B1500F4E163 /* 
CPlusPlusNameParser.cpp */; };
4C0083401B9F9BA900D5CF24 /* UtilityFunction.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C00833F1B9F9BA900D5CF24 /* UtilityFunction.cpp 
*/; };
4C2479BD1BA39295009C9A7B /* FunctionCaller.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4C0083321B9A5DE200D5CF24 /* FunctionCaller.cpp 
*/; };
4C3ADCD61810D88B00357218 /* BreakpointResolverFileRegex.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 4CAA56141422D986001FFA01 /* 
BreakpointResolverFileRegex.cpp */; };
@@ -2474,6 +2475,8 @@
49EC3E9C118F90D400B1265E /* ThreadPlanCallFunction.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name 
= ThreadPlanCallFunction.h; path = 
include/lldb/Target/ThreadPlanCallFunction.h; sourceTree = ""; };
49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.cpp.cpp; name = ClangExpressionDeclMap.cpp; path = 
ExpressionParser/Clang/ClangExpressionDeclMap.cpp; sourceTree = ""; };
49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */ = {isa 
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name 
= ClangExpressionDeclMap.h; path = 
ExpressionParser/Clang/ClangExpressionDeclMap.h; sourceTree = ""; };
+   49F811EF1E931B1500F4E163 /* CPlusPlusNameParser.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = CPlusPlusNameParser.cpp; path = 
Language/CPlusPlus/CPlusPlusNameParser.cpp; sourceTree = ""; };
+   49F811F01E931B1500F4E163 /* CPlusPlusNameParser.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
CPlusPlusNameParser.h; path = Language/CPlusPlus/CPlusPlusNameParser.h; 
sourceTree = ""; };
4C00832C1B9A58A700D5CF24 /* Expression.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
Expression.h; path = include/lldb/Expression/Expression.h; sourceTree = 
""; };
4C00832D1B9A58A700D5CF24 /* FunctionCaller.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
FunctionCaller.h; path = include/lldb/Expression/FunctionCaller.h; sourceTree = 
""; };
4C00832E1B9A58A700D5CF24 /* UserExpression.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
UserExpression.h; path = include/lldb/Expression/UserExpression.h; sourceTree = 
""; };
@@ -6108,6 +6111,

[Lldb-commits] [PATCH] D31451: New C++ function name parsing logic

2017-04-06 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I'm sorry, I don't have time actually review the code here for correctness...  
But can you make sure that this also rejects a two or three field selector, not 
just "selector:" but "selector:otherField:"?  That seems sufficiently different 
that you might get the one : but not the two : form right.  You could test 3 & 
more colons, but at that point it's probably overkill.


Repository:
  rL LLVM

https://reviews.llvm.org/D31451



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


[Lldb-commits] [lldb] r299729 - Add more tests for ExtractContextAndIdentifier

2017-04-06 Thread Eugene Zemtsov via lldb-commits
Author: eugene
Date: Thu Apr  6 18:12:43 2017
New Revision: 299729

URL: http://llvm.org/viewvc/llvm-project?rev=299729&view=rev
Log:
Add more tests for ExtractContextAndIdentifier

Modified:
lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Modified: lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp?rev=299729&r1=299728&r2=299729&view=diff
==
--- lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp (original)
+++ lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp Thu Apr  
6 18:12:43 2017
@@ -124,6 +124,7 @@ TEST(CPlusPlusLanguage, ExtractContextAn
 
   TestCase test_cases[] = {
   {"main", "", "main"},
+  {"main ", "", "main"},
   {"foo01::bar", "foo01", "bar"},
   {"foo::~bar", "foo", "~bar"},
   {"std::vector::push_back", "std::vector", "push_back"},
@@ -150,4 +151,8 @@ TEST(CPlusPlusLanguage, ExtractContextAn
   CPlusPlusLanguage::ExtractContextAndIdentifier("", context, basename));
   EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "selector:", context, basename));
+  EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+  "selector:otherField:", context, basename));
+  EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
+  "abc::", context, basename));
 }


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


Re: [Lldb-commits] [PATCH] D31451: New C++ function name parsing logic

2017-04-06 Thread Eugene Zemtsov via lldb-commits
Thanks for vigilance. I added a couple more tests in r299729.

On Thu, Apr 6, 2017 at 4:06 PM, Jim Ingham via Phabricator <
revi...@reviews.llvm.org> wrote:

> jingham added a comment.
>
> I'm sorry, I don't have time actually review the code here for
> correctness...  But can you make sure that this also rejects a two or three
> field selector, not just "selector:" but "selector:otherField:"?  That
> seems sufficiently different that you might get the one : but not the two :
> form right.  You could test 3 & more colons, but at that point it's
> probably overkill.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D31451
>
>
>
>


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