Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\trace_events_filter.c Create Date:2022-07-28 12:25:10
Last Modify:2022-05-22 20:19:57 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Called when a predicate is encountered by predicate_parse()

Proto:static int parse_pred(const char *str, void *data, int pos, struct filter_parse_error *pe, struct filter_pred **pred_ptr)

Type:int

Parameter:

TypeParameterName
const char *str
void *data
intpos
struct filter_parse_error *pe
struct filter_pred **pred_ptr
1156  call = data
1158  struct filter_pred * pred = NULL
1167  i = 0
1170  When Note: isspace() must return false for %NUL-terminator (str[i]) cycle
1171  i++
1172  s = i
1174  When isalnum(str[i]) || str[i] == '_' cycle
1175  i++
1177  len = i - s
1179  If Not len Then Return -1
1182  field_name = kmemdup_nul(str + s, len, GFP_KERNEL)
1183  If Not field_name Then Return -ENOMEM
1188  field = trace_find_event_field(call, field_name)
1189  kfree(field_name)
1190  If Not field Then
1191  parse_error(pe, FILT_ERR_FIELD_NOT_FOUND, pos + i)
1192  Return -EINVAL
1195  When Note: isspace() must return false for %NUL-terminator (str[i]) cycle
1196  i++
1199  When ops[op] cycle
1201  If strncmp(str + i, ops[op], strlen - Find the length of a string*@s: The string to be sized) == 0 Then Break
1205  If Not ops[op] Then
1206  parse_error(pe, FILT_ERR_INVALID_OP, pos + i)
1207  Go to err_free
1210  i += strlen - Find the length of a string*@s: The string to be sized
1212  When Note: isspace() must return false for %NUL-terminator (str[i]) cycle
1213  i++
1215  s = i
1217  pred = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
1218  If Not pred Then Return -ENOMEM
1221  field = field
1222  offset = offset
1223  op = op
1225  If ftrace_event_is_function(call) Then
1233  If strcmp(name, "ip") != 0 Then
1235  Go to err_free
1237  fn = filter_pred_none
1243  If str[i] == '\'' || str[i] == '"' Then q = str[i]
1245  Else q = 0
1248  When str[i] cycle
1249  If q && str[i] == q Then Break
1251  If Not q && ( str[i] == ')' || str[i] == '&' || str[i] == '|' ) Then Break
1256  If q Then s++
1258  len = i - s
1261  Go to err_free
1264  len = len
1265  strncpy(pattern, str + s, len)
1266  pattern[len] = 0
1269  Else if str[i] == '\'' || str[i] == '"' Then
1270  q = str[i]
1274  Case op == OP_NE
1275  not = 1
1277  Case op == OP_GLOB
1278  Case op == OP_EQ
1279  Break
1280  Default
1282  Go to err_free
1286  If Not is_string_field(field) Then
1288  Go to err_free
1291  When str[i] cycle
1292  If str[i] == q Then Break
1295  If Not str[i] Then
1297  Go to err_free
1301  s++
1302  len = i - s
1305  Go to err_free
1308  len = len
1309  strncpy(pattern, str + s, len)
1310  pattern[len] = 0
1312  filter_build_regex(pred)
1314  If filter_type == FILTER_COMM Then
1317  Else if filter_type == FILTER_STATIC_STRING Then
1319  field_len = size
1321  Else if filter_type == FILTER_DYN_STRING Then fn = Filter predicate for dynamic sized arrays of characters
1323  Else fn = Filter predicate for char * pointers
1326  i++
1328  Else if isdigit(str[i]) || str[i] == '-' Then
1331  If is_string_field(field) Then
1333  Go to err_free
1336  If op == OP_GLOB Then
1338  Go to err_free
1341  If str[i] == '-' Then i++
1345  When isalnum(str[i]) cycle
1346  i++
1348  len = i - s
1350  If len >= size of num_buf Then
1352  Go to err_free
1355  strncpy(num_buf, str + s, len)
1356  num_buf[len] = 0
1359  If is_signed Then ret = kstrtoll - convert a string to a long long*@s: The start of the string. The string must be null-terminated, and may also* include a single newline before its terminating null. The first character* may also be a plus sign or a minus sign.
1361  Else ret = kstrtoull - convert a string to an unsigned long long*@s: The start of the string. The string must be null-terminated, and may also* include a single newline before its terminating null. The first character* may also be a plus sign, but not a minus sign.
1363  If ret Then
1365  Go to err_free
1368  val = val
1370  If filter_type == FILTER_CPU Then fn = Filter predicate for CPUs.
1372  Else
1375  If op == OP_NE Then not = 1
1379  Else
1380  parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i)
1381  Go to err_free
1384  pred_ptr = pred
1385  Return i
1387  err_free :
1388  kfree(pred)
1389  Return -EINVAL