linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Zanussi <tom.zanussi@linux.intel.com>
To: rostedt@goodmis.org
Cc: masami.hiramatsu.pt@hitachi.com, namhyung@kernel.org,
	josh@joshtriplett.org, andi@firstfloor.org,
	mathieu.desnoyers@efficios.com, peterz@infradead.org,
	linux-kernel@vger.kernel.org,
	Tom Zanussi <tom.zanussi@linux.intel.com>
Subject: [PATCH v15 09/23] tracing: Add hist trigger 'sym' and 'sym-offset' modifiers
Date: Fri, 26 Feb 2016 10:01:12 -0600	[thread overview]
Message-ID: <d3f7d29e9379d637ea2eca1433a429a140d7314e.1456501855.git.tom.zanussi@linux.intel.com> (raw)
In-Reply-To: <cover.1456501855.git.tom.zanussi@linux.intel.com>
In-Reply-To: <cover.1456501855.git.tom.zanussi@linux.intel.com>

Allow users to have address fields displayed as symbols in the output
by appending '.sym' or 'sym-offset' to field names:

   # echo hist:keys=aaa.sym,bbb.sym-offset ... \
              [ if filter] > event/trigger

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
---
 kernel/trace/trace.c             |  4 +++-
 kernel/trace/trace_events_hist.c | 29 +++++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d6b4692..202220c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3846,7 +3846,9 @@ static const char readme_msg[] =
 	"\t    table in its entirety to stdout.  The default format used to\n"
 	"\t    display a given field can be modified by appending any of the\n"
 	"\t    following modifiers to the field name, as applicable:\n\n"
-	"\t            .hex        display a number as a hex value\n\n"
+	"\t            .hex        display a number as a hex value\n"
+	"\t            .sym        display an address as a symbol\n"
+	"\t            .sym-offset display an address as a symbol and offset\n\n"
 	"\t    The 'pause' parameter can be used to pause an existing hist\n"
 	"\t    trigger or to start a hist trigger but not log any events\n"
 	"\t    until told to do so.  'continue' can be used to start or\n"
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 734cdce..fd4de16 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -77,10 +77,12 @@ DEFINE_HIST_FIELD_FN(u8);
 #define HIST_KEY_SIZE_MAX	(MAX_FILTER_STR_VAL + sizeof(u64))
 
 enum hist_field_flags {
-	HIST_FIELD_FL_HITCOUNT	= 1,
-	HIST_FIELD_FL_KEY	= 2,
-	HIST_FIELD_FL_STRING	= 4,
-	HIST_FIELD_FL_HEX	= 8,
+	HIST_FIELD_FL_HITCOUNT		= 1,
+	HIST_FIELD_FL_KEY		= 2,
+	HIST_FIELD_FL_STRING		= 4,
+	HIST_FIELD_FL_HEX		= 8,
+	HIST_FIELD_FL_SYM		= 16,
+	HIST_FIELD_FL_SYM_OFFSET	= 32,
 };
 
 struct hist_trigger_attrs {
@@ -393,6 +395,10 @@ static int create_key_field(struct hist_trigger_data *hist_data,
 	if (field_str) {
 		if (strcmp(field_str, "hex") == 0)
 			flags |= HIST_FIELD_FL_HEX;
+		else if (strcmp(field_str, "sym") == 0)
+			flags |= HIST_FIELD_FL_SYM;
+		else if (strcmp(field_str, "sym-offset") == 0)
+			flags |= HIST_FIELD_FL_SYM_OFFSET;
 		else {
 			ret = -EINVAL;
 			goto out;
@@ -720,6 +726,7 @@ hist_trigger_entry_print(struct seq_file *m,
 			 struct tracing_map_elt *elt)
 {
 	struct hist_field *key_field;
+	char str[KSYM_SYMBOL_LEN];
 	unsigned int i;
 	u64 uval;
 
@@ -735,6 +742,16 @@ hist_trigger_entry_print(struct seq_file *m,
 			uval = *(u64 *)(key + key_field->offset);
 			seq_printf(m, "%s: %llx",
 				   key_field->field->name, uval);
+		} else if (key_field->flags & HIST_FIELD_FL_SYM) {
+			uval = *(u64 *)(key + key_field->offset);
+			sprint_symbol_no_offset(str, uval);
+			seq_printf(m, "%s: [%llx] %-45s",
+				   key_field->field->name, uval, str);
+		} else if (key_field->flags & HIST_FIELD_FL_SYM_OFFSET) {
+			uval = *(u64 *)(key + key_field->offset);
+			sprint_symbol(str, uval);
+			seq_printf(m, "%s: [%llx] %-55s",
+				   key_field->field->name, uval, str);
 		} else if (key_field->flags & HIST_FIELD_FL_STRING) {
 			seq_printf(m, "%s: %-50s", key_field->field->name,
 				   (char *)(key + key_field->offset));
@@ -850,6 +867,10 @@ static const char *get_hist_field_flags(struct hist_field *hist_field)
 
 	if (hist_field->flags & HIST_FIELD_FL_HEX)
 		flags_str = "hex";
+	else if (hist_field->flags & HIST_FIELD_FL_SYM)
+		flags_str = "sym";
+	else if (hist_field->flags & HIST_FIELD_FL_SYM_OFFSET)
+		flags_str = "sym-offset";
 
 	return flags_str;
 }
-- 
1.9.3

  parent reply	other threads:[~2016-02-26 16:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 16:01 [PATCH 00/23] tracing: 'hist' triggers Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 01/23] tracing: Update some tracing_map constants and comments Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 02/23] tracing: Add 'hist' event trigger command Tom Zanussi
2016-03-02 14:33   ` Steven Rostedt
2016-02-26 16:01 ` [PATCH v15 03/23] tracing: Add hist trigger support for multiple values ('vals=' param) Tom Zanussi
2016-03-02 14:38   ` Steven Rostedt
2016-02-26 16:01 ` [PATCH v15 04/23] tracing: Add hist trigger support for compound keys Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 05/23] tracing: Add hist trigger support for user-defined sorting ('sort=' param) Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 06/23] tracing: Add hist trigger support for pausing and continuing a trace Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 07/23] tracing: Add hist trigger support for clearing " Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 08/23] tracing: Add hist trigger 'hex' modifier for displaying numeric fields Tom Zanussi
2016-02-26 16:01 ` Tom Zanussi [this message]
2016-02-26 16:01 ` [PATCH v15 10/23] tracing: Add hist trigger 'execname' modifier Tom Zanussi
2016-03-02 17:39   ` Steven Rostedt
2016-03-02 19:51     ` Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 11/23] tracing: Add hist trigger 'syscall' modifier Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 12/23] tracing: Add hist trigger support for stacktraces as keys Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 13/23] tracing: Support string type key properly Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 14/23] tracing: Remove restriction on string position in hist trigger keys Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 15/23] tracing: Add enable_hist/disable_hist triggers Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 16/23] tracing: Add 'hist' trigger Documentation Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 17/23] tracing: Add support for multiple hist triggers per event Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 18/23] tracing: Add support for named triggers Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 19/23] tracing: Add support for named hist triggers Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 20/23] kselftests/ftrace : Add event trigger testcases Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 21/23] kselftests/ftrace: Add hist " Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 22/23] tracing: Add hist trigger 'log2' modifier Tom Zanussi
2016-02-26 16:01 ` [PATCH v15 23/23] kselftests/ftrace: Add a test for log2 modifier of hist trigger Tom Zanussi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d3f7d29e9379d637ea2eca1433a429a140d7314e.1456501855.git.tom.zanussi@linux.intel.com \
    --to=tom.zanussi@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).