Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:trace_kprobe_create

Proto:static int trace_kprobe_create(int argc, const char *argv[])

Type:int

Parameter:

TypeParameterName
intargc
const char *argv
736  struct trace_kprobe * tk = NULL
737  ret = 0
738  bool is_return = false
739  char * symbol = NULL, * tmp = NULL
740  event = NULL , group = KPROBE_EVENT_SYSTEM
741  maxactive = 0
742  offset = 0
743  void * addr = NULL
745  flags = TPARG_FL_KERNEL
748  Case argv[0][0] == 'r'
749  is_return = true
750  flags |= TPARG_FL_RETURN
751  Break
752  Case argv[0][0] == 'p'
753  Break
754  Default
755  Return -ECANCELED
757  If argc < 2 Then Return -ECANCELED
760  trace_probe_log_init("trace_kprobe", argc, argv)
762  event = 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
763  If event Then event++
766  If isdigit(argv[0][1]) Then
767  If Not is_return Then
769  Go to parse_error
771  If event Then len = event - argv[0][1] - 1
773  Else len = strlen - Find the length of a string*@s: The string to be sized
775  If len > MAX_EVENT_NAME_LEN - 1 Then
777  Go to parse_error
779  No 3D Now!(buf, & argv[0][1], len)
780  buf[len] = '\0'
781  ret = kstrtouint - convert a string to an unsigned int*@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.
782  If ret || Not maxactive Then
784  Go to parse_error
791  Go to parse_error
797  If 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. Then
798  trace_probe_log_set_index(1)
801  ret = -ECANCELED
802  Go to error
805  symbol = kstrdup(argv[1], GFP_KERNEL)
806  If Not symbol Then Return -ENOMEM
809  ret = traceprobe_split_symbol_offset(symbol, & offset)
810  If ret || offset < 0 || offset > UINT_MAX Then
812  Go to parse_error
814  If kprobe_on_func_entry(NULL, symbol, offset) Then flags |= TPARG_FL_FENTRY
816  If offset && is_return && Not (flags & TPARG_FL_FENTRY) Then
818  Go to parse_error
822  trace_probe_log_set_index(0)
823  If event Then
824  ret = @buf must has MAX_EVENT_NAME_LEN size
826  If ret Then Go to parse_error
828  Else
830  If symbol Then 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*@
833  Else 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*@
836  Convert certain expected symbols into '_' when generating event names
837  event = buf
841  tk = Allocate new trace_probe and initialize it (including kprobes).
843  If IS_ERR(tk) Then
844  ret = PTR_ERR(tk)
846  WARN_ON_ONCE(ret != - ENOMEM)
847  Go to out
849  argc -= 2
849  argv += 2
852  When i < argc && i < MAX_TRACE_ARGS cycle
853  tmp = kstrdup(argv[i], GFP_KERNEL)
854  If Not tmp Then
855  ret = -ENOMEM
856  Go to error
859  trace_probe_log_set_index(i + 2)
860  ret = traceprobe_parse_probe_arg( & tp, i, tmp, flags)
861  kfree(tmp)
862  If ret Then Go to error
866  ret = traceprobe_set_print_fmt( & tp, is_return)
867  If ret < 0 Then Go to error
870  ret = Register a trace_probe and probe_event
871  If ret Then
872  trace_probe_log_set_index(1)
873  If ret == -EILSEQ Then trace_probe_log_err(0, BAD_INSN_BNDRY)
875  Else if ret == -ENOENT Then trace_probe_log_err(0, BAD_PROBE_ADDR)
877  Else if ret != -ENOMEM && ret != -EEXIST Then trace_probe_log_err(0, FAIL_REG_PROBE)
879  Go to error
882  out :
883  trace_probe_log_clear()
884  kfree(symbol)
885  Return ret
887  parse_error :
888  ret = -EINVAL
889  error :
890  free_trace_kprobe(tk)
891  Go to out
Caller
NameDescribe
create_or_delete_trace_kprobe