summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorWalter Erquinigo <a20012251@gmail.com>2019-10-16 18:47:05 +0000
committerWalter Erquinigo <a20012251@gmail.com>2019-10-16 18:47:05 +0000
commit48a50ee0344d626fc4b51f6d2acf1fa2354bc46b (patch)
treed96772527c1ccd1158e699b7433f5a4c0c398fe5 /lldb/packages/Python/lldbsuite
parenta86bd22515952c184471c95aaf6273cd6a94505b (diff)
downloadbcm5719-llvm-48a50ee0344d626fc4b51f6d2acf1fa2354bc46b.tar.gz
bcm5719-llvm-48a50ee0344d626fc4b51f6d2acf1fa2354bc46b.zip
[android/process list] support showing process arguments
Summary: The qfProcessInfo and qsProcessInfo packets currently don't set the processes' arguments, however the platform process list -v command tries to print it. In this diff I'm adding the arguments as part of the packet, and now the command shows the arguments just like on mac. On Mac: 507 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/secd 503 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/secinitd 501 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/languageassetd --firstLogin 497 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/trustd --agent 496 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/lsd 494 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /System/Library/Frameworks/CoreTelephony.framework/Support/CommCenter -L 491 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/sbin/distnoted agent 489 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/libexec/UserEventAgent (Aqua) 484 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /usr/sbin/cfprefsd agent 483 1 wallace 1876110778 wallace 1876110778 x86_64-apple-macosx /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd On android: 1561 1016 root 0 0 aarch64-unknown-linux-android /system/bin/ip6tables-restore--noflush -w -v 1805 982 1000 1000 1000 android:drmService 1811 982 10189 10189 10189 com.qualcomm.embms:remote 1999 1 1000 1000 1000 aarch64-unknown-linux-android /system/bin/tlc_serverCCM 2332 982 10038 10038 10038 com.android.systemui 2378 983 1053 1053 1053 webview_zygote 2448 982 5013 5013 5013 com.sec.location.nsflp2 2465 982 10027 10027 10027 com.google.android.gms.persistent Differential Revision: https://reviews.llvm.org/D68293 llvm-svn: 375029
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py32
-rw-r--r--lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp9
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py40
4 files changed, 82 insertions, 4 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile b/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile
new file mode 100644
index 00000000000..b560876f24e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/commands/platform/process/Makefile
@@ -0,0 +1,5 @@
+CXX_SOURCES := main.cpp
+
+EXE := TestProcess
+
+include Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py b/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
new file mode 100644
index 00000000000..e7a0273bbd8
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/commands/platform/process/TestProcessList.py
@@ -0,0 +1,32 @@
+"""
+Test process list.
+"""
+
+from __future__ import print_function
+
+
+import os
+import lldb
+import shutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class ProcessListTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def test_process_list_with_args(self):
+ """Test process list show process args"""
+ self.build()
+ exe = self.getBuildArtifact("TestProcess")
+
+ # Spawn a new process
+ popen = self.spawnSubprocess(exe, args=["arg1", "--arg2", "arg3"])
+ self.addTearDownHook(self.cleanupSubprocesses)
+
+ self.expect("platform process list -v",
+ substrs=["TestProcess arg1 --arg2 arg3", str(popen.pid)])
diff --git a/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp
new file mode 100644
index 00000000000..da43e60155e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/commands/platform/process/main.cpp
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+#include <chrono>
+#include <thread>
+
+int main(int argc, char const *argv[]) {
+ std::this_thread::sleep_for(std::chrono::seconds(30));
+ return 0;
+}
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
index f85665a17e5..2da8dd59e17 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py
@@ -5,6 +5,8 @@ from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
from gdbclientutils import *
+def hexlify(string):
+ return binascii.hexlify(string.encode()).decode()
class TestPlatformClient(GDBRemoteTestBase):
@@ -12,22 +14,52 @@ class TestPlatformClient(GDBRemoteTestBase):
"""Test connecting to a remote linux platform"""
class MyResponder(MockGDBServerResponder):
+ def __init__(self):
+ MockGDBServerResponder.__init__(self)
+ self.currentQsProc = 0
+ self.all_users = False
+
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/test_process".encode()).decode() + ";"
+ self.all_users = True
+ name = hexlify("/a/test_process")
+ args = "-".join(map(hexlify,
+ ["/system/bin/sh", "-c", "/data/local/tmp/lldb-server"]))
+ return "pid:10;ppid:1;uid:2;gid:3;euid:4;egid:5;name:" + name + ";args:" + args + ";"
else:
+ self.all_users = False
return "E04"
- self.server.responder = MyResponder()
+ def qsProcessInfo(self):
+ if self.all_users:
+ if self.currentQsProc == 0:
+ self.currentQsProc = 1
+ name = hexlify("/b/another_test_process")
+ # This intentionally has a badly encoded argument
+ args = "X".join(map(hexlify,
+ ["/system/bin/ls", "--help"]))
+ return "pid:11;ppid:2;uid:3;gid:4;euid:5;egid:6;name:" + name + ";args:" + args + ";"
+ elif self.currentQsProc == 1:
+ self.currentQsProc = 0
+ return "E04"
+ else:
+ return "E04"
- self.runCmd("platform select remote-linux")
+ self.server.responder = MyResponder()
try:
+ self.runCmd("platform select remote-linux")
self.runCmd("platform connect connect://localhost:%d" %
self.server.port)
self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
self.expect("platform process list -x",
- substrs=["1 matching process was found", "test_process"])
+ substrs=["2 matching processes were found", "test_process", "another_test_process"])
+ self.expect("platform process list -xv",
+ substrs=[
+ "PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE ARGUMENTS",
+ "10 1 2 3 4 5 /system/bin/sh -c /data/local/tmp/lldb-server",
+ "11 2 3 4 5 6"])
+ self.expect("platform process list -xv", substrs=["/system/bin/ls"], matching=False)
self.expect("platform process list",
error=True,
substrs=["error: no processes were found on the \"remote-linux\" platform"])
OpenPOWER on IntegriCloud