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

Method ParseArgType

user/config/config_module.go:42–253  ·  view source on GitHub ↗
(arg_str string, point_arg *PointArg)

Source from the content-addressed store, hash-verified

40}
41
42func (this *StackUprobeConfig) ParseArgType(arg_str string, point_arg *PointArg) error {
43 // ./stackplz -n icu.nullptr.nativetest -l libc.so -w 0x5B950[*int:x20,*int:x20+4] -w 0x5B7BC[*int:x20,*int:x20+4]
44 // ./stackplz -n com.xingin.xhs -l libart.so -w 0x4B8A74[str:x22,str:x8] --tname com.xingin.xhs --reg x28
45 // str
46 // int:x10
47 // buf:64:sp+0x20-0x8
48 // 解析为单个参数的读取配置 -> 在何处读、读取类型
49 var err error = nil
50 var to_ptr bool = false
51 var type_name string = ""
52 var read_op_str string = ""
53 var items []string
54 // 参数是否为指针
55 if strings.HasPrefix(arg_str, "*") {
56 to_ptr = true
57 type_name = arg_str[1:]
58 items = strings.SplitN(arg_str[1:], ":", 2)
59 } else {
60 items = strings.SplitN(arg_str, ":", 2)
61 }
62 // 提取类型、参数读取索引
63 if len(items) == 1 {
64 type_name = items[0]
65 } else if len(items) == 2 {
66 type_name = items[0]
67 read_op_str = items[1]
68 } else {
69 return errors.New(fmt.Sprintf("parse arg_str:%s failed, err:%v", arg_str, err))
70 }
71 // 提取参数过滤规则
72 filter_items := strings.SplitN(type_name, ".", 2)
73 if len(filter_items) == 2 {
74 type_name = filter_items[0]
75 filter_names := strings.Split(filter_items[1], ".")
76 for _, filter_name := range filter_names {
77 if filter_name != "" {
78 point_arg.AddFilterIndex(GetFilterIndex(filter_name))
79 }
80 }
81 }
82 to_hex := false
83 if strings.HasSuffix(type_name, "x") {
84 to_hex = true
85 type_name = type_name[:len(type_name)-1]
86 }
87 switch type_name {
88 case "int":
89 point_arg.SetTypeIndex(INT)
90 case "uint":
91 point_arg.SetTypeIndex(UINT)
92 case "int8":
93 point_arg.SetTypeIndex(INT8)
94 case "uint8":
95 point_arg.SetTypeIndex(UINT8)
96 case "int16":
97 point_arg.SetTypeIndex(INT16)
98 case "uint16":
99 point_arg.SetTypeIndex(UINT16)

Callers 1

Parse_HookPointMethod · 0.95

Calls 15

GetTypeIndexMethod · 0.95
SetDumpHexMethod · 0.95
SetColorMethod · 0.95
R_NUM_ARRAYFunction · 0.92
R_BUFFER_LENFunction · 0.92
R_BUFFER_REGFunction · 0.92
Add_READ_MOVE_REGFunction · 0.92
GetFilterIndexFunction · 0.85
GetRegIndexFunction · 0.85
AddFilterIndexMethod · 0.80
SetGroupTypeMethod · 0.80
SetTypeByNameMethod · 0.80

Tested by

no test coverage detected