Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\trace_uprobe.c Create Date:2022-07-28 12:44:23
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:trace_uprobe_create

Proto:static int trace_uprobe_create(int argc, const char **argv)

Type:int

Parameter:

TypeParameterName
intargc
const char **argv
536  event = NULL , group = UPROBE_EVENT_SYSTEM
541  bool is_return = false
544  ret = 0
545  ref_ctr_offset = 0
548  Case argv[0][0] == 'r'
549  is_return = true
550  Break
551  Case argv[0][0] == 'p'
552  Break
553  Default
554  Return -ECANCELED
557  If argc < 2 Then Return -ECANCELED
560  If argv[0][1] == ':' Then event = argv[0][2]
563  If Not strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for Then Return -ECANCELED
566  filename = kstrdup(argv[1], GFP_KERNEL)
567  If Not filename Then Return -ENOMEM
571  arg = strrchr - Find the last occurrence of a character in a string*@s: The string to be searched*@c: The character to search for
572  If Not arg || Not isdigit(arg[1]) Then
573  kfree(filename)
574  Return -ECANCELED
577  trace_probe_log_init("trace_uprobe", argc, argv)
578  trace_probe_log_set_index(1)
580  arg++ = '\0'
581  ret = kern_path(filename, llow links at the end , & path)
582  If ret Then
583  trace_probe_log_err(0, FILE_NOT_FOUND)
584  kfree(filename)
585  trace_probe_log_clear()
586  Return ret
588  If Not d_is_reg(dentry) Then
589  trace_probe_log_err(0, NO_REGULAR_FILE)
590  ret = -EINVAL
591  Go to fail_address_parse
595  rctr = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
596  If rctr Then
597  rctr_end = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
598  If Not rctr_end Then
599  ret = -EINVAL
603  Go to fail_address_parse
604  Else if rctr_end[1] != '\0' Then
605  ret = -EINVAL
608  Go to fail_address_parse
611  rctr++ = '\0'
612  rctr_end = '\0'
613  ret = kstrtoul - convert a string to an unsigned 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.
614  If ret Then
616  Go to fail_address_parse
621  ret = kstrtoul - convert a string to an unsigned 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.
622  If ret Then
623  trace_probe_log_err(arg - filename, BAD_UPROBE_OFFS)
624  Go to fail_address_parse
628  trace_probe_log_set_index(0)
629  If event Then
630  ret = @buf must has MAX_EVENT_NAME_LEN size
632  If ret Then Go to fail_address_parse
634  Else
638  tail = kstrdup(kbasename - return the last part of a pathname.*@path: path to extract the filename from., GFP_KERNEL)
639  If Not tail Then
640  ret = -ENOMEM
641  Go to fail_address_parse
644  ptr = strpbrk - Find the first occurrence of a set of characters*@cs: The string to be searched*@ct: The characters to search for
645  If ptr Then ptr = '\0'
648  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
649  event = buf
650  kfree(tail)
653  argc -= 2
654  argv += 2
656  tu = Allocate new trace_uprobe and initialize it (including uprobes).
657  If IS_ERR(tu) Then
658  ret = PTR_ERR(tu)
660  WARN_ON_ONCE(ret != - ENOMEM)
661  Go to fail_address_parse
663  offset = offset
664  ref_ctr_offset = ref_ctr_offset
665  path = path
666  filename = filename
669  When i < argc && i < MAX_TRACE_ARGS cycle
670  tmp = kstrdup(argv[i], GFP_KERNEL)
671  If Not tmp Then
672  ret = -ENOMEM
673  Go to error
676  trace_probe_log_set_index(i + 2)
677  ret = traceprobe_parse_probe_arg( & tp, i, tmp, is_return ? TPARG_FL_RETURN : 0)
679  kfree(tmp)
680  If ret Then Go to error
684  ret = traceprobe_set_print_fmt( & tp, is_ret_probe(tu))
685  If ret < 0 Then Go to error
688  ret = Register a trace_uprobe and probe_event
689  If Not ret Then Go to out
692  error :
693  free_trace_uprobe(tu)
694  out :
695  trace_probe_log_clear()
696  Return ret
698  fail_address_parse :
699  trace_probe_log_clear()
700  path_put( & path)
701  kfree(filename)
703  Return ret
Caller
NameDescribe
create_or_delete_trace_uprobe