@@ -61,8 +61,29 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent)
61
61
62
62
const char PRINT_TYPE_FMT_NAME (string )[] = "\\\"%s\\\"" ;
63
63
64
- static const struct fetch_type * find_fetch_type (const char * type ,
65
- const struct fetch_type * ftbl )
64
+ /* Fetch type information table */
65
+ static const struct fetch_type probe_fetch_types [] = {
66
+ /* Special types */
67
+ __ASSIGN_FETCH_TYPE ("string" , string , string , sizeof (u32 ), 1 ,
68
+ "__data_loc char[]" ),
69
+ /* Basic types */
70
+ ASSIGN_FETCH_TYPE (u8 , u8 , 0 ),
71
+ ASSIGN_FETCH_TYPE (u16 , u16 , 0 ),
72
+ ASSIGN_FETCH_TYPE (u32 , u32 , 0 ),
73
+ ASSIGN_FETCH_TYPE (u64 , u64 , 0 ),
74
+ ASSIGN_FETCH_TYPE (s8 , u8 , 1 ),
75
+ ASSIGN_FETCH_TYPE (s16 , u16 , 1 ),
76
+ ASSIGN_FETCH_TYPE (s32 , u32 , 1 ),
77
+ ASSIGN_FETCH_TYPE (s64 , u64 , 1 ),
78
+ ASSIGN_FETCH_TYPE_ALIAS (x8 , u8 , u8 , 0 ),
79
+ ASSIGN_FETCH_TYPE_ALIAS (x16 , u16 , u16 , 0 ),
80
+ ASSIGN_FETCH_TYPE_ALIAS (x32 , u32 , u32 , 0 ),
81
+ ASSIGN_FETCH_TYPE_ALIAS (x64 , u64 , u64 , 0 ),
82
+
83
+ ASSIGN_FETCH_TYPE_END
84
+ };
85
+
86
+ static const struct fetch_type * find_fetch_type (const char * type )
66
87
{
67
88
int i ;
68
89
@@ -83,21 +104,21 @@ static const struct fetch_type *find_fetch_type(const char *type,
83
104
84
105
switch (bs ) {
85
106
case 8 :
86
- return find_fetch_type ("u8" , ftbl );
107
+ return find_fetch_type ("u8" );
87
108
case 16 :
88
- return find_fetch_type ("u16" , ftbl );
109
+ return find_fetch_type ("u16" );
89
110
case 32 :
90
- return find_fetch_type ("u32" , ftbl );
111
+ return find_fetch_type ("u32" );
91
112
case 64 :
92
- return find_fetch_type ("u64" , ftbl );
113
+ return find_fetch_type ("u64" );
93
114
default :
94
115
goto fail ;
95
116
}
96
117
}
97
118
98
- for (i = 0 ; ftbl [i ].name ; i ++ ) {
99
- if (strcmp (type , ftbl [i ].name ) == 0 )
100
- return & ftbl [i ];
119
+ for (i = 0 ; probe_fetch_types [i ].name ; i ++ ) {
120
+ if (strcmp (type , probe_fetch_types [i ].name ) == 0 )
121
+ return & probe_fetch_types [i ];
101
122
}
102
123
103
124
fail :
@@ -164,8 +185,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
164
185
static int
165
186
parse_probe_arg (char * arg , const struct fetch_type * type ,
166
187
struct fetch_insn * * pcode , struct fetch_insn * end ,
167
- bool is_return , bool is_kprobe ,
168
- const struct fetch_type * ftbl )
188
+ bool is_return , bool is_kprobe )
169
189
{
170
190
struct fetch_insn * code = * pcode ;
171
191
unsigned long param ;
@@ -247,12 +267,11 @@ parse_probe_arg(char *arg, const struct fetch_type *type,
247
267
tmp = strrchr (arg , ')' );
248
268
249
269
if (tmp ) {
250
- const struct fetch_type * t2 ;
270
+ const struct fetch_type * t2 = find_fetch_type ( NULL ) ;
251
271
252
- t2 = find_fetch_type (NULL , ftbl );
253
272
* tmp = '\0' ;
254
273
ret = parse_probe_arg (arg , t2 , & code , end , is_return ,
255
- is_kprobe , ftbl );
274
+ is_kprobe );
256
275
if (ret )
257
276
break ;
258
277
if (code -> op == FETCH_OP_COMM )
@@ -312,8 +331,7 @@ static int __parse_bitfield_probe_arg(const char *bf,
312
331
313
332
/* String length checking wrapper */
314
333
int traceprobe_parse_probe_arg (char * arg , ssize_t * size ,
315
- struct probe_arg * parg , bool is_return , bool is_kprobe ,
316
- const struct fetch_type * ftbl )
334
+ struct probe_arg * parg , bool is_return , bool is_kprobe )
317
335
{
318
336
struct fetch_insn * code , * tmp = NULL ;
319
337
const char * t ;
@@ -339,7 +357,7 @@ int traceprobe_parse_probe_arg(char *arg, ssize_t *size,
339
357
*/
340
358
if (!t && strcmp (arg , "$comm" ) == 0 )
341
359
t = "string" ;
342
- parg -> type = find_fetch_type (t , ftbl );
360
+ parg -> type = find_fetch_type (t );
343
361
if (!parg -> type ) {
344
362
pr_info ("Unsupported type: %s\n" , t );
345
363
return - EINVAL ;
@@ -353,7 +371,7 @@ int traceprobe_parse_probe_arg(char *arg, ssize_t *size,
353
371
code [FETCH_INSN_MAX - 1 ].op = FETCH_OP_END ;
354
372
355
373
ret = parse_probe_arg (arg , parg -> type , & code , & code [FETCH_INSN_MAX - 1 ],
356
- is_return , is_kprobe , ftbl );
374
+ is_return , is_kprobe );
357
375
if (ret )
358
376
goto fail ;
359
377
0 commit comments