[Lldb-commits] [PATCH] D35223: Report inferior SIGSEGV/SIGILL/SIGBUS/SIGFPE as a signal instead of an exception on freebsd

2017-08-10 Thread Ed Maste via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310591: Report inferior signals as signals, not exceptions, 
on FreeBSD (authored by emaste).

Changed prior to commit:
  https://reviews.llvm.org/D35223?vs=110438&id=110572#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35223

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
  lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
  lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
  lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
  lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
@@ -17,9 +17,6 @@
 mydir = TestBase.compute_mydir(__file__)
 
 @expectedFailureAll(
-oslist=['freebsd'],
-bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
-@expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")
 def test_inferior_crashing(self):
@@ -60,7 +57,6 @@
 self.build()
 self.inferior_crashing_step()
 
-@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939')
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24778, This actually works, but the test relies on the output format instead of the API")
@@ -76,6 +72,7 @@
 # Inferior exits after stepping after a segfault. This is working as
 # intended IMHO.
 @skipIfLinux
+@skipIfFreeBSD
 def test_inferior_crashing_expr_step_and_expr(self):
 """Test that lldb expressions work before and after stepping after a crash."""
 self.build()
@@ -110,7 +107,7 @@
 # The exact stop reason depends on the platform
 if self.platformIsDarwin():
 stop_reason = 'stop reason = EXC_BAD_ACCESS'
-elif self.getPlatform() == "linux":
+elif self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
 stop_reason = 'stop reason = signal SIGSEGV'
 else:
 stop_reason = 'stop reason = invalid address'
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
@@ -16,9 +16,6 @@
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(
-oslist=['freebsd'],
-bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
 def test_recursive_inferior_crashing(self):
 """Test that lldb reliably catches the inferior crashing (command)."""
@@ -50,7 +47,6 @@
 self.build()
 self.recursive_inferior_crashing_step()
 
-@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939')
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
 @skipIfTargetAndroid()  # debuggerd interferes with this test on Android
 def test_recursive_inferior_crashing_step_after_break(self):
@@ -61,6 +57,7 @@
 # Inferior exits after stepping after a segfault. This is working as
 # intended IMHO.
 @skipIfLinux
+@skipIfFreeBSD
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
 def test_recursive_inferior_crashing_expr_step_and_expr(self):
 """Test that lldb expressions work before and after stepping after a crash."""
@@ -94,7 +91,7 @@
 # The exact stop reason depends on the platform
 if self.platformIsDarwin():
 stop_reason = 'stop reason = EXC_BAD_ACCESS'
-elif self.getPlatform() == "linux":
+elif self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
 stop_reason = 'stop reason = signal SIGSEGV'
 else:
 stop_reason = 'stop reason = invalid address'
Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
=

[Lldb-commits] [lldb] r310591 - Report inferior signals as signals, not exceptions, on FreeBSD

2017-08-10 Thread Ed Maste via lldb-commits
Author: emaste
Date: Thu Aug 10 06:47:17 2017
New Revision: 310591

URL: http://llvm.org/viewvc/llvm-project?rev=310591&view=rev
Log:
Report inferior signals as signals, not exceptions, on FreeBSD

This is the FreeBSD equivalent of r238549.

This serves 2 purposes:

* LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/
  SIGFPE the way it is suppose to be handled. Prior to this fix these
  signals will neither create a coredump, nor exit from the debugger
  or work for signal handling scenario.
* eInvalidCrashReason need not report "unknown crash reason" if we have
  a valid si_signo

llvm.org/pr23699

Patch by Karnajit Wangkhem

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

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
lldb/trunk/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
lldb/trunk/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
lldb/trunk/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py?rev=310591&r1=310590&r2=310591&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/TestInferiorCrashing.py
 Thu Aug 10 06:47:17 2017
@@ -17,9 +17,6 @@ class CrashingInferiorTestCase(TestBase)
 mydir = TestBase.compute_mydir(__file__)
 
 @expectedFailureAll(
-oslist=['freebsd'],
-bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not 
signal")
-@expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24778, This actually works, but the test relies 
on the output format instead of the API")
 def test_inferior_crashing(self):
@@ -60,7 +57,6 @@ class CrashingInferiorTestCase(TestBase)
 self.build()
 self.inferior_crashing_step()
 
-@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939')
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24778, This actually works, but the test relies 
on the output format instead of the API")
@@ -76,6 +72,7 @@ class CrashingInferiorTestCase(TestBase)
 # Inferior exits after stepping after a segfault. This is working as
 # intended IMHO.
 @skipIfLinux
+@skipIfFreeBSD
 def test_inferior_crashing_expr_step_and_expr(self):
 """Test that lldb expressions work before and after stepping after a 
crash."""
 self.build()
@@ -110,7 +107,7 @@ class CrashingInferiorTestCase(TestBase)
 # The exact stop reason depends on the platform
 if self.platformIsDarwin():
 stop_reason = 'stop reason = EXC_BAD_ACCESS'
-elif self.getPlatform() == "linux":
+elif self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
 stop_reason = 'stop reason = signal SIGSEGV'
 else:
 stop_reason = 'stop reason = invalid address'

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py?rev=310591&r1=310590&r2=310591&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferior.py
 Thu Aug 10 06:47:17 2017
@@ -16,9 +16,6 @@ class CrashingRecursiveInferiorTestCase(
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(
-oslist=['freebsd'],
-bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not 
signal")
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
 def test_recursive_inferior_crashing(self):
 """Test that lldb reliably catches the inferior crashing (command)."""
@@ -50,7 +47,6 @@ class CrashingRecursiveInferiorTestCase(
 self.build()
 self.recursive_inferior_crashing_step()
 
-@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr24939')
 @expectedFailureAll(oslist=["windows

[Lldb-commits] [lldb] r310624 - remove FreeBSD xfail decorator from TestExitDuringBreak

2017-08-10 Thread Ed Maste via lldb-commits
Author: emaste
Date: Thu Aug 10 09:48:36 2017
New Revision: 310624

URL: http://llvm.org/viewvc/llvm-project?rev=310624&view=rev
Log:
remove FreeBSD xfail decorator from TestExitDuringBreak

This test passes for me on FreeBSD 10 and 12(-CURRENT).

llvm.org/pr18190

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py?rev=310624&r1=310623&r2=310624&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
 Thu Aug 10 09:48:36 2017
@@ -26,9 +26,6 @@ class ExitDuringBreakpointTestCase(TestB
 @expectedFailureAll(
 oslist=["linux"],
 bugnumber="llvm.org/pr15824 thread states not properly maintained")
-@expectedFailureAll(
-oslist=["freebsd"],
-bugnumber="llvm.org/pr18190 thread states not properly maintained")
 def test(self):
 """Test thread exit during breakpoint handling."""
 self.build(dictionary=self.getBuildFlags())


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


[Lldb-commits] Details of radar rdar://problem/24599697

2017-08-10 Thread Ed Maste via lldb-commits
On 20 June 2016 at 19:01, Sean Callanan via lldb-commits
 wrote:
> Author: spyffe
> Date: Mon Jun 20 18:01:11 2016
> New Revision: 273211
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273211&view=rev
> Log:
> Test that lldb calls the right 'printf' even when a 'printf' method exists.
>
...
> +
> +lldbinline.MakeInlineTest(__file__, globals(), 
> [decorators.expectedFailureAll(bugnumber="rdar://problem/24599697")] )

This test is consistently reporting unexpected pass on FreeBSD. Can
you please provide details on the actual failure in order to determine
the best path forward here?
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r310626 - remove FreeBSD xfail decorator from TestCallStdStringFunction

2017-08-10 Thread Ed Maste via lldb-commits
Author: emaste
Date: Thu Aug 10 10:01:51 2017
New Revision: 310626

URL: http://llvm.org/viewvc/llvm-project?rev=310626&view=rev
Log:
remove FreeBSD xfail decorator from TestCallStdStringFunction

This test is consistently reporting unexpected pass for me on FreeBSD
10 and 12. It was failing on the old FreeBSD buildbot which has now been
retired for some time. Will investigate further if this fails once a new
buildbot is configured and running tests.

llvm.org/pr17807

Modified:

lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py?rev=310626&r1=310625&r2=310626&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStdStringFunction.py
 Thu Aug 10 10:01:51 2017
@@ -26,9 +26,6 @@ class ExprCommandCallFunctionTestCase(Te
 @expectedFailureAll(
 compiler="icc",
 bugnumber="llvm.org/pr14437, fails with ICC 13.1")
-@expectedFailureAll(
-oslist=['freebsd'],
-bugnumber='llvm.org/pr17807 Fails on FreeBSD buildbot')
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
 def test_with(self):
 """Test calling std::String member function."""


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


[Lldb-commits] [lldb] r310644 - remove FreeBSD xfail decorator from TestCppNsImport

2017-08-10 Thread Ed Maste via lldb-commits
Author: emaste
Date: Thu Aug 10 11:26:52 2017
New Revision: 310644

URL: http://llvm.org/viewvc/llvm-project?rev=310644&view=rev
Log:
remove FreeBSD xfail decorator from TestCppNsImport

The Linux xfail decorator was removed in r272326 with the claim that the
test "runs reliably on the linux x86 buildbot." It also runs reliably on
FreeBSD for me.

llvm.org/pr25925

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py?rev=310644&r1=310643&r2=310644&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py 
(original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/nsimport/TestCppNsImport.py 
Thu Aug 10 11:26:52 2017
@@ -11,7 +11,6 @@ class TestCppNsImport(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr25925")
 def test_with_run_command(self):
 """Tests imported namespaces in C++."""
 self.build()


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


[Lldb-commits] [PATCH] D33213: Use socketpair on all Unix platforms

2017-08-10 Thread Demi Marie Obenour via Phabricator via lldb-commits
DemiMarie updated this revision to Diff 110636.
DemiMarie added a comment.

Delete misleading comment


https://reviews.llvm.org/D33213

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  tools/lldb-server/lldb-gdbserver.cpp

Index: tools/lldb-server/lldb-gdbserver.cpp
===
--- tools/lldb-server/lldb-gdbserver.cpp
+++ tools/lldb-server/lldb-gdbserver.cpp
@@ -106,6 +106,7 @@
// than llgs listening for a connection from address on port.
 {"setsid", no_argument, NULL,
  'S'}, // Call setsid() to make llgs run in its own session.
+{"fd", required_argument, NULL, 'F'},
 {NULL, 0, NULL, 0}};
 
 //--
@@ -132,13 +133,13 @@
   "[--log-file log-file-name] "
   "[--log-channels log-channel-list] "
   "[--setsid] "
+  "[--fd file-descriptor]"
   "[--named-pipe named-pipe-path] "
   "[--native-regs] "
   "[--attach pid] "
   "[[HOST]:PORT] "
   "[-- PROGRAM ARG1 ARG2 ...]\n",
   progname, subcommand);
-  exit(0);
 }
 
 void handle_attach_to_pid(GDBRemoteCommunicationServerLLGS &gdb_server,
@@ -232,10 +233,34 @@
  GDBRemoteCommunicationServerLLGS &gdb_server,
  bool reverse_connect, const char *const host_and_port,
  const char *const progname, const char *const subcommand,
- const char *const named_pipe_path, int unnamed_pipe_fd) {
+ const char *const named_pipe_path, int unnamed_pipe_fd,
+ int connection_fd) {
   Status error;
 
-  if (host_and_port && host_and_port[0]) {
+  std::unique_ptr connection_up;
+  if (connection_fd != -1) {
+// Build the connection string.
+char connection_url[512];
+snprintf(connection_url, sizeof(connection_url), "fd://%d", connection_fd);
+
+// Create the connection.
+#if !defined LLDB_DISABLE_POSIX && !defined _WIN32
+::fcntl(connection_fd, F_SETFD, FD_CLOEXEC);
+#endif
+connection_up.reset(new ConnectionFileDescriptor);
+auto connection_result = connection_up->Connect(connection_url, &error);
+if (connection_result != eConnectionStatusSuccess) {
+  fprintf(stderr, "error: failed to connect to client at '%s' "
+  "(connection status: %d)",
+  connection_url, static_cast(connection_result));
+  exit(-1);
+}
+if (error.Fail()) {
+  fprintf(stderr, "error: failed to connect to client at '%s': %s",
+  connection_url, error.AsCString());
+  exit(-1);
+}
+  } else if (host_and_port && host_and_port[0]) {
 // Parse out host and port.
 std::string final_host_and_port;
 std::string connection_host;
@@ -255,7 +280,6 @@
   connection_portno = StringConvert::ToUInt32(connection_port.c_str(), 0);
 }
 
-std::unique_ptr connection_up;
 
 if (reverse_connect) {
   // llgs will connect to the gdb-remote client.
@@ -328,14 +352,14 @@
   }
   connection_up.reset(conn);
 }
-error = gdb_server.InitializeConnection(std::move(connection_up));
-if (error.Fail()) {
-  fprintf(stderr, "Failed to initialize connection: %s\n",
-  error.AsCString());
-  exit(-1);
-}
-printf("Connection established.\n");
   }
+  error = gdb_server.InitializeConnection(std::move(connection_up));
+  if (error.Fail()) {
+fprintf(stderr, "Failed to initialize connection: %s\n",
+error.AsCString());
+exit(-1);
+  }
+  printf("Connection established.\n");
 }
 
 //--
@@ -364,6 +388,7 @@
   log_channels; // e.g. "lldb process threads:gdb-remote default:linux all"
   int unnamed_pipe_fd = -1;
   bool reverse_connect = false;
+  int connection_fd = -1;
 
   // ProcessLaunchInfo launch_info;
   ProcessAttachInfo attach_info;
@@ -413,6 +438,10 @@
   reverse_connect = true;
   break;
 
+case 'F':
+  connection_fd = StringConvert::ToUInt32(optarg, -1);
+  break;
+
 #ifndef _WIN32
 case 'S':
   // Put llgs into a new session. Terminals group processes
@@ -472,7 +501,8 @@
   argc -= optind;
   argv += optind;
 
-  if (argc == 0) {
+  if (argc == 0 && connection_fd == -1) {
+fputs("No arguments\n", stderr);
 display_usage(progname, subcommand);
 exit(255);
   }
@@ -501,7 +531,7 @@
 
   ConnectToRemote(mainloop, gdb_server, reverse_connect, host_and_port,
   progname, subcommand, named_pipe_path.c_str(),
-  unnamed_pipe_fd);
+  unnamed_pipe_fd, connection_fd);
 
   if (!gdb_server.IsConnected()) {
 fprintf(stderr, "no connection information provided, unable to run\n");
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
==

[Lldb-commits] [PATCH] D33213: Use socketpair on all Unix platforms

2017-08-10 Thread Demi Marie Obenour via Phabricator via lldb-commits
DemiMarie updated this revision to Diff 110642.
DemiMarie added a comment.

Fix misleading comment for real


https://reviews.llvm.org/D33213

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  tools/lldb-server/lldb-gdbserver.cpp

Index: tools/lldb-server/lldb-gdbserver.cpp
===
--- tools/lldb-server/lldb-gdbserver.cpp
+++ tools/lldb-server/lldb-gdbserver.cpp
@@ -106,6 +106,7 @@
// than llgs listening for a connection from address on port.
 {"setsid", no_argument, NULL,
  'S'}, // Call setsid() to make llgs run in its own session.
+{"fd", required_argument, NULL, 'F'},
 {NULL, 0, NULL, 0}};
 
 //--
@@ -132,13 +133,13 @@
   "[--log-file log-file-name] "
   "[--log-channels log-channel-list] "
   "[--setsid] "
+  "[--fd file-descriptor]"
   "[--named-pipe named-pipe-path] "
   "[--native-regs] "
   "[--attach pid] "
   "[[HOST]:PORT] "
   "[-- PROGRAM ARG1 ARG2 ...]\n",
   progname, subcommand);
-  exit(0);
 }
 
 void handle_attach_to_pid(GDBRemoteCommunicationServerLLGS &gdb_server,
@@ -232,10 +233,34 @@
  GDBRemoteCommunicationServerLLGS &gdb_server,
  bool reverse_connect, const char *const host_and_port,
  const char *const progname, const char *const subcommand,
- const char *const named_pipe_path, int unnamed_pipe_fd) {
+ const char *const named_pipe_path, int unnamed_pipe_fd,
+ int connection_fd) {
   Status error;
 
-  if (host_and_port && host_and_port[0]) {
+  std::unique_ptr connection_up;
+  if (connection_fd != -1) {
+// Build the connection string.
+char connection_url[512];
+snprintf(connection_url, sizeof(connection_url), "fd://%d", connection_fd);
+
+// Create the connection.
+#if !defined LLDB_DISABLE_POSIX && !defined _WIN32
+::fcntl(connection_fd, F_SETFD, FD_CLOEXEC);
+#endif
+connection_up.reset(new ConnectionFileDescriptor);
+auto connection_result = connection_up->Connect(connection_url, &error);
+if (connection_result != eConnectionStatusSuccess) {
+  fprintf(stderr, "error: failed to connect to client at '%s' "
+  "(connection status: %d)",
+  connection_url, static_cast(connection_result));
+  exit(-1);
+}
+if (error.Fail()) {
+  fprintf(stderr, "error: failed to connect to client at '%s': %s",
+  connection_url, error.AsCString());
+  exit(-1);
+}
+  } else if (host_and_port && host_and_port[0]) {
 // Parse out host and port.
 std::string final_host_and_port;
 std::string connection_host;
@@ -255,7 +280,6 @@
   connection_portno = StringConvert::ToUInt32(connection_port.c_str(), 0);
 }
 
-std::unique_ptr connection_up;
 
 if (reverse_connect) {
   // llgs will connect to the gdb-remote client.
@@ -328,14 +352,14 @@
   }
   connection_up.reset(conn);
 }
-error = gdb_server.InitializeConnection(std::move(connection_up));
-if (error.Fail()) {
-  fprintf(stderr, "Failed to initialize connection: %s\n",
-  error.AsCString());
-  exit(-1);
-}
-printf("Connection established.\n");
   }
+  error = gdb_server.InitializeConnection(std::move(connection_up));
+  if (error.Fail()) {
+fprintf(stderr, "Failed to initialize connection: %s\n",
+error.AsCString());
+exit(-1);
+  }
+  printf("Connection established.\n");
 }
 
 //--
@@ -364,6 +388,7 @@
   log_channels; // e.g. "lldb process threads:gdb-remote default:linux all"
   int unnamed_pipe_fd = -1;
   bool reverse_connect = false;
+  int connection_fd = -1;
 
   // ProcessLaunchInfo launch_info;
   ProcessAttachInfo attach_info;
@@ -413,6 +438,10 @@
   reverse_connect = true;
   break;
 
+case 'F':
+  connection_fd = StringConvert::ToUInt32(optarg, -1);
+  break;
+
 #ifndef _WIN32
 case 'S':
   // Put llgs into a new session. Terminals group processes
@@ -472,7 +501,8 @@
   argc -= optind;
   argv += optind;
 
-  if (argc == 0) {
+  if (argc == 0 && connection_fd == -1) {
+fputs("No arguments\n", stderr);
 display_usage(progname, subcommand);
 exit(255);
   }
@@ -501,7 +531,7 @@
 
   ConnectToRemote(mainloop, gdb_server, reverse_connect, host_and_port,
   progname, subcommand, named_pipe_path.c_str(),
-  unnamed_pipe_fd);
+  unnamed_pipe_fd, connection_fd);
 
   if (!gdb_server.IsConnected()) {
 fprintf(stderr, "no connection information provided, unable to run\n");
Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

[Lldb-commits] [PATCH] D36598: Prevent gtests from using includes from project root

2017-08-10 Thread Tim Hammerquist via Phabricator via lldb-commits
penryu created this revision.
Herald added subscribers: mgorny, emaste.

At present, several gtests in the lldb open source codebase are using
#include statements rooted at $(SOURCE_ROOT)/${LLDB_PROJECT_ROOT}.
This patch cleans up this directory/include structure for both CMake and
Xcode build systems.

rdar://problem/33835795


https://reviews.llvm.org/D36598

Files:
  lldb.xcodeproj/project.pbxproj
  unittests/CMakeLists.txt
  unittests/Interpreter/TestCompletion.cpp
  unittests/ObjectFile/ELF/TestObjectFileELF.cpp
  unittests/Process/minidump/MinidumpParserTest.cpp
  unittests/Symbol/TestDWARFCallFrameInfo.cpp
  unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
  unittests/Target/ModuleCacheTest.cpp

Index: unittests/Target/ModuleCacheTest.cpp
===
--- unittests/Target/ModuleCacheTest.cpp
+++ unittests/Target/ModuleCacheTest.cpp
@@ -10,7 +10,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Target/ModuleCache.h"
-#include "unittests/Utility/Helpers/TestUtilities.h"
+#include "Utility/Helpers/TestUtilities.h"
 
 using namespace lldb_private;
 using namespace lldb;
Index: unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -28,7 +28,7 @@
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/SymbolVendor.h"
 #include "lldb/Utility/FileSpec.h"
-#include "unittests/Utility/Helpers/TestUtilities.h"
+#include "Utility/Helpers/TestUtilities.h"
 
 using namespace lldb_private;
 
Index: unittests/Symbol/TestDWARFCallFrameInfo.cpp
===
--- unittests/Symbol/TestDWARFCallFrameInfo.cpp
+++ unittests/Symbol/TestDWARFCallFrameInfo.cpp
@@ -16,7 +16,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/DWARFCallFrameInfo.h"
 #include "lldb/Utility/StreamString.h"
-#include "unittests/Utility/Helpers/TestUtilities.h"
+#include "Utility/Helpers/TestUtilities.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
Index: unittests/Process/minidump/MinidumpParserTest.cpp
===
--- unittests/Process/minidump/MinidumpParserTest.cpp
+++ unittests/Process/minidump/MinidumpParserTest.cpp
@@ -23,7 +23,7 @@
 #include "lldb/Utility/DataBufferLLVM.h"
 #include "lldb/Utility/DataExtractor.h"
 #include "lldb/Utility/FileSpec.h"
-#include "unittests/Utility/Helpers/TestUtilities.h"
+#include "Utility/Helpers/TestUtilities.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
Index: unittests/ObjectFile/ELF/TestObjectFileELF.cpp
===
--- unittests/ObjectFile/ELF/TestObjectFileELF.cpp
+++ unittests/ObjectFile/ELF/TestObjectFileELF.cpp
@@ -14,7 +14,7 @@
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/Section.h"
 #include "lldb/Host/HostInfo.h"
-#include "unittests/Utility/Helpers/TestUtilities.h"
+#include "Utility/Helpers/TestUtilities.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
Index: unittests/Interpreter/TestCompletion.cpp
===
--- unittests/Interpreter/TestCompletion.cpp
+++ unittests/Interpreter/TestCompletion.cpp
@@ -12,7 +12,7 @@
 #include "lldb/Utility/StringList.h"
 #include "lldb/Utility/TildeExpressionResolver.h"
 
-#include "unittests/Utility/Helpers/MockTildeExpressionResolver.h"
+#include "Utility/Helpers/MockTildeExpressionResolver.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
Index: unittests/CMakeLists.txt
===
--- unittests/CMakeLists.txt
+++ unittests/CMakeLists.txt
@@ -2,7 +2,7 @@
 set_target_properties(LLDBUnitTests PROPERTIES FOLDER "LLDB tests")
 
 include_directories(${LLDB_SOURCE_ROOT})
-include_directories(${LLDB_PROJECT_ROOT})
+include_directories(${LLDB_PROJECT_ROOT}/unittests)
 
 set(LLDB_GTEST_COMMON_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/gtest_common.h)
 if (MSVC)
Index: lldb.xcodeproj/project.pbxproj
===
--- lldb.xcodeproj/project.pbxproj
+++ lldb.xcodeproj/project.pbxproj
@@ -8456,7 +8456,7 @@
 	"$(LLVM_SOURCE_DIR)/tools/clang/include",
 	"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)/tools/clang/include",
 );
-LLDB_GTESTS_CFLAGS = "-I ${SOURCE_ROOT} -I $(LLVM_SOURCE_DIR)/utils/unittest/googlemock/include -I $(LLVM_SOURCE_DIR)/utils/unittest/googletest/include -I $(LLVM_SOURCE_DIR)/include -I $(LLVM_BUILD_DIR)/x86_64/include -I include -I source -I $(PYTHON_FRAMEWORK_PATH)/Headers";
+LLD