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

Method ParseMapsContent

user/event/event_mmap2.go:258–314  ·  view source on GitHub ↗
(pid uint32, content []byte, del_old bool)

Source from the content-addressed store, hash-verified

256}
257
258func (this *MapsHelper) ParseMapsContent(pid uint32, content []byte, del_old bool) error {
259 var (
260 seg_start uint64
261 seg_end uint64
262 permission string
263 seg_offset uint64
264 device string
265 inode uint64
266 seg_path string
267 )
268
269 if del_old {
270 this.pid_maps[pid] = &ProcMaps{}
271 } else {
272 _, ok := this.pid_maps[pid]
273 if !ok {
274 this.pid_maps[pid] = &ProcMaps{}
275 }
276 }
277 pid_maps := this.pid_maps[pid]
278 for _, line := range strings.Split(string(content), "\n") {
279 reader := strings.NewReader(line)
280 n, err := fmt.Fscanf(reader, "%x-%x %s %x %s %d %s", &seg_start, &seg_end, &permission, &seg_offset, &device, &inode, &seg_path)
281 if err == nil && n == 7 {
282 if seg_path == "" {
283 seg_path = fmt.Sprintf("UNNAMED_0x%x", seg_start)
284 }
285 new_info := LibInfo{
286 BaseAddr: seg_start,
287 Off: seg_offset,
288 EndAddr: seg_end,
289 LibPath: seg_path,
290 }
291 new_info.ParseLib()
292
293 base_list, ok := (*pid_maps)[seg_path]
294 if ok {
295 // 注意基址列表去重 做成列表的原因是...
296 has_find := false
297 for _, info := range base_list {
298 if info.BaseAddr == new_info.BaseAddr {
299 has_find = true
300 break
301 }
302 }
303 if !has_find {
304 base_list = append(base_list, new_info)
305 (*pid_maps)[seg_path] = base_list
306 }
307 } else {
308 (*pid_maps)[seg_path] = []LibInfo{new_info}
309 }
310 }
311 }
312 this.pid_maps[pid] = pid_maps
313 return nil
314}
315

Callers 2

TryManualUpdateMapsMethod · 0.95
ParseMapsMethod · 0.95

Calls 1

ParseLibMethod · 0.95

Tested by

no test coverage detected