pid.c 558 B

123456789101112131415161718192021
  1. // SPDX-License-Identifier: GPL-2.0
  2. size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg)
  3. {
  4. int pid = arg->val;
  5. struct trace *trace = arg->trace;
  6. size_t printed = scnprintf(bf, size, "%d", pid);
  7. struct thread *thread = machine__findnew_thread(trace->host, pid, pid);
  8. if (thread != NULL) {
  9. if (!thread->comm_set)
  10. thread__set_comm_from_proc(thread);
  11. if (thread->comm_set)
  12. printed += scnprintf(bf + printed, size - printed,
  13. " (%s)", thread__comm_str(thread));
  14. thread__put(thread);
  15. }
  16. return printed;
  17. }