[Lldb-commits] [PATCH] D61833: Fix IPv6 support on lldb-server platform

2019-05-12 Thread António Afonso via Phabricator via lldb-commits
aadsm created this revision.
aadsm added a reviewer: labath.
Herald added subscribers: lldb-commits, jfb, mgorny.
Herald added a project: LLDB.

This is a general fix for the ConnectionFileDescriptor class but my main 
motivation was to make lldb-server working with IPv6.
The connect URI can use square brackets ([]) to wrap the interface part of the 
URI (e.g.: ://[]:). For IPv6 addresses this is a must 
since its ip can include colons and it will overlap with the port colon 
otherwise. The URIParser class parses the square brackets correctly but the 
ConnectionFileDescriptor doesn't generate them for IPv6 addresses making it 
impossible to connect to the gdb server when using this protocol.

How to reproduce the issue:

  $ lldb-server p --server --listen [::1]:8080
  ...
  $ lldb
  (lldb) platform select remote-macosx
  (lldb) platform connect connect://[::1]:8080
  (lldb) platform process -p 
  error: unable to launch a GDB server on 'computer'

The server was actually launched we were just not able to connect to it. With 
this fix lldb will correctly connect.

I fixed this by wrapping the ip portion with []. It was a simple fix but the 
tests was what took more time to do.

@labath I need your help figuring out a good way to set these tests up. I 
wanted to reuse the CreateConnectedSockets part of the SocketTests. Initially I 
thought about creating a few functions in a test socket utility file, but then 
I realized the tests need to initialize the Socket plugin for these functions 
to work. In the end I created a new class (SocketBasedTest) so I can ensure 
this plugin is correctly initialized and teared down. However, I'm not a fan of 
subclassing as a means of code shared (as I prefer composition or delegation). 
What are your thoughts on this?

Another question I have (and this is more a n00b question as I don't have prior 
c++ experience), the CreateConnectedSockets functions that exist use unique 
pointers, and after reading the documentation about this I decided to use 
.release() so I could safely pass them to the ConnectionFileDescriptor in the 
test I created for it. Should I have changed the unique pointers to shared 
pointers instead?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61833

Files:
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/unittests/Host/CMakeLists.txt
  lldb/unittests/Host/ConnectionFileDescriptorTest.cpp
  lldb/unittests/Host/SocketBasedTest.cpp
  lldb/unittests/Host/SocketBasedTest.h
  lldb/unittests/Host/SocketTest.cpp

Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -6,82 +6,18 @@
 //
 //===--===//
 
-#include 
-#include 
-#include 
-
+#include "SocketBasedTest.h"
 #include "gtest/gtest.h"
 
-#include "lldb/Host/Config.h"
-#include "lldb/Host/Socket.h"
-#include "lldb/Host/common/TCPSocket.h"
-#include "lldb/Host/common/UDPSocket.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
-#include "llvm/Testing/Support/Error.h"
-
-#ifndef LLDB_DISABLE_POSIX
-#include "lldb/Host/posix/DomainSocket.h"
-#endif
-
 using namespace lldb_private;
 
-class SocketTest : public testing::Test {
+class SocketTest : public SocketBasedTest {
 public:
   void SetUp() override {
 ASSERT_THAT_ERROR(Socket::Initialize(), llvm::Succeeded());
   }
 
   void TearDown() override { Socket::Terminate(); }
-
-protected:
-  static void AcceptThread(Socket *listen_socket,
-   bool child_processes_inherit, Socket **accept_socket,
-   Status *error) {
-*error = listen_socket->Accept(*accept_socket);
-  }
-
-  template 
-  void CreateConnectedSockets(
-  llvm::StringRef listen_remote_address,
-  const std::function &get_connect_addr,
-  std::unique_ptr *a_up, std::unique_ptr *b_up) {
-bool child_processes_inherit = false;
-Status error;
-std::unique_ptr listen_socket_up(
-new SocketType(true, child_processes_inherit));
-EXPECT_FALSE(error.Fail());
-error = listen_socket_up->Listen(listen_remote_address, 5);
-EXPECT_FALSE(error.Fail());
-EXPECT_TRUE(listen_socket_up->IsValid());
-
-Status accept_error;
-Socket *accept_socket;
-std::thread accept_thread(AcceptThread, listen_socket_up.get(),
-  child_processes_inherit, &accept_socket,
-  &accept_error);
-
-std::string connect_remote_address = get_connect_addr(*listen_socket_up);
-std::unique_ptr connect_socket_up(
-new SocketType(true, child_processes_inherit));
-EXPECT_FALSE(error.Fail());
-error = connect_socket_up->Connect(connect_remote_address);
-EXPECT_FALSE(error.Fail());
-EXPECT_TRUE(connect_socket_up->IsValid());
-
-a_up->swap(connect_socket_up);
-EXPECT_TRUE(error.Success()

[Lldb-commits] [lldb] r360554 - Fix file names in file headers. NFC

2019-05-12 Thread Fangrui Song via lldb-commits
Author: maskray
Date: Sun May 12 21:42:32 2019
New Revision: 360554

URL: http://llvm.org/viewvc/llvm-project?rev=360554&view=rev
Log:
Fix file names in file headers. NFC

Modified:
lldb/trunk/include/lldb/API/SBExpressionOptions.h
lldb/trunk/include/lldb/API/SBThreadPlan.h
lldb/trunk/include/lldb/Core/ValueObjectCast.h
lldb/trunk/include/lldb/Expression/IRMemoryMap.h
lldb/trunk/include/lldb/Host/HostGetOpt.h
lldb/trunk/include/lldb/Host/HostInfo.h
lldb/trunk/include/lldb/Host/windows/PipeWindows.h
lldb/trunk/include/lldb/Host/windows/editlinewin.h
lldb/trunk/include/lldb/Host/windows/windows.h
lldb/trunk/include/lldb/Interpreter/OptionValueChar.h
lldb/trunk/include/lldb/Symbol/LocateSymbolFile.h
lldb/trunk/include/lldb/Symbol/UnwindTable.h
lldb/trunk/include/lldb/lldb-public.h
lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp
lldb/trunk/source/API/SBBreakpointOptionCommon.cpp
lldb/trunk/source/Breakpoint/BreakpointName.cpp
lldb/trunk/source/Host/posix/ProcessLauncherPosixFork.cpp
lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
lldb/trunk/source/Plugins/Instruction/ARM/EmulationStateARM.h
lldb/trunk/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
lldb/trunk/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
lldb/trunk/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h
lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h

lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp

lldb/trunk/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h
lldb/trunk/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
lldb/trunk/source/Symbol/LocateSymbolFile.cpp
lldb/trunk/source/Symbol/LocateSymbolFileMacOSX.cpp
lldb/trunk/source/Utility/ProcessInfo.cpp
lldb/trunk/source/Utility/VASprintf.cpp
lldb/trunk/tools/darwin-debug/darwin-debug.cpp
lldb/trunk/tools/debugserver/source/MacOSX/DarwinLog/ActivityStreamSPI.h
lldb/trunk/tools/debugserver/source/MacOSX/Genealogy.cpp
lldb/trunk/tools/debugserver/source/MacOSX/Genealogy.h
lldb/trunk/tools/debugserver/source/MacOSX/GenealogySPI.h
lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
lldb/trunk/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.h
lldb/trunk/tools/lldb-mi/MICmdCmdSupportInfo.cpp
lldb/trunk/tools/lldb-mi/MICmnMIValueResult.h
lldb/trunk/unittests/TestingSupport/MockTildeExpressionResolver.h

Modified: lldb/trunk/include/lldb/API/SBExpressionOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBExpressionOptions.h?rev=360554&r1=360553&r2=360554&view=diff
==
--- lldb/trunk/include/lldb/API/SBExpressionOptions.h (original)
+++ lldb/trunk/include/lldb/API/SBExpressionOptions.h Sun May 12 21:42:32 2019
@@ -1,4 +1,4 @@
-//===-- SBEvent.h ---*- C++ 
-*-===//
+//===-- SBExpressionOptions.h ---*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -89,10 +89,10 @@ public:
   bool GetTopLevel();
 
   void SetTopLevel(bool b = true);
-  
+
   // Gets whether we will JIT an expression if it cannot be interpreted
   bool GetAllowJIT();
-  
+
   // Sets whether we will JIT an expression if it cannot be interpreted
   void SetAllowJIT(bool allow);
 

Modified: lldb/trunk/include/lldb/API/SBThreadPlan.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThreadPlan.h?rev=360554&r1=360553&r2=360554&view=diff
==
--- lldb/trunk/include/lldb/API/SBThreadPlan.h (original)
+++ lldb/trunk/include/lldb/API/SBThreadPlan.h Sun May 12 21:42:32 2019
@@ -1,4 +1,4 @@
-//===-- SBThread.h --*- C++ 
-*-===//
+//===-- SBThreadPlan.h --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

Modified: lldb/trunk/include/lldb/Core/ValueObjectCast.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectCast.h?rev=360554&r1=360553&r2=360554&view=diff
==
--- lldb/trunk/include/lldb/Core/ValueObjectCast.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectCast.h Sun May 12 21:42:32 2019
@@ -1,4 +1,4 @@
-//===-- ValueObjectDynamicValue.h ---*- C++ 
-*-===//
+//===-- ValueObjectCast.h ---*- C++ 
-*-===//
 //
 // Part

[Lldb-commits] [lldb] r360557 - [CMake] Add lli to LLDB_TEST_DEPS

2019-05-12 Thread Fangrui Song via lldb-commits
Author: maskray
Date: Sun May 12 22:05:46 2019
New Revision: 360557

URL: http://llvm.org/viewvc/llvm-project?rev=360557&view=rev
Log:
[CMake] Add lli to LLDB_TEST_DEPS

lli is used by lit/Breakpoint/jitbp_elf.test
I had a test failure when running check-lldb-lit because my lli was stale.

Modified:
lldb/trunk/lit/CMakeLists.txt

Modified: lldb/trunk/lit/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/CMakeLists.txt?rev=360557&r1=360556&r2=360557&view=diff
==
--- lldb/trunk/lit/CMakeLists.txt (original)
+++ lldb/trunk/lit/CMakeLists.txt Sun May 12 22:05:46 2019
@@ -24,6 +24,7 @@ list(APPEND LLDB_TEST_DEPS
   llc
   lldb
   lldb-test
+  lli
   llvm-config
   llvm-mc
   llvm-objcopy


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