[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-27 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 93130.
nitesh.jain added a comment.

Update diff as per suggestion.

Thanks


https://reviews.llvm.org/D31280

Files:
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabi64.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mips64el-gnuabin32.out
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.core
  
packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-mipsel-gnuabio32.out
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.cpp

Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -214,9 +214,12 @@
   // Even if the architecture is set in the target, we need to override
   // it to match the core file which is always single arch.
   ArchSpec arch(m_core_module_sp->GetArchitecture());
-  if (arch.IsValid())
-GetTarget().SetArchitecture(arch);
 
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  ArchSpec core_arch(m_core_module_sp->GetArchitecture());
+  target_arch.MergeFrom(core_arch);
+  GetTarget().SetArchitecture(target_arch);
+ 
   SetUnixSignals(UnixSignals::Create(GetArchitecture()));
 
   // Ensure we found at least one thread that was stopped on a signal.
@@ -370,6 +373,10 @@
   lldb::addr_t bytes_left =
   0; // Number of bytes available in the core file from the given address
 
+  // Don't proceed if core file doesn't contain the actual data for this address range.
+  if (file_start == file_end)
+return 0;
+
   // Figure out how many on-disk bytes remain in this segment
   // starting at the given offset
   if (file_end > file_start + offset)
@@ -588,6 +595,8 @@
 // The result from FXSAVE is in NT_PRXFPREG for i386 core files
 if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
   thread_data->fpregset = note_data;
+else if(arch.IsMIPS())
+  thread_data->fpregset = note_data;
 break;
   case NT_PRPSINFO:
 have_prpsinfo = true;
@@ -655,6 +664,12 @@
   (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
   ArchSpec arch;
   core_file->GetArchitecture(arch);
+
+  ArchSpec target_arch = GetTarget().GetArchitecture();
+  
+  if (target_arch.IsMIPS())
+return target_arch;
+
   return arch;
 }
 
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -287,10 +287,26 @@
   return kal_arch_variant;
 }
 
-static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags,
-uint32_t endian) {
-  const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH;
+static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
+  const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
+  uint32_t endian = header.e_ident[EI_DATA];
   uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
+  uint32_t fileclass = header.e_ident[EI_CLASS];
+
+  // If there aren't any elf flags available (e.g core elf file) then return default 
+  // 32 or 64 bit arch (without any architecture revision) based on object file's class.
+  if (header.e_type == ET_CORE) {
+switch (fileclass) {
+case llvm::ELF::ELFCLASS32:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el
+ : ArchSpec::eMIPSSubType_mips32;
+case llvm::ELF::ELFCLASS64:
+  return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el
+ : ArchSpec::eMIPSSubType_mips64;
+default:
+  return arch_variant;
+}
+  }
 
   switch (mips_arch) {
   case llvm::ELF::EF_MIPS_ARCH_1:
@@ -325,7 +341,7 @@
 
 static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
   if (header.e_machine == llvm::ELF::EM_MIPS)
-return mipsVariantFromElfFlags(header.e_flags, header.e_ident[EI_DATA]);
+return mipsVariantFromElfFlags(header);
 
   return llvm::ELF::EM_CSR_KALIMBA == header.e_machine
  ? kalimbaVariantFromElfFlags(header.e_flags)
@@ -1348,6 +1364,10 @@
 }
 break;
   }
+  if (arch_spec.IsMIPS() &&
+  arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS)
+// The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
+arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
 

[Lldb-commits] [PATCH] D31335: Allow getCompiler to return None in the test suite

2017-03-27 Thread Francis Ricci via Phabricator via lldb-commits
fjricci abandoned this revision.
fjricci added a comment.

I primarily wrote this because `getArchFlag()` accounts for the possibility 
that `getCompiler()` can be None. But my problem was unrelated, so I don't need 
this (and I agree that it would be surprising if anyone did).


https://reviews.llvm.org/D31335



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


[Lldb-commits] [PATCH] D31280: [LLDB][MIPS] Fix Core file Architecture and OS information

2017-03-27 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

Looks good


https://reviews.llvm.org/D31280



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


[Lldb-commits] [PATCH] D31368: Add support for sythetic operator dereference

2017-03-27 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

The idea here seems fine, but why does StackFrame have to know the magic 
$$dereference$$?  Why can't it call the Dereference on the synthetic value?


https://reviews.llvm.org/D31368



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


[Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default

2017-03-27 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

This test compiles correctly on Darwin if you pass the --std=c++11 flag.  
lldbtest has a getstdFlag that returns the correct std value in this case.  Can 
you get the test running on Darwin with this?

Other than that this looks fine to me.


https://reviews.llvm.org/D31366



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


[Lldb-commits] [lldb] r298874 - Fix the Xcode project for OpenBSD additions.

2017-03-27 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Mon Mar 27 14:03:11 2017
New Revision: 298874

URL: http://llvm.org/viewvc/llvm-project?rev=298874&view=rev
Log:
Fix the Xcode project for OpenBSD additions.

Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=298874&r1=298873&r2=298874&view=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Mar 27 14:03:11 2017
@@ -735,6 +735,9 @@
4CD0BD0F134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 4CD0BD0E134BFADF00CB44D4 /* 
ValueObjectDynamicValue.cpp */; };
4CDB8D6D1DBA91B6006C5B13 /* LibStdcppUniquePointer.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 4CDB8D671DBA91A6006C5B13 /* 
LibStdcppUniquePointer.cpp */; };
4CDB8D6E1DBA91B6006C5B13 /* LibStdcppTuple.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4CDB8D681DBA91A6006C5B13 /* LibStdcppTuple.cpp 
*/; };
+   4CE4EFAA1E8999B900A80C06 /* PlatformOpenBSD.cpp in Sources */ = 
{isa = PBXBuildFile; fileRef = 4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp 
*/; };
+   4CE4EFB31E899A3400A80C06 /* RegisterContextOpenBSD_i386.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFAB1E899A1200A80C06 /* 
RegisterContextOpenBSD_i386.cpp */; };
+   4CE4EFB41E899A4000A80C06 /* RegisterContextOpenBSD_x86_64.cpp 
in Sources */ = {isa = PBXBuildFile; fileRef = 4CE4EFAD1E899A1200A80C06 /* 
RegisterContextOpenBSD_x86_64.cpp */; };
4CE4F673162C971A00F75CB3 /* SBExpressionOptions.h in Headers */ 
= {isa = PBXBuildFile; fileRef = 4CE4F672162C971A00F75CB3 /* 
SBExpressionOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
4CE4F675162C973F00F75CB3 /* SBExpressionOptions.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 4CE4F674162C973F00F75CB3 /* 
SBExpressionOptions.cpp */; };
4CF3D80C15AF4DC800845BF3 /* Security.framework in Frameworks */ 
= {isa = PBXBuildFile; fileRef = EDB919B414F6F10D008FF64B /* Security.framework 
*/; };
@@ -2549,6 +2552,12 @@
4CD0BD0E134BFADF00CB44D4 /* ValueObjectDynamicValue.cpp */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.cpp.cpp; name = ValueObjectDynamicValue.cpp; path = 
source/Core/ValueObjectDynamicValue.cpp; sourceTree = ""; };
4CDB8D671DBA91A6006C5B13 /* LibStdcppUniquePointer.cpp */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.cpp.cpp; name = LibStdcppUniquePointer.cpp; path = 
Language/CPlusPlus/LibStdcppUniquePointer.cpp; sourceTree = ""; };
4CDB8D681DBA91A6006C5B13 /* LibStdcppTuple.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = LibStdcppTuple.cpp; path = Language/CPlusPlus/LibStdcppTuple.cpp; 
sourceTree = ""; };
+   4CE4EFA61E8999B000A80C06 /* PlatformOpenBSD.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
path = PlatformOpenBSD.cpp; sourceTree = ""; };
+   4CE4EFA71E8999B000A80C06 /* PlatformOpenBSD.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
PlatformOpenBSD.h; sourceTree = ""; };
+   4CE4EFAB1E899A1200A80C06 /* RegisterContextOpenBSD_i386.cpp */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.cpp.cpp; name = RegisterContextOpenBSD_i386.cpp; path = 
Utility/RegisterContextOpenBSD_i386.cpp; sourceTree = ""; };
+   4CE4EFAC1E899A1200A80C06 /* RegisterContextOpenBSD_i386.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
name = RegisterContextOpenBSD_i386.h; path = 
Utility/RegisterContextOpenBSD_i386.h; sourceTree = ""; };
+   4CE4EFAD1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.cpp 
*/ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.cpp.cpp; name = RegisterContextOpenBSD_x86_64.cpp; path = 
Utility/RegisterContextOpenBSD_x86_64.cpp; sourceTree = ""; };
+   4CE4EFAE1E899A1200A80C06 /* RegisterContextOpenBSD_x86_64.h */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.h; name = RegisterContextOpenBSD_x86_64.h; path = 
Utility/RegisterContextOpenBSD_x86_64.h; sourceTree = ""; };
4CE4F672162C971A00F75CB3 /* SBExpressionOptions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
SBExpressionOptions.h; path = include/lldb/API/SBExpressionOptions.h; 
sourceTree = ""; };
4CE4F674162C973F00F75CB3 /* SBExpressionOptions.cpp */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; 
name = S

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

2017-03-27 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 93165.
beanz added a comment.

Fleshed out the unit test logic to be more meaningful.


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,109 @@
+//===-- 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 "RNBSocket.h"
+#include "RNBDefs.h"
+#include "lldb/Host/Socket.h"
+
+using namespace lldb_private;
+
+static void ServerCallback(const void *baton, in_port_t port) {}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  std::string Hello = "Hello, world!";
+  std::string Goodbye = "Goodbye!";
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ServerSocket;
+auto result = ServerSocket.Listen("localhost", 4242, ServerCallback, NULL);
+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);
+  } else {
+Socket *ClientSocket;
+Error Err = Socket::TcpConnect("localhost:4242", 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();
+exit(0);
+  }
+  int exit_status;
+  wait(&exit_status);
+  ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackConnectIPv4) {
+  Socket *ServerSocket;
+  Predicate PortPredicate;
+  PortPredicate.SetValue(0, eBroadcastNever);
+  Error Err = Socket::TcpListen("localhost:4242", false, ServerSocket,
+&PortPredicate);
+  ASSERT_FALSE(Err.Fail());
+
+  std::string Hello = "Hello, world!";
+  std::string Goodbye = "Goodbye!";
+
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ClientSocket;
+auto result = ClientSocket.Connect("localhost", 4242);
+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("localhost:4242", false, ConnectedSocket);
+if (Err.Fail())
+  abort();
+char Buffer[32];
+size_t ReadSize = 32;
+Err = ConnectedSocket->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 = ConnectedSocket->Write(Goodbye.c_str(), WriteSize);
+if (Err.Fail())
+  abort();
+if (WriteSize != Goodbye.length())
+  abort();
+exit(0);
+  }
+  int exit_status;
+  wait(&exit_status);
+  ASSERT_EQ(exit_status, 0);
+}
Index: unittests/debugserver/CMakeLists.txt
==

[Lldb-commits] [lldb] r298876 - In FileSpec::Equal, short-cut GetNormalizedPath.

2017-03-27 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Mon Mar 27 14:12:25 2017
New Revision: 298876

URL: http://llvm.org/viewvc/llvm-project?rev=298876&view=rev
Log:
In FileSpec::Equal, short-cut GetNormalizedPath.

GetNormalizedPath seems to be slow, so it's worth
shortcutting it if possible.  This change does so
when the filenames and not equal and we can tell
GetNormalizedPath would not make them equal.

Also added a test for "." final component since that
was missing.

Modified:
lldb/trunk/source/Utility/FileSpec.cpp
lldb/trunk/unittests/Host/FileSpecTest.cpp

Modified: lldb/trunk/source/Utility/FileSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=298876&r1=298875&r2=298876&view=diff
==
--- lldb/trunk/source/Utility/FileSpec.cpp (original)
+++ lldb/trunk/source/Utility/FileSpec.cpp Mon Mar 27 14:12:25 2017
@@ -401,11 +401,36 @@ int FileSpec::Compare(const FileSpec &a,
 
 bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full,
  bool remove_backups) {
+  static ConstString g_dot_string(".");
+  static ConstString g_dot_dot_string("..");
+
   // case sensitivity of equality test
   const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive();
+  
+  bool filenames_equal = ConstString::Equals(a.m_filename, 
+ b.m_filename, 
+ case_sensitive);
+
+  // The only way two FileSpecs can be equal if their filenames are
+  // unequal is if we are removing backups and one or the other filename
+  // is a backup string:
+
+  if (!filenames_equal && !remove_backups)
+  return false;
+
+  bool last_component_is_dot = ConstString::Equals(a.m_filename, g_dot_string) 
+   || ConstString::Equals(a.m_filename, 
+  g_dot_dot_string)
+   || ConstString::Equals(b.m_filename, 
+  g_dot_string)
+   || ConstString::Equals(b.m_filename, 
+  g_dot_dot_string);
+
+  if (!filenames_equal && !last_component_is_dot)
+return false;
 
   if (!full && (a.GetDirectory().IsEmpty() || b.GetDirectory().IsEmpty()))
-return ConstString::Equals(a.m_filename, b.m_filename, case_sensitive);
+return filenames_equal;
 
   if (remove_backups == false)
 return a == b;

Modified: lldb/trunk/unittests/Host/FileSpecTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/FileSpecTest.cpp?rev=298876&r1=298875&r2=298876&view=diff
==
--- lldb/trunk/unittests/Host/FileSpecTest.cpp (original)
+++ lldb/trunk/unittests/Host/FileSpecTest.cpp Mon Mar 27 14:12:25 2017
@@ -164,6 +164,7 @@ TEST(FileSpecTest, EqualDotsWindows) {
   {R"(C:/bar/baz)", R"(C:\foo\..\bar\baz)"},
   {R"(C:\bar)", R"(C:\foo\..\bar)"},
   {R"(C:\foo\bar)", R"(C:\foo\.\bar)"},
+  {R"(C:\foo\bar)", R"(C:\foo\bar\.)"},
   };
 
   for(const auto &test: tests) {
@@ -187,6 +188,7 @@ TEST(FileSpecTest, EqualDotsPosix) {
   {R"(/bar/baz)", R"(/foo/../bar/baz)"},
   {R"(/bar)", R"(/foo/../bar)"},
   {R"(/foo/bar)", R"(/foo/./bar)"},
+  {R"(/foo/bar)", R"(/foo/bar/.)"},
   };
 
   for(const auto &test: tests) {


___
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-03-27 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

It's a little weird to have the unit tests for debugserver in the top-level 
lldb directory.  debugserver really is a stand-alone tool that shares no code 
with lldb proper.  How hard would it be to put the tests under debugserver?


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-03-27 Thread Chris Bieneman via Phabricator via lldb-commits
beanz added a comment.

@jingham I put the unit tests at the top because they depend on LLDB's Host 
library (at least the current tests do). I'm attempting to write tests which 
cover the socket communication between LLDB and debugserver by sending data 
between the two using each side of the API.


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-03-27 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

debugserver only runs on darwin and we have no intentions of using it 
elsewhere.  lldb-server is the way to do debugserver for new platforms.  I 
don't think you need the generality provided by host to test debugserver, OTOH, 
if using those classes saves you lots of time over writing macOS specific code, 
then I'm mostly concerned that it is clear that debugserver isn't the way to do 
debug servers for lldb, lldb-server is...


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] D31366: Do not dereference std::unique_ptr by default

2017-03-27 Thread Tamas Berghammer via Phabricator via lldb-commits
tberghammer requested review of this revision.
tberghammer added a comment.

I am trying to compile it with the following command on OSX but I wasn't able 
to get it working:

  clang  -std=c++11  -g -O0 -fno-builtin -arch x86_64   -fno-limit-debug-info 
-I$LLVM_ROOT/lldb/packages/Python/lldbsuite/test/make/../../../../../include 
-include $LLVM_ROOT/lldb/packages/Python/lldbsuite/test/make/test_common.h  
-stdlib=libstdc++ -DLLDB_USING_LIBSTDCPP --driver-mode=g++ -c -o main.o main.cpp

Compile error (first few):

  main.cpp:12:8: error: no member named 'unique_ptr' in namespace 'std'
std::unique_ptr nup;
~^
  main.cpp:12:23: error: expected '(' for function-style cast or type 
construction
std::unique_ptr nup;
^
  main.cpp:12:25: error: use of undeclared identifier 'nup'; did you mean 'dup'?
std::unique_ptr nup;
  ^~~
  dup
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/unistd.h:438:6:
 note: 'dup' declared here
  int  dup(int);
   ^
  main.cpp:13:8: error: no member named 'unique_ptr' in namespace 'std'
std::unique_ptr iup(new int{123});
~^
  main.cpp:13:22: error: expected '(' for function-style cast or type 
construction
std::unique_ptr iup(new int{123});
~~~^
  main.cpp:13:24: error: use of undeclared identifier 'iup'; did you mean 'dup'?
std::unique_ptr iup(new int{123});
 ^~~
 dup
  
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/unistd.h:438:6:
 note: 'dup' declared here
  int  dup(int);

I think the problem is that this is testing libstdc++ what is not available on 
OSX.

Clang version:

  Apple LLVM version 7.3.0 (clang-703.0.31)
  Target: x86_64-apple-darwin16.3.0
  Thread model: posix
  InstalledDir: 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


https://reviews.llvm.org/D31366



___
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-03-27 Thread Chris Bieneman via Phabricator via lldb-commits
beanz updated this revision to Diff 93190.
beanz added a comment.

Added a note to the unit test CMake file about why the tests are where they 
are. Generally we isolate debugserver from the rest of LLDB, and this comment 
explains the breach of isolation.


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,109 @@
+//===-- 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 "RNBSocket.h"
+#include "RNBDefs.h"
+#include "lldb/Host/Socket.h"
+
+using namespace lldb_private;
+
+static void ServerCallback(const void *baton, in_port_t port) {}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  std::string Hello = "Hello, world!";
+  std::string Goodbye = "Goodbye!";
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ServerSocket;
+auto result = ServerSocket.Listen("localhost", 4242, ServerCallback, NULL);
+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);
+  } else {
+Socket *ClientSocket;
+Error Err = Socket::TcpConnect("localhost:4242", 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();
+exit(0);
+  }
+  int exit_status;
+  wait(&exit_status);
+  ASSERT_EQ(exit_status, 0);
+}
+
+TEST(RNBSocket, LoopBackConnectIPv4) {
+  Socket *ServerSocket;
+  Predicate PortPredicate;
+  PortPredicate.SetValue(0, eBroadcastNever);
+  Error Err = Socket::TcpListen("localhost:4242", false, ServerSocket,
+&PortPredicate);
+  ASSERT_FALSE(Err.Fail());
+
+  std::string Hello = "Hello, world!";
+  std::string Goodbye = "Goodbye!";
+
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ClientSocket;
+auto result = ClientSocket.Connect("localhost", 4242);
+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("localhost:4242", false, ConnectedSocket);
+if (Err.Fail())
+  abort();
+char Buffer[32];
+size_t ReadSize = 32;
+Err = ConnectedSocket->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 = ConnectedSocket->Write(Goodbye.c_str(), WriteSize);
+if (Err.Fail())
+  abort();
+if (WriteSize != Goodbye.length())
+  abort();
+exit(0);
+  }
+  int exit_status;

[Lldb-commits] [PATCH] D31366: Do not dereference std::unique_ptr by default

2017-03-27 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

There's no reason you couldn't build the gnu libstdc++ on Darwin.  Anyway, if 
that's the problem, I'm pretty sure the testsuite has a way to conditionalize 
on which stdlib(s) are available.  That would be clearer than conditionalizing 
on platform.


https://reviews.llvm.org/D31366



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


[Lldb-commits] [PATCH] D30984: Centralize libc++ test skipping logic

2017-03-27 Thread Eric Fiselier via Phabricator via lldb-commits
EricWF added a comment.

I don't see anything wrong with this, but I only know libc++ and not LLDB.

>   libc++'s atomic does not play well with gcc on linux

It should... Can you elaborate on this issue? I suspect this may be a libc++ 
bug.


https://reviews.llvm.org/D30984



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