xref: /kernel/linux/linux-5.10/tools/perf/trace/beauty/pid.c (revision 8c2ecf20)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/tools/perf/trace/beauty/
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_cisize_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg)
48c2ecf20Sopenharmony_ci{
58c2ecf20Sopenharmony_ci	int pid = arg->val;
68c2ecf20Sopenharmony_ci	struct trace *trace = arg->trace;
78c2ecf20Sopenharmony_ci	size_t printed = scnprintf(bf, size, "%d", pid);
88c2ecf20Sopenharmony_ci	struct thread *thread = machine__findnew_thread(trace->host, pid, pid);
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci	if (thread != NULL) {
118c2ecf20Sopenharmony_ci		if (!thread->comm_set)
128c2ecf20Sopenharmony_ci			thread__set_comm_from_proc(thread);
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci		if (thread->comm_set)
158c2ecf20Sopenharmony_ci			printed += scnprintf(bf + printed, size - printed,
168c2ecf20Sopenharmony_ci					     " (%s)", thread__comm_str(thread));
178c2ecf20Sopenharmony_ci		thread__put(thread);
188c2ecf20Sopenharmony_ci	}
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	return printed;
218c2ecf20Sopenharmony_ci}
22

Indexes created Thu Nov 07 10:32:03 CST 2024