@@ -549,6 +549,22 @@ def uid_to_name(uid):
549549 return str (uid )
550550
551551
552+ def _resolve_comm (comm , cmdline ):
553+ """Expand a truncated comm using cmdline when available.
554+
555+ The kernel's task->comm is limited to TASK_COMM_LEN (16 bytes,
556+ 15 usable chars). When it looks truncated, scan the cmdline for
557+ the full name.
558+ """
559+ if len (comm ) < 15 or not cmdline :
560+ return comm
561+ for arg in cmdline .split ():
562+ name = os .path .basename (arg )
563+ if name .startswith (comm ):
564+ return name
565+ return comm
566+
567+
552568def build_bpf (target_ino , target_dev , dir_mode , want_stacks ):
553569 """Substitute placeholders in the BPF C source."""
554570 src = bpf_text
@@ -885,8 +901,9 @@ def print_event(cpu, data, size):
885901 indent = " " * i
886902 tag = ">>>" if i == 0 else " "
887903
888- line = "%s %s[%d] %s" % (tag , indent , pid , comm )
889- if cmdline and cmdline != comm :
904+ display_comm = _resolve_comm (comm , cmdline )
905+ line = "%s %s[%d] %s" % (tag , indent , pid , display_comm )
906+ if cmdline and cmdline != display_comm :
890907 line += "\n %scmdline: %s" % (indent , cmdline )
891908 if exe :
892909 line += "\n %sexe: %s" % (indent , exe )
0 commit comments