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

Method start

user/module/stack.go:152–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150}
151
152func (this *MStack) start() error {
153 // 初始化uprobe相关设置
154 err := this.setupManager()
155 if err != nil {
156 return err
157 }
158 this.setupManagerOptions()
159
160 // 从assets中获取eBPF程序的二进制数据
161 var bpfFileName = filepath.Join("user/assets", this.hookBpfFile)
162 byteBuf, err := assets.Asset(bpfFileName)
163
164 if err != nil {
165 return fmt.Errorf("%s\tcouldn't find asset %v .", this.Name(), err)
166 }
167
168 // 初始化 bpfManager 循环次数越多这一步耗时越长
169 if err = this.bpfManager.InitWithOptions(bytes.NewReader(byteBuf), this.bpfManagerOptions); err != nil {
170 return fmt.Errorf("couldn't init manager %v", err)
171 }
172
173 // 启动 bpfManager
174 if err = this.bpfManager.Start(); err != nil {
175 return fmt.Errorf("couldn't start bootstrap manager %v .", err)
176 }
177
178 // 通过更新 BPF_MAP_TYPE_HASH 类型的 map 实现过滤设定的同步
179 err = this.updateFilter()
180 if err != nil {
181 return err
182 }
183
184 // 加载map信息,设置eventFuncMaps,给不同的事件指定处理事件数据的函数
185 err = this.initDecodeFun()
186 if err != nil {
187 return err
188 }
189
190 return nil
191}
192
193func (this *MStack) update_map(map_name string, filter_key uint32, filter_value interface{}) {
194 bpf_map, err := this.FindMap(map_name)

Callers 1

StartMethod · 0.95

Calls 6

setupManagerMethod · 0.95
setupManagerOptionsMethod · 0.95
updateFilterMethod · 0.95
initDecodeFunMethod · 0.95
NameMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected