@@ -1367,6 +1367,14 @@ static int field_is_dynamic(struct tep_format_field *field)
1367
1367
return 0 ;
1368
1368
}
1369
1369
1370
+ static int field_is_relative_dynamic (struct tep_format_field * field )
1371
+ {
1372
+ if (strncmp (field -> type , "__rel_loc" , 9 ) == 0 )
1373
+ return 1 ;
1374
+
1375
+ return 0 ;
1376
+ }
1377
+
1370
1378
static int field_is_long (struct tep_format_field * field )
1371
1379
{
1372
1380
/* includes long long */
@@ -1622,6 +1630,8 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field **
1622
1630
field -> flags |= TEP_FIELD_IS_STRING ;
1623
1631
if (field_is_dynamic (field ))
1624
1632
field -> flags |= TEP_FIELD_IS_DYNAMIC ;
1633
+ if (field_is_relative_dynamic (field ))
1634
+ field -> flags |= TEP_FIELD_IS_DYNAMIC | TEP_FIELD_IS_RELATIVE ;
1625
1635
if (field_is_long (field ))
1626
1636
field -> flags |= TEP_FIELD_IS_LONG ;
1627
1637
@@ -2928,7 +2938,7 @@ process_str(struct tep_event *event __maybe_unused, struct tep_print_arg *arg,
2928
2938
2929
2939
arg -> type = TEP_PRINT_STRING ;
2930
2940
arg -> string .string = token ;
2931
- arg -> string .offset = -1 ;
2941
+ arg -> string .field = NULL ;
2932
2942
2933
2943
if (read_expected (TEP_EVENT_DELIM , ")" ) < 0 )
2934
2944
goto out_err ;
@@ -2957,7 +2967,7 @@ process_bitmask(struct tep_event *event __maybe_unused, struct tep_print_arg *ar
2957
2967
2958
2968
arg -> type = TEP_PRINT_BITMASK ;
2959
2969
arg -> bitmask .bitmask = token ;
2960
- arg -> bitmask .offset = -1 ;
2970
+ arg -> bitmask .field = NULL ;
2961
2971
2962
2972
if (read_expected (TEP_EVENT_DELIM , ")" ) < 0 )
2963
2973
goto out_err ;
@@ -3123,19 +3133,23 @@ process_function(struct tep_event *event, struct tep_print_arg *arg,
3123
3133
free_token (token );
3124
3134
return process_int_array (event , arg , tok );
3125
3135
}
3126
- if (strcmp (token , "__get_str" ) == 0 ) {
3136
+ if (strcmp (token , "__get_str" ) == 0 ||
3137
+ strcmp (token , "__get_rel_str" ) == 0 ) {
3127
3138
free_token (token );
3128
3139
return process_str (event , arg , tok );
3129
3140
}
3130
- if (strcmp (token , "__get_bitmask" ) == 0 ) {
3141
+ if (strcmp (token , "__get_bitmask" ) == 0 ||
3142
+ strcmp (token , "__get_rel_bitmask" ) == 0 ) {
3131
3143
free_token (token );
3132
3144
return process_bitmask (event , arg , tok );
3133
3145
}
3134
- if (strcmp (token , "__get_dynamic_array" ) == 0 ) {
3146
+ if (strcmp (token , "__get_dynamic_array" ) == 0 ||
3147
+ strcmp (token , "__get_rel_dynamic_array" ) == 0 ) {
3135
3148
free_token (token );
3136
3149
return process_dynamic_array (event , arg , tok );
3137
3150
}
3138
- if (strcmp (token , "__get_dynamic_array_len" ) == 0 ) {
3151
+ if (strcmp (token , "__get_dynamic_array_len" ) == 0 ||
3152
+ strcmp (token , "__get_rel_dynamic_array_len" ) == 0 ) {
3139
3153
free_token (token );
3140
3154
return process_dynamic_array_len (event , arg , tok );
3141
3155
}
@@ -4163,14 +4177,16 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
4163
4177
case TEP_PRINT_STRING : {
4164
4178
int str_offset ;
4165
4179
4166
- if (arg -> string .offset == -1 ) {
4167
- struct tep_format_field * f ;
4180
+ if (!arg -> string .field )
4181
+ arg -> string .field = tep_find_any_field (event , arg -> string .string );
4182
+ if (!arg -> string .field )
4183
+ break ;
4168
4184
4169
- f = tep_find_any_field (event , arg -> string .string );
4170
- arg -> string .offset = f -> offset ;
4171
- }
4172
- str_offset = data2host4 (tep , * (unsigned int * )(data + arg -> string .offset ));
4185
+ str_offset = data2host4 (tep ,
4186
+ * (unsigned int * )(data + arg -> string .field -> offset ));
4173
4187
str_offset &= 0xffff ;
4188
+ if (arg -> string .field -> flags & TEP_FIELD_IS_RELATIVE )
4189
+ str_offset += arg -> string .field -> offset + arg -> string .field -> size ;
4174
4190
print_str_to_seq (s , format , len_arg , ((char * )data ) + str_offset );
4175
4191
break ;
4176
4192
}
@@ -4181,15 +4197,16 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
4181
4197
int bitmask_offset ;
4182
4198
int bitmask_size ;
4183
4199
4184
- if (arg -> bitmask .offset == -1 ) {
4185
- struct tep_format_field * f ;
4186
-
4187
- f = tep_find_any_field (event , arg -> bitmask .bitmask );
4188
- arg -> bitmask .offset = f -> offset ;
4189
- }
4190
- bitmask_offset = data2host4 (tep , * (unsigned int * )(data + arg -> bitmask .offset ));
4200
+ if (!arg -> bitmask .field )
4201
+ arg -> bitmask .field = tep_find_any_field (event , arg -> bitmask .bitmask );
4202
+ if (!arg -> bitmask .field )
4203
+ break ;
4204
+ bitmask_offset = data2host4 (tep ,
4205
+ * (unsigned int * )(data + arg -> bitmask .field -> offset ));
4191
4206
bitmask_size = bitmask_offset >> 16 ;
4192
4207
bitmask_offset &= 0xffff ;
4208
+ if (arg -> bitmask .field -> flags & TEP_FIELD_IS_RELATIVE )
4209
+ bitmask_offset += arg -> bitmask .field -> offset + arg -> bitmask .field -> size ;
4193
4210
print_bitmask_to_seq (tep , s , format , len_arg ,
4194
4211
data + bitmask_offset , bitmask_size );
4195
4212
break ;
@@ -5109,6 +5126,8 @@ void tep_print_field(struct trace_seq *s, void *data,
5109
5126
offset = val ;
5110
5127
len = offset >> 16 ;
5111
5128
offset &= 0xffff ;
5129
+ if (field -> flags & TEP_FIELD_IS_RELATIVE )
5130
+ offset += field -> offset + field -> size ;
5112
5131
}
5113
5132
if (field -> flags & TEP_FIELD_IS_STRING &&
5114
5133
is_printable_array (data + offset , len )) {
@@ -6987,6 +7006,8 @@ void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event,
6987
7006
data + offset , field -> size );
6988
7007
* len = offset >> 16 ;
6989
7008
offset &= 0xffff ;
7009
+ if (field -> flags & TEP_FIELD_IS_RELATIVE )
7010
+ offset += field -> offset + field -> size ;
6990
7011
} else
6991
7012
* len = field -> size ;
6992
7013
0 commit comments