MCPcopy Create free account
hub / github.com/SeeFlowerX/stackplz / GetPointArg

Method GetPointArg

user/config/config_file.go:45–210  ·  view source on GitHub ↗
(arg_index, point_type uint32)

Source from the content-addressed store, hash-verified

43}
44
45func (this *ParamConfig) GetPointArg(arg_index, point_type uint32) *PointArg {
46 // 参数名省略时 以 a{index} 这样的形式作为名字
47 arg_name := fmt.Sprintf("a%d", arg_index)
48 if this.Name != "" {
49 arg_name = this.Name
50 }
51 // 默认以参数索引作为寄存器索引 除非特别指定寄存器
52 // 若通过 read_op 指定读取地址 后面根据 ExtraOpList 决定是否使用这里的索引
53 reg_index := arg_index
54 if this.Reg != "" {
55 reg_index = GetRegIndex(this.Reg)
56 }
57 // 基础配置
58 var point_arg *PointArg
59 switch point_type {
60 case EBPF_SYS_ENTER, EBPF_SYS_EXIT, EBPF_SYS_ALL:
61 point_arg = NewSyscallPointArg(arg_name, POINTER, reg_index, point_type)
62 case EBPF_UPROBE_ENTER:
63 point_arg = NewUprobePointArg(arg_name, POINTER, reg_index)
64 default:
65 panic("...")
66 }
67 // 先处理一些比较特殊的情况
68
69 to_ptr := false
70 type_name := this.Type
71 if strings.HasPrefix(type_name, "*") {
72 to_ptr = true
73 type_name = type_name[1:]
74 }
75
76 switch type_name {
77 case "buf":
78 // buf 类型需要给定读取的大小 但是这个大小有可能是通过寄存器指定
79 at := argtype.R_BUFFER_LEN(256)
80 if this.Size != "" {
81 size, err := strconv.ParseUint(this.Size, 0, 32)
82 if err == nil {
83 // 以指定长度作为读取大小
84 at = argtype.R_BUFFER_LEN(uint32(size))
85 } else {
86 // 以寄存器的值作为读取大小
87 at = argtype.R_BUFFER_REG(GetRegIndex(this.Size))
88 }
89 }
90 point_arg.SetTypeIndex(at.GetTypeIndex())
91 // 这个设定用于指示是否进一步读取和解析
92 point_arg.SetGroupType(EBPF_UPROBE_ENTER)
93 case "iovec":
94 at := argtype.R_IOVEC_REG(this.Size)
95 point_arg.SetTypeIndex(at.GetTypeIndex())
96 point_arg.SetGroupType(EBPF_UPROBE_ENTER)
97 case "int_arr", "uint_arr", "ptr_arr":
98 // 必须指定数组长度
99 size, err := strconv.ParseUint(this.Size, 0, 32)
100 if err != nil {
101 panic(fmt.Sprintf("parse %s array size failed", type_name))
102 }

Callers 2

Parse_FileConfigMethod · 0.80
Parse_FileConfigMethod · 0.80

Calls 15

SetTypeIndexMethod · 0.95
GetTypeIndexMethod · 0.95
SetGroupTypeMethod · 0.95
SetTypeByNameMethod · 0.95
ToPointerTypeMethod · 0.95
SetHexFormatMethod · 0.95
SetFlagsFormatMethod · 0.95
AddFilterIndexMethod · 0.95
AddExtraOpMethod · 0.95
R_BUFFER_LENFunction · 0.92
R_BUFFER_REGFunction · 0.92
R_IOVEC_REGFunction · 0.92

Tested by

no test coverage detected