Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp67553imm; Wed, 5 Sep 2018 15:07:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbE1PdBeb0ME4UzZPnEoM7shE4aL3uiBGd1bi7kEL//hTHrdKuxZ9rBef2HDSFh3BJoojwa X-Received: by 2002:a62:8208:: with SMTP id w8-v6mr42189814pfd.215.1536185244752; Wed, 05 Sep 2018 15:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185244; cv=none; d=google.com; s=arc-20160816; b=GNwr9G33cgH6cQbShlfxbbqUk/f2B2u3889dn5eiC1M4cNeMYzQY4s6AZnCGHYSSlO VUFleLHomnLvLOq8bi0Gnz7ctnRvoKvZqr5WffNSz8hM39o64laD1+SQtDZqB3zS4y87 e0RSR8Qz3h78zGLb0PcUjcG28fKxuPhGj3lYbvYs4J+lvLgzn+30xFr+Qn3A1HIghYbJ zaSl6TzzgnjQYq5ToNVShLY/qVFGif1iiW9TdxvKZ2uOiUbwi6/lVBVZP7XnM6RHrEMI M/nS81CTVw+16EDYd6fpjopwkJ3R34+9CURaqgSfBJn2HxlspEfso5D+v03rv0YqWEnE pJVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7C7kfh+kXAuAPgvbIOq7MpbWeHIU1P4nZ8cmLol8IEM=; b=qAgSzFgNfujgdnJshxYvrndujG1Wvjh25X2NrK30dLjZtX9jNvuDsC9OwNHYlYoc4r wTw+hnnmVGTDOOiJMomdlWbq2qH5xvVriD6lh18f6lGQaUWHWKrAwCUlCaOTOCeZ0z18 WCdzQ+zCxi3xD/DnfwEzTE+7OVEGib3D+jDEY7CFdtg/h/SOEla5JOA4e23MGLR4CqT7 ZC4c+dtK7JVS8ylkbcV6yGyA5+fiSYXGhhc+Jqf0cCa4li/0CKS35e/xz/7JCKcG6Pkm vZMub+Bcvn6UWFWh2GU8zT6vVXZwANohWUK4b1yXYRqrF7BMRbsTcTea1Ci8mz9/muQl WpUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dex2QK2O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k24-v6si3062518pll.460.2018.09.05.15.07.09; Wed, 05 Sep 2018 15:07:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dex2QK2O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727879AbeIFChN (ORCPT + 99 others); Wed, 5 Sep 2018 22:37:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:51146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeIFChN (ORCPT ); Wed, 5 Sep 2018 22:37:13 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 19BB62083D; Wed, 5 Sep 2018 22:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185101; bh=tvYuGRfPeWQUIItiSRIjKl2dOFZzYH0L9YqbIz4qF0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dex2QK2OVcI9S4a6EzPLEtNKtxkNL9zdpeFqfCmQjZVWdPV4VI/2D2F0S5704JCDT mRjZqHxKHel4f0kBEK2guct11qhC6Cc3+QB8NiLkcdnEBVP7qbNbUHQCsllncL04Fh TpAEiO4lneW6f45MXsVYQYAYidZ+dZ05Xxr12My0= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 03/77] perf trace: Print the syscall name for augmented_syscalls Date: Wed, 5 Sep 2018 19:03:26 -0300 Message-Id: <20180905220440.20256-4-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo Since we copy all the payload for raw_syscalls:sys_enter plus add expanded pointers, we can use the syscall id to get its name, etc: # grep 'field:.* id' /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/format field:long id; offset:8; size:8; signed:1; # Before: # perf trace -e tools/perf/examples/bpf/augmented_syscalls.c,openat cat /etc/passwd > /dev/null 0.000 ( ): __augmented_syscalls__:dfd: CWD, filename: 0xec9f9da8, flags: CLOEXEC 0.006 ( 0.006 ms): cat/2395 openat(dfd: CWD, filename: 0xec9f9da8, flags: CLOEXEC) = 3 0.041 ( ): __augmented_syscalls__:dfd: CWD, filename: 0xecc01ce0, flags: CLOEXEC 0.042 ( 0.007 ms): cat/2395 openat(dfd: CWD, filename: 0xecc01ce0, flags: CLOEXEC) = 3 0.376 ( ): __augmented_syscalls__:dfd: CWD, filename: 0xac0a806b 0.379 ( 0.006 ms): cat/2395 openat(dfd: CWD, filename: 0xac0a806b) = 3 # After: # perf trace -e tools/perf/examples/bpf/augmented_syscalls.c,openat cat /etc/passwd > /dev/null 0.000 ( ): openat(dfd: CWD, filename: 0x31b6dda8, flags: CLOEXEC) 0.009 ( 0.009 ms): cat/3619 openat(dfd: CWD, filename: 0x31b6dda8, flags: CLOEXEC) = 3 0.051 ( ): openat(dfd: CWD, filename: 0x31d75ce0, flags: CLOEXEC) 0.054 ( 0.010 ms): cat/3619 openat(dfd: CWD, filename: 0x31d75ce0, flags: CLOEXEC) = 3 0.539 ( ): openat(dfd: CWD, filename: 0xca71506b) 0.543 ( 0.115 ms): cat/3619 openat(dfd: CWD, filename: 0xca71506b) = 3 # Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-epz6y9i0eavmerc5ha98t7gn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7deae6c8cb25..bcf882afd6d0 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2055,13 +2055,33 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, if (trace->trace_syscalls) fprintf(trace->output, "( ): "); + if (evsel == trace->syscalls.events.augmented) { + int id = perf_evsel__sc_tp_uint(evsel, id, sample); + struct syscall *sc = trace__syscall_info(trace, evsel, id); + + if (sc) { + struct thread *thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + + if (thread) { + fprintf(trace->output, "%s(", sc->name); + trace__fprintf_sys_enter(trace, evsel, sample); + fputc(')', trace->output); + thread__put(thread); + goto newline; + } + } + + /* + * XXX: Not having the associated syscall info or not finding/adding + * the thread should never happen, but if it does... + * fall thru and print it as a bpf_output event. + */ + } + fprintf(trace->output, "%s:", evsel->name); if (perf_evsel__is_bpf_output(evsel)) { - if (evsel == trace->syscalls.events.augmented) - trace__fprintf_sys_enter(trace, evsel, sample); - else - bpf_output__fprintf(trace, sample); + bpf_output__fprintf(trace, sample); } else if (evsel->tp_format) { if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || trace__fprintf_sys_enter(trace, evsel, sample)) { @@ -2071,6 +2091,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, } } +newline: fprintf(trace->output, "\n"); if (callchain_ret > 0) -- 2.14.4