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:23:58
Last Modify:2022-05-22 20:19:57 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:Without going into a formal proof, this explains the method that is used in* parsing the logical expressions

Proto:static struct prog_entry *predicate_parse(const char *str, int nr_parens, int nr_preds, parse_pred_fn parse_pred, void *data, struct filter_parse_error *pe)

Type:struct prog_entry

Parameter:

TypeParameterName
const char *str
intnr_parens
intnr_preds
parse_pred_fnparse_pred
void *data
struct filter_parse_error *pe
416  ptr = str
417  char * inverts = NULL
420  invert = 0
421  ret = -ENOMEM
423  N = 0
426  nr_preds += 2
428  op_stack = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
429  If Not op_stack Then Return ERR_PTR( - ENOMEM)
431  prog_stack = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
432  If Not prog_stack Then
433  parse_error(pe, - ENOMEM, 0)
434  Go to out_free
436  inverts = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
437  If Not inverts Then
438  parse_error(pe, - ENOMEM, 0)
439  Go to out_free
442  top = op_stack
443  prog = prog_stack
444  top = 0
447  When ptr cycle
448  next = ptr++
450  If Note: isspace() must return false for %NUL-terminator ( * next) Then Continue
454  Case next == '('
455  If top - op_stack > nr_parens Then
456  ret = -EINVAL
457  Go to out_free
459  *++top = invert
460  Continue
461  Case next == '!'
464  invert = Not invert
465  Continue
468  If N >= nr_preds Then
470  Go to out_free
473  inverts[N] = invert
474  target = N - 1
476  len = parse_pred(next, data, ptr - str, pe, & pred)
477  If len < 0 Then
478  ret = len
479  Go to out_free
481  ptr = next + len
483  N++
485  ret = -1
486  When 1 cycle
487  next = ptr++
492  Case next == ')'
493  Case next == '\0'
494  Break
495  Case next == '&'
496  Case next == '|'
498  If next[1] == next[0] Then
499  ptr++
500  Break
503  Default
509  invert = top & INVERT
511  If top & PROCESS_AND Then
515  If next == '&' Then
516  top |= PROCESS_AND
517  Break
519  If top & PROCESS_OR Then
523  If next == '|' Then
524  top |= PROCESS_OR
525  Break
527  If Not next Then Go to out
530  If top == op_stack Then
531  ret = -1
534  Go to out_free
536  top--
539  out :
540  If top != op_stack Then
542  parse_error(pe, FILT_ERR_TOO_MANY_OPEN, ptr - str)
543  Go to out_free
546  If Not N Then
548  ret = -EINVAL
549  parse_error(pe, FILT_ERR_NO_FILTER, ptr - str)
550  Go to out_free
553  pred = NULL
554  target = 1
555  pred = NULL
556  target = 0
557  target = N
558  when_to_branch = false
561  When i-- cycle
562  target = target
563  If when_to_branch == when_to_branch Then target = target
568  When i < N cycle
569  invert = inverts[i] ^ when_to_branch
570  when_to_branch = invert
572  If WARN_ON(target <= i) Then
573  ret = -EINVAL
574  Go to out_free
578  kfree(op_stack)
579  kfree(inverts)
580  Return prog
581  out_free :
582  kfree(op_stack)
583  kfree(inverts)
584  If prog_stack Then
585  When pred cycle kfree(pred)
587  kfree(prog_stack)
589  Return ERR_PTR(ret)
Caller
NameDescribe
process_preds