Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932349AbbGPRXz (ORCPT ); Thu, 16 Jul 2015 13:23:55 -0400 Received: from mga01.intel.com ([192.55.52.88]:43144 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932178AbbGPRXx (ORCPT ); Thu, 16 Jul 2015 13:23:53 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,488,1432623600"; d="scan'208";a="607541464" From: Tom Zanussi To: rostedt@goodmis.org Cc: daniel.wagner@bmw-carit.de, masami.hiramatsu.pt@hitachi.com, namhyung@kernel.org, josh@joshtriplett.org, andi@firstfloor.org, linux-kernel@vger.kernel.org, Tom Zanussi Subject: [PATCH v9 15/22] tracing: Add hist trigger 'sym' and 'sym-offset' modifiers Date: Thu, 16 Jul 2015 12:22:48 -0500 Message-Id: <4a74cc640bde7beb1389ad412458ed14ca520172.1437066836.git.tom.zanussi@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3461 Lines: 93 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 --- kernel/trace/trace.c | 2 ++ kernel/trace/trace_events_hist.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 14f9472..8cdc7b3 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3814,6 +3814,8 @@ static const char readme_msg[] = "\t integers. This can be modified by appending any of the\n" "\t following modifiers to the field name:\n\n" "\t .hex display a number as a hex value\n\n" + "\t .sym display an address as a symbol\n" + "\t .sym-offset display an address as a symbol and offset\n" "\t By default, the size of the hash table is 2048 entries. The\n" "\t 'size' param can be used to specify more or fewer than that.\n" "\t The units are in terms of hashtable entries - if a run uses\n" diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 9cc38ee..106d557 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -73,6 +73,8 @@ enum hist_field_flags { HIST_FIELD_KEY = 2, HIST_FIELD_STRING = 4, HIST_FIELD_HEX = 8, + HIST_FIELD_SYM = 16, + HIST_FIELD_SYM_OFFSET = 32, }; struct hist_trigger_attrs { @@ -370,6 +372,10 @@ static int create_key_field(struct hist_trigger_data *hist_data, if (field_str) { if (!strcmp(field_str, "hex")) flags |= HIST_FIELD_HEX; + else if (!strcmp(field_str, "sym")) + flags |= HIST_FIELD_SYM; + else if (!strcmp(field_str, "sym-offset")) + flags |= HIST_FIELD_SYM_OFFSET; else { ret = -EINVAL; goto out; @@ -700,6 +706,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; @@ -715,6 +722,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_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_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_STRING) { seq_printf(m, "%s: %-35s", key_field->field->name, (char *)(key + key_field->offset)); @@ -824,6 +841,10 @@ static const char *get_hist_field_flags(struct hist_field *hist_field) if (hist_field->flags & HIST_FIELD_HEX) flags_str = "hex"; + else if (hist_field->flags & HIST_FIELD_SYM) + flags_str = "sym"; + else if (hist_field->flags & HIST_FIELD_SYM_OFFSET) + flags_str = "sym-offset"; return flags_str; } -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/