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

Method CloneMaps

user/event/event_mmap2.go:163–185  ·  view source on GitHub ↗
(pid, parent_pid uint32)

Source from the content-addressed store, hash-verified

161}
162
163func (this *MapsHelper) CloneMaps(pid, parent_pid uint32) (err error) {
164 // 为子进程复制一份maps信息
165 maps_lock.Lock()
166 defer maps_lock.Unlock()
167 pid_maps, ok := this.pid_maps[parent_pid]
168 if !ok {
169 // 在当前维护的maps中不存在父进程的 比如是在进程运行过程中hook的
170 // 那么尝试去读取父进程的maps
171 err = this.ParseMaps(parent_pid, false)
172 if err != nil {
173 // 应该不会走到这个分支
174 return err
175 }
176 pid_maps, ok = this.pid_maps[parent_pid]
177 if !ok {
178 // ParseMaps 成功的情况下应该不会到这个分支
179 return errors.New(fmt.Sprintf("ParseMaps success, but get pid_maps failed by child:%d parent:%d", pid, parent_pid))
180 }
181 }
182 copied_maps := pid_maps.Clone()
183 this.pid_maps[pid] = &copied_maps
184 return nil
185}
186
187func (this *MapsHelper) GetStack(pid uint32, ubuf *UnwindBuf) (info string, err error) {
188 // 当直接读取 maps 文件失败的时候 就采用这个方案获取堆栈

Callers 1

UpdateForkEventMethod · 0.95

Calls 2

ParseMapsMethod · 0.95
CloneMethod · 0.65

Tested by

no test coverage detected