From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964872AbdGTI5z (ORCPT ); Thu, 20 Jul 2017 04:57:55 -0400 Received: from terminus.zytor.com ([65.50.211.136]:56045 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934945AbdGTI5w (ORCPT ); Thu, 20 Jul 2017 04:57:52 -0400 Date: Thu, 20 Jul 2017 01:55:37 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: jolsa@kernel.org, hpa@zytor.com, tglx@linutronix.de, namhyung@kernel.org, linux-kernel@vger.kernel.org, dsahern@gmail.com, acme@redhat.com, mingo@kernel.org, adrian.hunter@intel.com, wangnan0@huawei.com Reply-To: adrian.hunter@intel.com, wangnan0@huawei.com, jolsa@kernel.org, tglx@linutronix.de, hpa@zytor.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, dsahern@gmail.com, acme@redhat.com, mingo@kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf trace beauty: Export strarray for use in per-object beautifiers Git-Commit-ID: 0ae79636e32889cced620865debd3ba5bfd36daa X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0ae79636e32889cced620865debd3ba5bfd36daa Gitweb: http://git.kernel.org/tip/0ae79636e32889cced620865debd3ba5bfd36daa Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 17 Jul 2017 10:31:42 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 18 Jul 2017 23:14:23 -0300 perf trace beauty: Export strarray for use in per-object beautifiers Like will be done with fcntl(fd, F_GETLEASE, F_RDLCK|F_WRLCK|F_UNLCK) Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-3p11bgirtntjfmbixfkz8i2m@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 27 +++++++-------------------- tools/perf/trace/beauty/beauty.h | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 65fa012..0dedce0 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -283,34 +283,21 @@ out_delete: ({ struct syscall_tp *fields = evsel->priv; \ fields->name.pointer(&fields->name, sample); }) -struct strarray { - int offset; - int nr_entries; - const char **entries; -}; +size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val) +{ + int idx = val - sa->offset; -#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \ - .nr_entries = ARRAY_SIZE(array), \ - .entries = array, \ -} + if (idx < 0 || idx >= sa->nr_entries) + return scnprintf(bf, size, intfmt, val); -#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \ - .offset = off, \ - .nr_entries = ARRAY_SIZE(array), \ - .entries = array, \ + return scnprintf(bf, size, "%s", sa->entries[idx]); } static size_t __syscall_arg__scnprintf_strarray(char *bf, size_t size, const char *intfmt, struct syscall_arg *arg) { - struct strarray *sa = arg->parm; - int idx = arg->val - sa->offset; - - if (idx < 0 || idx >= sa->nr_entries) - return scnprintf(bf, size, intfmt, arg->val); - - return scnprintf(bf, size, "%s", sa->entries[idx]); + return strarray__scnprintf(arg->parm, bf, size, intfmt, arg->val); } static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size, diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index 9ccf0f3..f75ef7d 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -1,8 +1,28 @@ #ifndef _PERF_TRACE_BEAUTY_H #define _PERF_TRACE_BEAUTY_H +#include #include +struct strarray { + int offset; + int nr_entries; + const char **entries; +}; + +#define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \ + .nr_entries = ARRAY_SIZE(array), \ + .entries = array, \ +} + +#define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \ + .offset = off, \ + .nr_entries = ARRAY_SIZE(array), \ + .entries = array, \ +} + +size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val); + struct trace; struct thread;