summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py34
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py28
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp4
-rw-r--r--lldb/source/Commands/Options.td3
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp3
5 files changed, 68 insertions, 4 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
new file mode 100644
index 00000000000..d0087770256
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
@@ -0,0 +1,34 @@
+import lldb
+import binascii
+import os
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from gdbclientutils import *
+
+
+class TestPlatformClient(GDBRemoteTestBase):
+
+ def test_process_list_with_all_users(self):
+ """Test connecting to a remote linux platform"""
+
+ class MyResponder(MockGDBServerResponder):
+ def qfProcessInfo(self, packet):
+ if "all_users:1" in packet:
+ return "pid:10;ppid:1;uid:1;gid:1;euid:1;egid:1;name:" + binascii.hexlify("/a/process") + ";args:"
+ else:
+ return "E04"
+
+ self.server.responder = MyResponder()
+
+ self.runCmd("platform select remote-linux")
+
+ try:
+ self.runCmd("platform connect connect://localhost:%d" %
+ self.server.port)
+ self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
+ self.expect("platform process list -x",
+ startstr="1 matching process was found", endstr="process" + os.linesep)
+ self.expect("platform process list",
+ error="error: no processes were found on the \"remote-linux\" platform")
+ finally:
+ self.runCmd("platform disconnect")
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
index fad41f8a83a..73c698d1e3e 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py
@@ -160,9 +160,34 @@ class MockGDBServerResponder:
return self.QListThreadsInStopReply()
if packet.startswith("qMemoryRegionInfo:"):
return self.qMemoryRegionInfo()
+ if packet == "qQueryGDBServer":
+ return self.qQueryGDBServer()
+ if packet == "qHostInfo":
+ return self.qHostInfo()
+ if packet == "qGetWorkingDir":
+ return self.qGetWorkingDir()
+ if packet == "qsProcessInfo":
+ return self.qsProcessInfo()
+ if packet.startswith("qfProcessInfo"):
+ return self.qfProcessInfo(packet)
return self.other(packet)
+ def qsProcessInfo(self):
+ return "E04"
+
+ def qfProcessInfo(self, packet):
+ raise "E04"
+
+ def qGetWorkingDir(self):
+ return "2f"
+
+ def qHostInfo(self):
+ return "ptrsize:8;endian:little;"
+
+ def qQueryGDBServer(self):
+ return "E04"
+
def interrupt(self):
raise self.UnexpectedPacketException()
@@ -171,7 +196,7 @@ class MockGDBServerResponder:
def vCont(self, packet):
raise self.UnexpectedPacketException()
-
+
def readRegisters(self):
return "00000000" * self.registerCount
@@ -425,7 +450,6 @@ class MockGDBServer:
class InvalidPacketException(Exception):
pass
-
class GDBRemoteTestBase(TestBase):
"""
Base class for GDB client tests.
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 7fb37839be7..fbd13aa37bd 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1264,6 +1264,10 @@ protected:
verbose = true;
break;
+ case 'x':
+ match_info.SetMatchAllUsers(true);
+ break;
+
default:
llvm_unreachable("Unimplemented option");
}
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 477b5532946..87f5506c305 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -591,6 +591,9 @@ let Command = "platform process list" in {
def platform_process_list_show_args : Option<"show-args", "A">,
GroupRange<1, 6>,
Desc<"Show process arguments instead of the process executable basename.">;
+ def platform_process_list_all_users: Option<"all-users", "x">,
+ GroupRange<1,6>,
+ Desc<"Show processes matching all user IDs.">;
def platform_process_list_verbose : Option<"verbose", "v">, GroupRange<1, 6>,
Desc<"Enable verbose output.">;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 63d0522da3b..7cb9ce0f52f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2176,8 +2176,7 @@ uint32_t GDBRemoteCommunicationClient::FindProcesses(
if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
packet.Printf("egid:%u;",
match_info.GetProcessInfo().GetEffectiveGroupID());
- if (match_info.GetProcessInfo().EffectiveGroupIDIsValid())
- packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
+ packet.Printf("all_users:%u;", match_info.GetMatchAllUsers() ? 1 : 0);
if (match_info.GetProcessInfo().GetArchitecture().IsValid()) {
const ArchSpec &match_arch =
match_info.GetProcessInfo().GetArchitecture();
OpenPOWER on IntegriCloud