[Lldb-commits] [PATCH] D102872: Fix lldb-server build failure on mips

2021-10-17 Thread John Paul Adrian Glaubitz via Phabricator via lldb-commits
glaubitz added a comment.

This failure affects 32-bit PowerPC as well. Can we get this fixed?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102872/new/

https://reviews.llvm.org/D102872

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


[Lldb-commits] [PATCH] D102872: Fix lldb-server build failure on mips

2021-10-17 Thread John Paul Adrian Glaubitz via Phabricator via lldb-commits
glaubitz added a comment.

It seems we need this change on all architectures except arm, arm64, ppc64el, 
s390x and x86_64. Those are the only ones which implement 
NativeRegisterContextLinux_$ARCH.

See: 
https://github.com/llvm/llvm-project/tree/main/lldb/source/Plugins/Process/Linux


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102872/new/

https://reviews.llvm.org/D102872

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


[Lldb-commits] [PATCH] D111963: [lldb] [lldb-server] Refactor ConnectToRemote()

2021-10-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
mgorny requested review of this revision.

Refactor ConnectToRemote() to improve readability and make future
changes easier:

1. Replace static buffers with std::string.
2. When handling errors, prefer reporting the actual error over dumb 
'connection status is not success'.
3. Move host/port parsing directly into reverse_connection condition that is 
its only user, and simplify it to make its purpose (verifying that a valid port 
is provided) clear.


https://reviews.llvm.org/D111963

Files:
  lldb/tools/lldb-server/lldb-gdbserver.cpp

Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -199,8 +199,7 @@
   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);
+std::string connection_url = llvm::formatv("fd://{0}", connection_fd).str();
 
 // Create the connection.
 #if LLDB_ENABLE_POSIX && !defined _WIN32
@@ -208,23 +207,20 @@
 #endif
 connection_up.reset(new ConnectionFileDescriptor);
 auto connection_result = connection_up->Connect(connection_url, &error);
+if (error.Fail()) {
+  fprintf(stderr, "error: failed to connect to client at '%s': %s\n",
+  connection_url.c_str(), error.AsCString());
+  exit(-1);
+}
 if (connection_result != eConnectionStatusSuccess) {
   fprintf(stderr, "error: failed to connect to client at '%s' "
   "(connection status: %d)\n",
-  connection_url, static_cast(connection_result));
-  exit(-1);
-}
-if (error.Fail()) {
-  fprintf(stderr, "error: failed to connect to client at '%s': %s\n",
-  connection_url, error.AsCString());
+  connection_url.c_str(), static_cast(connection_result));
   exit(-1);
 }
   } else if (!host_and_port.empty()) {
 // Parse out host and port.
 std::string final_host_and_port;
-std::string connection_host;
-std::string connection_port;
-uint32_t connection_portno = 0;
 
 // If host_and_port starts with ':', default the host to be "localhost" and
 // expect the remainder to be the port.
@@ -232,20 +228,15 @@
   final_host_and_port.append("localhost");
 final_host_and_port.append(host_and_port.str());
 
-// Note: use rfind, because the host/port may look like "[::1]:12345".
-const std::string::size_type colon_pos = final_host_and_port.rfind(':');
-if (colon_pos != std::string::npos) {
-  connection_host = final_host_and_port.substr(0, colon_pos);
-  connection_port = final_host_and_port.substr(colon_pos + 1);
-  // FIXME: improve error handling
-  llvm::to_integer(connection_port, connection_portno);
-}
-
-
 if (reverse_connect) {
   // llgs will connect to the gdb-remote client.
 
   // Ensure we have a port number for the connection.
+  // Note: use rfind, because the host/port may look like "[::1]:12345".
+  uint32_t connection_portno = 0;
+  const std::string::size_type colon_pos = final_host_and_port.rfind(':');
+  if (colon_pos != std::string::npos)
+llvm::to_integer(final_host_and_port.substr(colon_pos + 1), connection_portno);
   if (connection_portno == 0) {
 fprintf(stderr, "error: port number must be specified on when using "
 "reverse connect\n");
@@ -253,22 +244,21 @@
   }
 
   // Build the connection string.
-  char connection_url[512];
-  snprintf(connection_url, sizeof(connection_url), "connect://%s",
-   final_host_and_port.c_str());
+  final_host_and_port.insert(0, "connect://");
 
   // Create the connection.
   connection_up.reset(new ConnectionFileDescriptor);
-  auto connection_result = connection_up->Connect(connection_url, &error);
+  auto connection_result = connection_up->Connect(final_host_and_port,
+  &error);
+  if (error.Fail()) {
+fprintf(stderr, "error: failed to connect to client at '%s': %s\n",
+final_host_and_port.c_str(), error.AsCString());
+exit(-1);
+  }
   if (connection_result != eConnectionStatusSuccess) {
 fprintf(stderr, "error: failed to connect to client at '%s' "
 "(connection status: %d)\n",
-connection_url, static_cast(connection_result));
-exit(-1);
-  }
-  if (error.Fail()) {
-fprintf(stderr, "error: failed to connect to client at '%s': %s\n",
-connection_url, error.AsCString());
+final_host_and_port.c_str(), static_cast(connection_result));
 exit(-1);
   }
 } else {
__

[Lldb-commits] [PATCH] D111964: [lldb] [lldb-server] Support listening on serial://

2021-10-17 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste, teemperor.
mgorny requested review of this revision.

Support listening on serial port when serial:// protocol is being used
in place of host/port.  This is not fully functional yet, as lldb-server
crashes when attempting to send long packets (e.g. target.xml contents).


https://reviews.llvm.org/D111964

Files:
  lldb/tools/lldb-server/lldb-gdbserver.cpp


Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -228,23 +228,26 @@
   final_host_and_port.append("localhost");
 final_host_and_port.append(host_and_port.str());
 
-if (reverse_connect) {
+bool is_serial = host_and_port.startswith("serial://");
+if (reverse_connect || is_serial) {
   // llgs will connect to the gdb-remote client.
 
-  // Ensure we have a port number for the connection.
-  // Note: use rfind, because the host/port may look like "[::1]:12345".
-  uint32_t connection_portno = 0;
-  const std::string::size_type colon_pos = final_host_and_port.rfind(':');
-  if (colon_pos != std::string::npos)
-llvm::to_integer(final_host_and_port.substr(colon_pos + 1), 
connection_portno);
-  if (connection_portno == 0) {
-fprintf(stderr, "error: port number must be specified on when using "
-"reverse connect\n");
-exit(1);
-  }
+  if (!is_serial) {
+// Ensure we have a port number for the connection.
+// Note: use rfind, because the host/port may look like "[::1]:12345".
+uint32_t connection_portno = 0;
+const std::string::size_type colon_pos = 
final_host_and_port.rfind(':');
+if (colon_pos != std::string::npos)
+  llvm::to_integer(final_host_and_port.substr(colon_pos + 1), 
connection_portno);
+if (connection_portno == 0) {
+  fprintf(stderr, "error: port number must be specified on when using "
+  "reverse connect\n");
+  exit(1);
+}
 
-  // Build the connection string.
-  final_host_and_port.insert(0, "connect://");
+// Build the connection string.
+final_host_and_port.insert(0, "connect://");
+  }
 
   // Create the connection.
   connection_up.reset(new ConnectionFileDescriptor);


Index: lldb/tools/lldb-server/lldb-gdbserver.cpp
===
--- lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -228,23 +228,26 @@
   final_host_and_port.append("localhost");
 final_host_and_port.append(host_and_port.str());
 
-if (reverse_connect) {
+bool is_serial = host_and_port.startswith("serial://");
+if (reverse_connect || is_serial) {
   // llgs will connect to the gdb-remote client.
 
-  // Ensure we have a port number for the connection.
-  // Note: use rfind, because the host/port may look like "[::1]:12345".
-  uint32_t connection_portno = 0;
-  const std::string::size_type colon_pos = final_host_and_port.rfind(':');
-  if (colon_pos != std::string::npos)
-llvm::to_integer(final_host_and_port.substr(colon_pos + 1), connection_portno);
-  if (connection_portno == 0) {
-fprintf(stderr, "error: port number must be specified on when using "
-"reverse connect\n");
-exit(1);
-  }
+  if (!is_serial) {
+// Ensure we have a port number for the connection.
+// Note: use rfind, because the host/port may look like "[::1]:12345".
+uint32_t connection_portno = 0;
+const std::string::size_type colon_pos = final_host_and_port.rfind(':');
+if (colon_pos != std::string::npos)
+  llvm::to_integer(final_host_and_port.substr(colon_pos + 1), connection_portno);
+if (connection_portno == 0) {
+  fprintf(stderr, "error: port number must be specified on when using "
+  "reverse connect\n");
+  exit(1);
+}
 
-  // Build the connection string.
-  final_host_and_port.insert(0, "connect://");
+// Build the connection string.
+final_host_and_port.insert(0, "connect://");
+  }
 
   // Create the connection.
   connection_up.reset(new ConnectionFileDescriptor);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111965: [lldb] improve the help strings for gdb-remote and kdp-remote

2021-10-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: jasonmolenda, JDevlieghere.
lawrence_danna requested review of this revision.
Herald added a project: LLDB.

The help string can be more helpful by explaining these are 
aliases for 'process connect'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111965

Files:
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,9 @@
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin 
gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +763,9 @@
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin 
kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,9 @@
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +763,9 @@
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111965: [lldb] improve the help strings for gdb-remote and kdp-remote

2021-10-17 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna updated this revision to Diff 380257.
lawrence_danna added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111965/new/

https://reviews.llvm.org/D111965

Files:
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,10 @@
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin "
+  "gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +764,10 @@
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin "
+  "kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -744,8 +744,10 @@
   std::unique_ptr connect_gdb_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "gdb-remote",
-  "Connect to a process via remote GDB server.  "
-  "If no host is specifed, localhost is assumed.",
+  "Connect to a process via remote GDB server.\n"
+  "If no host is specifed, localhost is assumed.\n"
+  "gdb-remote is an abbreviation for 'process connect --plugin "
+  "gdb-remote connect://:'\n",
   "gdb-remote [:]", 2, 0, false));
   if (connect_gdb_remote_cmd_up) {
 if (connect_gdb_remote_cmd_up->AddRegexCommand(
@@ -762,9 +764,10 @@
   std::unique_ptr connect_kdp_remote_cmd_up(
   new CommandObjectRegexCommand(
   *this, "kdp-remote",
-  "Connect to a process via remote KDP server.  "
-  "If no UDP port is specified, port 41139 is "
-  "assumed.",
+  "Connect to a process via remote KDP server.\n"
+  "If no UDP port is specified, port 41139 is assumed.\n"
+  "kdp-remote is an abbreviation for 'process connect --plugin "
+  "kdp-remote udp://:'\n",
   "kdp-remote [:]", 2, 0, false));
   if (connect_kdp_remote_cmd_up) {
 if (connect_kdp_remote_cmd_up->AddRegexCommand(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c900b0a - [lldb] Skip target variable test on AS

2021-10-17 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-10-17T19:12:24-07:00
New Revision: c900b0a6d5f7aba7d71c3f0d02eb27a2bc9c9448

URL: 
https://github.com/llvm/llvm-project/commit/c900b0a6d5f7aba7d71c3f0d02eb27a2bc9c9448
DIFF: 
https://github.com/llvm/llvm-project/commit/c900b0a6d5f7aba7d71c3f0d02eb27a2bc9c9448.diff

LOG: [lldb] Skip target variable test on AS

Added: 


Modified: 
lldb/test/API/commands/target/basic/TestTargetCommand.py

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 15b226b4d3bf2..8a57b05ebb316 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -45,6 +45,7 @@ def test_target_command(self):
 self.do_target_command()
 
 @expectedFailureAll(archs=['arm64e']) # 
+@expectedFailureDarwin(archs=["arm64"]) # 
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -54,6 +55,7 @@ def test_target_variable_command(self):
 self.do_target_variable_command('globals')
 
 @expectedFailureAll(archs=['arm64e']) # 
+@expectedFailureDarwin(archs=["arm64"]) # 
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}



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


[Lldb-commits] [PATCH] D111890: [lldb] [Host] Make Terminal methods return llvm::Error

2021-10-17 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/include/lldb/Host/Terminal.h:21
 public:
+  struct Data;
+

Move this into the protected section



Comment at: lldb/source/Host/common/Terminal.cpp:76
+  struct termios &fd_termios = data->m_termios;
+  bool set_corectly = false;
+  if (enabled) {

mgorny wrote:
> My gut feeling is telling me that this can be simplified somehow… or we could 
> assume `tcsetattr()` is cheap and just do the change unconditionally.
yeah, I think it'd be fine to call tcsetattr unconditionally


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111890/new/

https://reviews.llvm.org/D111890

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