syncModules reconciles the state of loaded modules. When the module is unloaded from the process address space, its information is pruned from the cache. If the new module is loaded and not already present in the map, we get its export directory and insert into the map.
(e *event.Event)
| 259 | // the map, we get its export directory and insert |
| 260 | // into the map. |
| 261 | func (s *Symbolizer) syncModules(e *event.Event) error { |
| 262 | base := e.Params.TryGetAddress(params.ModuleBase) |
| 263 | size := e.Params.TryGetUint64(params.ModuleSize) |
| 264 | |
| 265 | if e.IsUnloadModule() { |
| 266 | s.mu.Lock() |
| 267 | defer s.mu.Unlock() |
| 268 | if _, ok := s.mods[e.PID][base]; ok { |
| 269 | symModulesCount.Add(-1) |
| 270 | delete(s.mods[e.PID], base) |
| 271 | // prune symbol entry from the cache if |
| 272 | // the symbol address falls within the |
| 273 | // unmapped module |
| 274 | syms, ok := s.symbols[e.PID] |
| 275 | if !ok { |
| 276 | return nil |
| 277 | } |
| 278 | for addr := range syms { |
| 279 | if addr >= base && addr <= base.Inc(size) { |
| 280 | delete(s.symbols[e.PID], base) |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | return nil |
| 287 | } |
| 288 | |
| 289 | func (s *Symbolizer) processCallstack(e *event.Event) error { |
| 290 | addrs := e.Params.MustGetSliceAddrs(params.Callstack) |
no test coverage detected