summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaoqin Ma <xiaoqinma@google.com>2023-06-01 23:23:20 +0000
committerXiaoqin Ma <xiaoqinma@google.com>2023-06-06 17:34:28 +0000
commitcfe5d215475f5f591b7cee0cfe3f01059d6667b8 (patch)
treebbdd9caf4a9903ab0d576a4dade3140991a1005d
parent7c55708a93cabd1574b346be70a3373c4bb3855c (diff)
downloadtrout-cfe5d215475f5f591b7cee0cfe3f01059d6667b8.tar.gz
Stop memdump_tracelogger on QNX before tracing.
Add an utility function for remote_slay a program on QNX. Bug 285420903 Test: Manually. Change-Id: I3d9e383691bf5b298c63efaf5a3b01f218563ca6
-rwxr-xr-xtools/tracing/tooling/remote_slay.py64
-rwxr-xr-xtools/tracing/tooling/tracing_agent.py7
2 files changed, 71 insertions, 0 deletions
diff --git a/tools/tracing/tooling/remote_slay.py b/tools/tracing/tooling/remote_slay.py
new file mode 100755
index 0000000..90ae1e2
--- /dev/null
+++ b/tools/tracing/tooling/remote_slay.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import paramiko
+import argparse
+
+# Usage:
+# ./remote_slay.py --ip_address 10.42.0.247 --process_name memdump_tracelogger --user_name root
+# If the program is not running on the QNX, output will be:
+# memdump_tracelogger is not running on 10.42.0.247
+#
+# If the program is running on the QNX, output will be:
+# 1 memdump_tracelogger running on 10.42.0.247 are slayed
+
+def slay_process(sshclient, process_name):
+ command = f"slay {process_name}"
+ try:
+ stdin, stdout, stderr = sshclient.exec_command(command)
+ except Exception as e:
+ print(f"slay_process catch an exception: {str(e)}")
+ return False
+
+ # Wait for the command to finish
+ exit_status = stdout.channel.recv_exit_status()
+ print(f"{exit_status} processes are slayed.")
+ return exit_status != 0
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description='Check if a process is running on a remote QNX system.')
+ parser.add_argument('--ip_address', required=True, help='IP address of the remote QNX system')
+ parser.add_argument('--user_name', required=True, help='Name of user')
+ parser.add_argument('--process_name', required=True, help='Name of the process to check')
+ args = parser.parse_args()
+
+ remote_ip = args.ip_address
+ user_name = args.user_name
+ sshclient = paramiko.SSHClient()
+ sshclient.load_system_host_keys()
+ sshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ sshclient.connect(remote_ip, username=user_name)
+
+ process_name = args.process_name
+ result = slay_process(sshclient, process_name)
+ sshclient.close()
+
+ if result:
+ print(f'{process_name} running on {remote_ip} are slayed')
+ else:
+ sys.exit('No processes matched the supplied criteria, an error occurred, '
+ 'or the number of processes matched and acted upon was an even multiple of 256')
diff --git a/tools/tracing/tooling/tracing_agent.py b/tools/tracing/tooling/tracing_agent.py
index beb8b4a..d9710b8 100755
--- a/tools/tracing/tooling/tracing_agent.py
+++ b/tools/tracing/tooling/tracing_agent.py
@@ -30,6 +30,8 @@ import traceback
from paramiko import SSHClient
from paramiko import AutoAddPolicy
+from remote_slay import slay_process
+
# This script works on Linux workstation.
# We haven't tested on Windows/macOS.
@@ -169,6 +171,11 @@ class QnxTracingAgent(TracingAgent):
# TODO(b/267675642):
# read the trace configuration file to get the tracing parameters
+ if not slay_process(self.client, "memdump_tracelogger"):
+ print("Warning: could not kill memdump_tracelogger on QNX."
+ "If there is a resource busy error reported by QNX, "
+ "execute slay memdump_tracelogger on QNX.")
+
def clientExecuteCmd(self, cmd_str):
self.verbose_print(f'sshclient executing command {cmd_str}')
(stdin, stdout, stderr) = self.client.exec_command(cmd_str)