函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\trace_kprobe.c Create Date:2022-07-27 13:50:13
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:trace_kprobe_create

函数原型:static int trace_kprobe_create(int argc, const char *argv[])

返回类型:int

参数:

类型参数名称
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  :argv[0][0]恒等于'r'
749  is_return = true
750  flags或等于TPARG_FL_RETURN
751  退出
752  :argv[0][0]恒等于'p'
753  退出
754  默认
755  返回:负ECANCELED
757  如果argc小于2则返回:负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  如果eventevent自加
766  如果是数字
767  如果非is_return
769  转到:parse_error
771  如果eventlen等于eventargv[0][1]减1
773  否则len等于strlen - Find the length of a string*@s: The string to be sized
775  如果len大于MAX_EVENT_NAME_LEN减1则
777  转到:parse_error
779  内存复制(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  如果ret或非maxactive
784  转到:parse_error
789  如果maxactive大于KRETPROBE_MAXACTIVE_MAX
791  转到:parse_error
797  如果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.
798  trace_probe_log_set_index(1)
801  ret等于负ECANCELED
802  转到:error
805  symbol等于kstrdup(argv[1], GFP_KERNEL)
806  如果非symbol则返回:负ENOMEM
809  ret等于traceprobe_split_symbol_offset(symbol, & offset)
810  如果retoffset小于0或offset大于UINT_MAX
812  转到:parse_error
814  如果kprobe_on_func_entry(NULL, symbol, offset)则flags或等于TPARG_FL_FENTRY
816  如果offsetis_return且非flags按位与TPARG_FL_FENTRY的值则
818  转到:parse_error
822  trace_probe_log_set_index(0)
823  如果event
824  ret等于@buf must has MAX_EVENT_NAME_LEN size
826  如果ret则转到:parse_error
828  否则
830  如果symbolsnprintf - 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  否则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  如果是错误
844  ret等于错误
846  WARN_ON_ONCE(ret != - ENOMEM)
847  转到:out
849  argc减等于2
849  argv加等于2
852 i小于argci小于MAX_TRACE_ARGS循环
853  tmp等于kstrdup(argv[i], GFP_KERNEL)
854  如果非tmp
855  ret等于负ENOMEM
856  转到:error
859  trace_probe_log_set_index(i + 2)
860  ret等于traceprobe_parse_probe_arg( & tp, i, tmp, flags)
861  kfree(tmp)
862  如果ret则转到:error
866  ret等于traceprobe_set_print_fmt( & tp, is_return)
867  如果ret小于0则转到:error
870  ret等于Register a trace_probe and probe_event
871  如果ret
872  trace_probe_log_set_index(1)
873  如果ret恒等于负EILSEQtrace_probe_log_err(0, BAD_INSN_BNDRY)
875  否则如果ret恒等于负ENOENTtrace_probe_log_err(0, BAD_PROBE_ADDR)
877  否则如果ret不等于负ENOMEMret不等于负EEXISTtrace_probe_log_err(0, FAIL_REG_PROBE)
879  转到:error
882  out :
883  trace_probe_log_clear()
884  kfree(symbol)
885  返回:ret
887  parse_error :
888  ret等于负EINVAL
889  error :
890  free_trace_kprobe(tk)
891  转到:out
调用者
名称描述
create_or_delete_trace_kprobe