key generates locationKey to be used as a key for maps.
()
| 316 | |
| 317 | // key generates locationKey to be used as a key for maps. |
| 318 | func (l *Location) key() locationKey { |
| 319 | key := locationKey{ |
| 320 | addr: l.Address, |
| 321 | isFolded: l.IsFolded, |
| 322 | } |
| 323 | if l.Mapping != nil { |
| 324 | // Normalizes address to handle address space randomization. |
| 325 | key.addr -= l.Mapping.Start |
| 326 | key.mappingID = l.Mapping.ID |
| 327 | } |
| 328 | lines := make([]string, len(l.Line)*3) |
| 329 | for i, line := range l.Line { |
| 330 | if line.Function != nil { |
| 331 | lines[i*2] = strconv.FormatUint(line.Function.ID, 16) |
| 332 | } |
| 333 | lines[i*2+1] = strconv.FormatInt(line.Line, 16) |
| 334 | lines[i*2+2] = strconv.FormatInt(line.Column, 16) |
| 335 | } |
| 336 | key.lines = strings.Join(lines, "|") |
| 337 | return key |
| 338 | } |
| 339 | |
| 340 | type locationKey struct { |
| 341 | addr, mappingID uint64 |