Skip to content

Commit 60c2e0c

Browse files
mhiramatrostedt
authored andcommitted
tracing: probeevent: Add symbol type
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. Link: http://lkml.kernel.org/r/152465882860.26224.14779072294412467338.stgit@devbox Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 9b960a3 commit 60c2e0c

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎Documentation/trace/kprobetrace.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ offset, and container-size (usually 32). The syntax is::
7272

7373
b<bit-width>@<bit-offset>/<container-size>
7474

75+
Symbol type('symbol') is an alias of u32 or u64 type (depends on BITS_PER_LONG)
76+
which shows given pointer in "symbol+offset" style.
7577
For $comm, the default type is "string"; any other type is invalid.
7678

7779

‎kernel/trace/trace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4626,7 +4626,7 @@ static const char readme_msg[] =
46264626
"\t args: <name>=fetcharg[:type]\n"
46274627
"\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n"
46284628
"\t $stack<index>, $stack, $retval, $comm\n"
4629-
"\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n"
4629+
"\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n"
46304630
"\t b<bit-width>@<bit-offset>/<container-size>\n"
46314631
#endif
46324632
" events/\t\t- Directory containing all trace event subsystems:\n"

‎kernel/trace/trace_probe.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ DEFINE_BASIC_PRINT_TYPE_FUNC(x16, u16, "0x%x")
4646
DEFINE_BASIC_PRINT_TYPE_FUNC(x32, u32, "0x%x")
4747
DEFINE_BASIC_PRINT_TYPE_FUNC(x64, u64, "0x%Lx")
4848

49+
int PRINT_TYPE_FUNC_NAME(symbol)(struct trace_seq *s, void *data, void *ent)
50+
{
51+
trace_seq_printf(s, "%pS", (void *)*(unsigned long *)data);
52+
return !trace_seq_has_overflowed(s);
53+
}
54+
const char PRINT_TYPE_FMT_NAME(symbol)[] = "%pS";
55+
4956
/* Print type function for string type */
5057
int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent)
5158
{
@@ -79,6 +86,7 @@ static const struct fetch_type probe_fetch_types[] = {
7986
ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
8087
ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
8188
ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
89+
ASSIGN_FETCH_TYPE_ALIAS(symbol, ADDR_FETCH_TYPE, ADDR_FETCH_TYPE, 0),
8290

8391
ASSIGN_FETCH_TYPE_END
8492
};

‎kernel/trace/trace_probe.h‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,18 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(x32);
145145
DECLARE_BASIC_PRINT_TYPE_FUNC(x64);
146146

147147
DECLARE_BASIC_PRINT_TYPE_FUNC(string);
148+
DECLARE_BASIC_PRINT_TYPE_FUNC(symbol);
148149

149150
/* Default (unsigned long) fetch type */
150151
#define __DEFAULT_FETCH_TYPE(t) x##t
151152
#define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
152153
#define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)
153154
#define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)
154155

156+
#define __ADDR_FETCH_TYPE(t) u##t
157+
#define _ADDR_FETCH_TYPE(t) __ADDR_FETCH_TYPE(t)
158+
#define ADDR_FETCH_TYPE _ADDR_FETCH_TYPE(BITS_PER_LONG)
159+
155160
#define __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \
156161
{.name = _name, \
157162
.size = _size, \
@@ -160,13 +165,14 @@ DECLARE_BASIC_PRINT_TYPE_FUNC(string);
160165
.fmt = PRINT_TYPE_FMT_NAME(ptype), \
161166
.fmttype = _fmttype, \
162167
}
163-
168+
#define _ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype) \
169+
__ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, #_fmttype)
164170
#define ASSIGN_FETCH_TYPE(ptype, ftype, sign) \
165-
__ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype)
171+
_ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, ptype)
166172

167173
/* If ptype is an alias of atype, use this macro (show atype in format) */
168174
#define ASSIGN_FETCH_TYPE_ALIAS(ptype, atype, ftype, sign) \
169-
__ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #atype)
175+
_ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, atype)
170176

171177
#define ASSIGN_FETCH_TYPE_END {}
172178

0 commit comments

Comments
 (0)