From: mhiramat at kernel.org (Masami Hiramatsu) Subject: [PATCH v7 09/16] tracing: probeevent: Add symbol type Date: Wed, 25 Apr 2018 21:20:28 +0900 [thread overview] Message-ID: <152465882860.26224.14779072294412467338.stgit@devbox> (raw) In-Reply-To: <152465856498.26224.16969986455942749517.stgit@devbox> Add "symbol" type to probeevent, which is an alias of u32 or u64 (depends on BITS_PER_LONG). This shows the result value in symbol+offset style. This type is only available with kprobe events. Signed-off-by: Masami Hiramatsu <mhiramat at kernel.org> --- Changes in v2: - Add symbol type to README file. --- Documentation/trace/kprobetrace.rst | 2 ++ kernel/trace/trace.c | 2 +- kernel/trace/trace_probe.c | 8 ++++++++ kernel/trace/trace_probe.h | 12 +++++++++--- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kprobetrace.rst index 3e0f971b12de..c920c9be221a 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -72,6 +72,8 @@ offset, and container-size (usually 32). The syntax is:: b<bit-width>@<bit-offset>/<container-size> +Symbol type('symbol') is an alias of u32 or u64 type (depends on BITS_PER_LONG) +which shows given pointer in "symbol+offset" style. For $comm, the default type is "string"; any other type is invalid. diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index dfbcf9ee1447..4812ae046f43 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4621,7 +4621,7 @@ static const char readme_msg[] = "\t args: <name>=fetcharg[:type]\n" "\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n" "\t $stack<index>, $stack, $retval, $comm\n" - "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n" + "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n" "\t b<bit-width>@<bit-offset>/<container-size>\n" #endif " events/\t\t- Directory containing all trace event subsystems:\n" diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index fff3ccfcdbb6..e2a31087f1f8 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -58,6 +58,13 @@ DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x") DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x") DEFINE_BASIC_PRINT_TYPE_FUNC(x64, u64, "0x%Lx") +int PRINT_TYPE_FUNC_NAME(symbol)(struct trace_seq *s, void *data, void *ent) +{ + trace_seq_printf(s, "%pS", (void *)*(unsigned long *)data); + return !trace_seq_has_overflowed(s); +} +const char PRINT_TYPE_FMT_NAME(symbol)[] = "%pS"; + /* Print type function for string type */ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent) { @@ -91,6 +98,7 @@ static const struct fetch_type probe_fetch_types[] = { ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0), ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0), ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0), + ASSIGN_FETCH_TYPE_ALIAS(symbol, ADDR_FETCH_TYPE, ADDR_FETCH_TYPE, 0), ASSIGN_FETCH_TYPE_END }; diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 3bc43c1ce628..ef477bd8468a 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -157,6 +157,7 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(x32); DECLARE_BASIC_PRINT_TYPE_FUNC(x64); DECLARE_BASIC_PRINT_TYPE_FUNC(string); +DECLARE_BASIC_PRINT_TYPE_FUNC(symbol); /* Default (unsigned long) fetch type */ #define __DEFAULT_FETCH_TYPE(t) x##t @@ -164,6 +165,10 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(string); #define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG) #define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE) +#define __ADDR_FETCH_TYPE(t) u##t +#define _ADDR_FETCH_TYPE(t) __ADDR_FETCH_TYPE(t) +#define ADDR_FETCH_TYPE _ADDR_FETCH_TYPE(BITS_PER_LONG) + #define __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \ {.name = _name, \ .size = _size, \ @@ -172,13 +177,14 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(string); .fmt = PRINT_TYPE_FMT_NAME(ptype), \ .fmttype = _fmttype, \ } - +#define _ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \ + __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, #_fmttype) #define ASSIGN_FETCH_TYPE(ptype, ftype, sign) \ - __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype) + _ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, ptype) /* If ptype is an alias of atype, use this macro (show atype in format) */ #define ASSIGN_FETCH_TYPE_ALIAS(ptype, atype, ftype, sign) \ - __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #atype) + _ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, atype) #define ASSIGN_FETCH_TYPE_END {} -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: mhiramat@kernel.org (Masami Hiramatsu) Subject: [PATCH v7 09/16] tracing: probeevent: Add symbol type Date: Wed, 25 Apr 2018 21:20:28 +0900 [thread overview] Message-ID: <152465882860.26224.14779072294412467338.stgit@devbox> (raw) Message-ID: <20180425122028.SZVUOsT758AY1qQ9UrnlxVvRTKceTfUzfASk0uS5qAo@z> (raw) In-Reply-To: <152465856498.26224.16969986455942749517.stgit@devbox> Add "symbol" type to probeevent, which is an alias of u32 or u64 (depends on BITS_PER_LONG). This shows the result value in symbol+offset style. This type is only available with kprobe events. Signed-off-by: Masami Hiramatsu <mhiramat at kernel.org> --- Changes in v2: - Add symbol type to README file. --- Documentation/trace/kprobetrace.rst | 2 ++ kernel/trace/trace.c | 2 +- kernel/trace/trace_probe.c | 8 ++++++++ kernel/trace/trace_probe.h | 12 +++++++++--- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kprobetrace.rst index 3e0f971b12de..c920c9be221a 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -72,6 +72,8 @@ offset, and container-size (usually 32). The syntax is:: b<bit-width>@<bit-offset>/<container-size> +Symbol type('symbol') is an alias of u32 or u64 type (depends on BITS_PER_LONG) +which shows given pointer in "symbol+offset" style. For $comm, the default type is "string"; any other type is invalid. diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index dfbcf9ee1447..4812ae046f43 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4621,7 +4621,7 @@ static const char readme_msg[] = "\t args: <name>=fetcharg[:type]\n" "\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n" "\t $stack<index>, $stack, $retval, $comm\n" - "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n" + "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n" "\t b<bit-width>@<bit-offset>/<container-size>\n" #endif " events/\t\t- Directory containing all trace event subsystems:\n" diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index fff3ccfcdbb6..e2a31087f1f8 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -58,6 +58,13 @@ DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x") DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x") DEFINE_BASIC_PRINT_TYPE_FUNC(x64, u64, "0x%Lx") +int PRINT_TYPE_FUNC_NAME(symbol)(struct trace_seq *s, void *data, void *ent) +{ + trace_seq_printf(s, "%pS", (void *)*(unsigned long *)data); + return !trace_seq_has_overflowed(s); +} +const char PRINT_TYPE_FMT_NAME(symbol)[] = "%pS"; + /* Print type function for string type */ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent) { @@ -91,6 +98,7 @@ static const struct fetch_type probe_fetch_types[] = { ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0), ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0), ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0), + ASSIGN_FETCH_TYPE_ALIAS(symbol, ADDR_FETCH_TYPE, ADDR_FETCH_TYPE, 0), ASSIGN_FETCH_TYPE_END }; diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 3bc43c1ce628..ef477bd8468a 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -157,6 +157,7 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(x32); DECLARE_BASIC_PRINT_TYPE_FUNC(x64); DECLARE_BASIC_PRINT_TYPE_FUNC(string); +DECLARE_BASIC_PRINT_TYPE_FUNC(symbol); /* Default (unsigned long) fetch type */ #define __DEFAULT_FETCH_TYPE(t) x##t @@ -164,6 +165,10 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(string); #define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG) #define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE) +#define __ADDR_FETCH_TYPE(t) u##t +#define _ADDR_FETCH_TYPE(t) __ADDR_FETCH_TYPE(t) +#define ADDR_FETCH_TYPE _ADDR_FETCH_TYPE(BITS_PER_LONG) + #define __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \ {.name = _name, \ .size = _size, \ @@ -172,13 +177,14 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(string); .fmt = PRINT_TYPE_FMT_NAME(ptype), \ .fmttype = _fmttype, \ } - +#define _ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \ + __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, #_fmttype) #define ASSIGN_FETCH_TYPE(ptype, ftype, sign) \ - __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype) + _ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, ptype) /* If ptype is an alias of atype, use this macro (show atype in format) */ #define ASSIGN_FETCH_TYPE_ALIAS(ptype, atype, ftype, sign) \ - __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #atype) + _ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, atype) #define ASSIGN_FETCH_TYPE_END {} -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-04-25 12:20 UTC|newest] Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-04-25 12:16 [PATCH v7 00/16] tracing: probeevent: Improve fetcharg features mhiramat 2018-04-25 12:16 ` Masami Hiramatsu 2018-04-25 12:16 ` [PATCH v7 01/16] tracing: probeevent: Cleanup print argument functions mhiramat 2018-04-25 12:16 ` Masami Hiramatsu 2018-04-25 12:17 ` [PATCH v7 02/16] tracing: probeevent: Cleanup argument field definition mhiramat 2018-04-25 12:17 ` Masami Hiramatsu 2018-04-25 12:17 ` [PATCH v7 03/16] tracing: probeevent: Remove NOKPROBE_SYMBOL from print functions mhiramat 2018-04-25 12:17 ` Masami Hiramatsu 2018-04-25 12:18 ` [PATCH v7 04/16] tracing: probeevent: Introduce new argument fetching code mhiramat 2018-04-25 12:18 ` Masami Hiramatsu 2018-04-25 12:18 ` [PATCH v7 05/16] tracing: probeevent: Unify fetch type tables mhiramat 2018-04-25 12:18 ` Masami Hiramatsu 2018-04-25 12:19 ` [PATCH v7 06/16] tracing: probeevent: Return consumed bytes of dynamic area mhiramat 2018-04-25 12:19 ` Masami Hiramatsu 2018-04-25 12:19 ` [PATCH v7 07/16] tracing: probeevent: Append traceprobe_ for exported function mhiramat 2018-04-25 12:19 ` Masami Hiramatsu 2018-04-25 12:19 ` [PATCH v7 08/16] tracing: probeevent: Unify fetch_insn processing common part mhiramat 2018-04-25 12:19 ` Masami Hiramatsu 2018-04-25 12:20 ` mhiramat [this message] 2018-04-25 12:20 ` [PATCH v7 09/16] tracing: probeevent: Add symbol type Masami Hiramatsu 2018-04-25 12:20 ` [PATCH v7 10/16] x86: ptrace: Add function argument access API mhiramat 2018-04-25 12:20 ` Masami Hiramatsu 2018-04-25 12:21 ` [PATCH v7 11/16] tracing: probeevent: Add $argN for accessing function args mhiramat 2018-04-25 12:21 ` Masami Hiramatsu 2018-04-25 12:21 ` [PATCH v7 12/16] tracing: probeevent: Add array type support mhiramat 2018-04-25 12:21 ` Masami Hiramatsu 2018-04-25 12:22 ` [PATCH v7 13/16] selftests: ftrace: Add a testcase for symbol type mhiramat 2018-04-25 12:22 ` Masami Hiramatsu 2018-04-25 12:22 ` [PATCH v7 14/16] selftests: ftrace: Add a testcase for $argN with kprobe_event mhiramat 2018-04-25 12:22 ` Masami Hiramatsu 2018-04-25 12:23 ` [PATCH v7 15/16] selftests: ftrace: Add a testcase for array type " mhiramat 2018-04-25 12:23 ` Masami Hiramatsu 2018-04-25 12:23 ` [PATCH v7 16/16] perf-probe: Add array argument support mhiramat 2018-04-25 12:23 ` Masami Hiramatsu 2018-04-27 1:42 ` [PATCH v7 00/16] tracing: probeevent: Improve fetcharg features rostedt 2018-04-27 1:42 ` Steven Rostedt 2018-05-03 22:11 ` rostedt 2018-05-03 22:11 ` Steven Rostedt 2018-05-04 15:48 ` mhiramat 2018-05-04 15:48 ` Masami Hiramatsu 2018-05-04 16:06 ` rostedt 2018-05-04 16:06 ` Steven Rostedt 2018-05-04 17:30 ` naveen.n.rao 2018-05-04 17:30 ` Naveen N. Rao 2018-05-05 2:38 ` mhiramat 2018-05-05 2:38 ` Masami Hiramatsu 2018-05-05 7:46 ` naveen.n.rao 2018-05-05 7:46 ` Naveen N. Rao 2018-05-05 14:32 ` mhiramat 2018-05-05 14:32 ` Masami Hiramatsu 2018-05-07 8:11 ` naveen.n.rao 2018-05-07 8:11 ` Naveen N. Rao 2018-05-07 14:53 ` mhiramat 2018-05-07 14:53 ` Masami Hiramatsu 2018-05-08 10:11 ` naveen.n.rao 2018-05-08 10:11 ` Naveen N. Rao 2018-05-08 15:02 ` mhiramat 2018-05-08 15:02 ` Masami Hiramatsu 2018-05-08 18:01 ` naveen.n.rao 2018-05-08 18:01 ` Naveen N. Rao 2018-05-05 15:51 ` mhiramat 2018-05-05 15:51 ` Masami Hiramatsu 2018-05-07 15:30 ` rostedt 2018-05-07 15:30 ` Steven Rostedt 2018-05-08 4:01 ` mhiramat 2018-05-08 4:01 ` Masami Hiramatsu 2018-05-07 15:21 ` rostedt 2018-05-07 15:21 ` Steven Rostedt 2018-06-21 20:16 ` rostedt 2018-06-21 20:16 ` Steven Rostedt 2018-06-22 6:04 ` mhiramat 2018-06-22 6:04 ` Masami Hiramatsu
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=152465882860.26224.14779072294412467338.stgit@devbox \ --to=linux-kselftest@vger.kernel.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: linkBe 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).