[Lldb-commits] [lldb] r298694 - The expression text in AppleObjCRuntimeV1::CreateObjectChecker

2017-03-24 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Fri Mar 24 03:01:16 2017
New Revision: 298694

URL: http://llvm.org/viewvc/llvm-project?rev=298694&view=rev
Log:
The expression text in AppleObjCRuntimeV1::CreateObjectChecker
was formatted into a string inside an assert() expression.
Which is elided when lldb is built with asserts disabled;
the result is that all expressions will fail when debugging
programs using the objective-c v1 runtime.

 

Modified:

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

Modified: 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=298694&r1=298693&r2=298694&view=diff
==
--- 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
 Fri Mar 24 03:01:16 2017
@@ -127,7 +127,7 @@ struct BufStruct {
 UtilityFunction *AppleObjCRuntimeV1::CreateObjectChecker(const char *name) {
   std::unique_ptr buf(new BufStruct);
 
-  assert(snprintf(&buf->contents[0], sizeof(buf->contents),
+  int strformatsize = snprintf(&buf->contents[0], sizeof(buf->contents),
   "struct __objc_class 
"
   "   \n"
   "{   
"
@@ -169,7 +169,8 @@ UtilityFunction *AppleObjCRuntimeV1::Cre
   "   \n"
   "}   
"
   "   \n",
-  name) < (int)sizeof(buf->contents));
+  name);
+  assert(strformatsize < (int)sizeof(buf->contents));
 
   Error error;
   return GetTargetRef().GetUtilityFunctionForLanguage(


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


[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support

2017-03-24 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: source/CMakeLists.txt:25
+include_directories(
+  Plugins/Process/POSIX
+  )

@labath are the includes for Plugins/Process/FreeBSD and 
Plugins/Process/FreeBSD necessary? I don't need to add Plugins/Process/NetBSD 
in order to make things work.

(it's not related to OpenBSD patch here)



Comment at: source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp:48
+  GPR gpr;
+  FPR_i386 i387;
+};

no DBG regs here?


https://reviews.llvm.org/D31131



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


[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support

2017-03-24 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski accepted this revision.
krytarowski added a comment.
This revision is now accepted and ready to land.

In general it looks good.


https://reviews.llvm.org/D31131



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


[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support

2017-03-24 Thread Mark Kettenis via Phabricator via lldb-commits
kettenis added inline comments.



Comment at: source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp:48
+  GPR gpr;
+  FPR_i386 i387;
+};

krytarowski wrote:
> no DBG regs here?
OpenBSD doesn't actually implement access to the debug registers.


https://reviews.llvm.org/D31131



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


[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support

2017-03-24 Thread Mark Kettenis via Phabricator via lldb-commits
kettenis updated this revision to Diff 92938.
kettenis added a comment.

Updated diff to account for the FileSpec.h move.


https://reviews.llvm.org/D31131

Files:
  include/lldb/Host/Config.h
  include/lldb/Host/Editline.h
  include/lldb/Host/Host.h
  include/lldb/Host/HostInfo.h
  include/lldb/Host/openbsd/Config.h
  include/lldb/Host/openbsd/HostInfoOpenBSD.h
  source/API/SystemInitializerFull.cpp
  source/CMakeLists.txt
  source/Host/CMakeLists.txt
  source/Host/common/Host.cpp
  source/Host/openbsd/Host.cpp
  source/Host/openbsd/HostInfoOpenBSD.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Platform/CMakeLists.txt
  source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  source/Plugins/Platform/OpenBSD/CMakeLists.txt
  source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
  source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
  source/Plugins/Process/Utility/CMakeLists.txt
  source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
  source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
  source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
  source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ThreadElfCore.cpp

Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -21,6 +21,8 @@
 #include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
 #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
+#include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
 #include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
 #include "ProcessElfCore.h"
@@ -126,6 +128,26 @@
 break;
   case llvm::Triple::x86_64:
 reg_interface = new RegisterContextLinux_x86_64(arch);
+break;
+  default:
+break;
+  }
+  break;
+}
+
+case llvm::Triple::OpenBSD: {
+  switch (arch.GetMachine()) {
+  case llvm::Triple::aarch64:
+reg_interface = new RegisterInfoPOSIX_arm64(arch);
+break;
+  case llvm::Triple::arm:
+reg_interface = new RegisterInfoPOSIX_arm(arch);
+break;
+  case llvm::Triple::x86:
+	reg_interface = new RegisterContextOpenBSD_i386(arch);
+	break;
+  case llvm::Triple::x86_64:
+reg_interface = new RegisterContextOpenBSD_x86_64(arch);
 break;
   default:
 break;
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -431,6 +431,10 @@
   NT_FILE = 0x46494c45,
   NT_PRXFPREG = 0x46e62b7f,
   NT_SIGINFO = 0x53494749,
+  NT_OPENBSD_PROCINFO = 10,
+  NT_OPENBSD_AUXV = 11,
+  NT_OPENBSD_REGS = 20,
+  NT_OPENBSD_FPREGS = 21,
 };
 
 namespace FREEBSD {
@@ -481,6 +485,18 @@
   thread_data.name = data.GetCStr(&offset, 20);
 }
 
+static void ParseOpenBSDProcInfo(ThreadData &thread_data, DataExtractor &data)
+{
+  lldb::offset_t offset = 0;
+  
+  int version = data.GetU32(&offset);
+  if (version != 1)
+	  return;
+
+  offset += 4;
+  thread_data.signo = data.GetU32(&offset);
+}
+
 /// Parse Thread context from PT_NOTE segment and store it in the thread list
 /// Notes:
 /// 1) A PT_NOTE segment is composed of one or more NOTE entries.
@@ -568,6 +584,24 @@
 break;
   default:
 break;
+  }
+} else if (note.n_name.substr(0, 7) == "OpenBSD") {
+  // OpenBSD per-thread information is stored in notes named
+  // "OpenBSD@nnn" so match on the initial part of the string.
+  m_os = llvm::Triple::OpenBSD;
+  switch (note.n_type) {
+  case NT_OPENBSD_PROCINFO:
+	ParseOpenBSDProcInfo(*thread_data, note_data);
+	break;
+  case NT_OPENBSD_AUXV:
+	m_auxv = DataExtractor(note_data);
+	break;
+  case NT_OPENBSD_REGS:
+	thread_data->gpregset = note_data;
+	break;
+  case NT_OPENBSD_FPREGS:
+	thread_data->fpregset = note_data;
+	break;
   }
 } else if (note.n_name == "CORE") {
   switch (note.n_type) {
Index: source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
===
--- source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
+++ source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
@@ -0,0 +1,31 @@
+//===-- RegisterContextOpenBSD_x86_64.h -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.

[Lldb-commits] [PATCH] D31131: [LLDB] OpenBSD support

2017-03-24 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added inline comments.



Comment at: source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp:48
+  GPR gpr;
+  FPR_i386 i387;
+};

kettenis wrote:
> krytarowski wrote:
> > no DBG regs here?
> OpenBSD doesn't actually implement access to the debug registers.
Yes, I know, there are also accessors for xmm registers. So far I have not been 
there with NetBSD either and your code follows FreeBSD (Linux has debug 
registers in userdata).


https://reviews.llvm.org/D31131



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


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

2017-03-24 Thread Francis Ricci via Phabricator via lldb-commits
fjricci created this revision.

Prior to r259433, getCompiler could return None without causing a
test suite crash. However, passing a NoneType to realpath will
cause a crash. Prevent this crash by allowing getCompiler to return None.


https://reviews.llvm.org/D31335

Files:
  packages/Python/lldbsuite/test/plugins/builder_base.py


Index: packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- packages/Python/lldbsuite/test/plugins/builder_base.py
+++ packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -33,7 +33,7 @@
 """Returns the compiler in effect the test suite is running with."""
 compiler = os.environ.get("CC", "clang")
 compiler = lldbutil.which(compiler)
-return os.path.realpath(compiler)
+return os.path.realpath(compiler) if compiler else None
 
 
 def getArchFlag():


Index: packages/Python/lldbsuite/test/plugins/builder_base.py
===
--- packages/Python/lldbsuite/test/plugins/builder_base.py
+++ packages/Python/lldbsuite/test/plugins/builder_base.py
@@ -33,7 +33,7 @@
 """Returns the compiler in effect the test suite is running with."""
 compiler = os.environ.get("CC", "clang")
 compiler = lldbutil.which(compiler)
-return os.path.realpath(compiler)
+return os.path.realpath(compiler) if compiler else None
 
 
 def getArchFlag():
___
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-24 Thread Chris Bieneman via Phabricator via lldb-commits
beanz created this revision.
Herald added a subscriber: mgorny.

This patch refactors the CMake build system's support for building debugserver 
to allow us to build the majority of debugserver's sources into the 
debugserverCommon library which can then be reused by unit tests.

The first unit test I've written tests debug server's ability to accept 
incoming connections from LLDB. The test forks the process, and one side 
creates a listening socket using debugserver's socket API, the other side 
creates a transmitting socket using LLDB's TCPSocket class.

I have no clue where to even start getting this connected into the LLDB Xcode 
project, so for now these tests are CMake-only.


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) {}
\ No newline at end of file
Index: unittests/debugserver/RNBSocketTest.cpp
===
--- /dev/null
+++ unittests/debugserver/RNBSocketTest.cpp
@@ -0,0 +1,35 @@
+//===-- 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 "lldb/Host/Socket.h"
+
+using namespace lldb_private;
+
+static void ServerCallback(const void *baton, in_port_t port) {}
+
+TEST(RNBSocket, LoopBackListenIPv4) {
+  auto ChildPID = fork();
+  if (ChildPID != 0) {
+RNBSocket ServerSocket;
+auto result = ServerSocket.Listen("localhost", 4242, ServerCallback, NULL);
+ASSERT_FALSE(result);
+  } else {
+Socket *ClientSocket;
+Error Err = Socket::TcpConnect("localhost:4242", false, ClientSocket);
+if (Err.Fail())
+  abort();
+exit(0);
+  }
+}
Index: unittests/debugserver/CMakeLists.txt
===
--- /dev/null
+++ unittests/debugserver/CMakeLists.txt
@@ -0,0 +1,13 @@
+include_directories(${LLDB_SOURCE_DIR}/tools/debugserver/source
+${LLDB_SOURCE_DIR}/tools/debugserver/source/MacOSX)
+
+add_lldb_unittest(debugserverTests
+  RNBSocketTest.cpp
+  debugserver_LogCallback.cpp
+
+  LINK_LIBS
+lldbDebugserverCommon
+lldbHost
+  LINK_COMPONENTS
+Support
+  )
Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -70,3 +70,7 @@
 add_subdirectory(Target)
 add_subdirectory(UnwindAssembly)
 add_subdirectory(Utility)
+
+if(LLDB_CAN_USE_DEBUGSERVER)
+  add_subdirectory(debugserver)
+endif()
\ No newline at end of file
Index: tools/debugserver/source/MacOSX/CMakeLists.txt
===
--- tools/debugserver/source/MacOSX/CMakeLists.txt
+++ tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -6,70 +6,3 @@
 add_subdirectory(DarwinLog)
 
 include_directories(..)
-
-set(generated_mach_interfaces
-  ${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
-  ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
-  ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
-  )
-add_custom_command(OUTPUT ${generated_mach_interfaces}
-  COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
-  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dbgnub-mig.defs
-  )
-
-set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
-set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
-
-add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
-  COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-ve

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

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

Todd added a gtest target to the lldb.xcodeproj.  Presumably you could use that 
as a template and do the same thing in the tools/debugserver.xcproj.  Then make 
an aggregate target in the lldb workspace that runs these two targets.


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

Xcode is pretty magic to me. I don't know how to do much of anything in it 
other than build. I think the right solution would be to take most of the 
source files out of the debugserver target and generate a static archive from 
them, then have debugserver and the debugserverTest target link the static 
archive.

I don't know how to do that and not screw up the Xcode target settings on the 
archive target.


https://reviews.llvm.org/D31357



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


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

2017-03-24 Thread Zachary Turner via lldb-commits
I'm ooo for ~2 weeks so I can't really do code reviews unfortunately
On Sat, Mar 25, 2017 at 6:23 AM Chris Bieneman via Phabricator <
revi...@reviews.llvm.org> wrote:

> beanz added a comment.
>
> Xcode is pretty magic to me. I don't know how to do much of anything in it
> other than build. I think the right solution would be to take most of the
> source files out of the debugserver target and generate a static archive
> from them, then have debugserver and the debugserverTest target link the
> static archive.
>
> I don't know how to do that and not screw up the Xcode target settings on
> the archive target.
>
>
> https://reviews.llvm.org/D31357
>
>
>
>
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits