| 434 | } |
| 435 | |
| 436 | CorefileRemoteMemoryManager::StatusCode |
| 437 | CorefileRemoteMemoryManager::getMemoryLocationFromCore(remote_addr_t addr, off_t* offset_in_file) const |
| 438 | { |
| 439 | auto corefile_it = std::find_if(d_vmaps.cbegin(), d_vmaps.cend(), [&](auto& map) { |
| 440 | // When considering if the data is in the core file, we need to check if the address is |
| 441 | // within the chunk of the segment in the core file. map.End() corresponds |
| 442 | // to the end of the segment in memory when the process was alive but when the core was |
| 443 | // created not all that data will be in the core, so we need to use map.FileSize() |
| 444 | // to get the end of the segment in the core file. |
| 445 | uintptr_t fileEnd = map.Start() + map.FileSize(); |
| 446 | return (map.Start() <= addr && addr < fileEnd) && (map.FileSize() != 0 && map.Offset() != 0); |
| 447 | }); |
| 448 | if (corefile_it == d_vmaps.cend()) { |
| 449 | return StatusCode::ERROR; |
| 450 | } |
| 451 | |
| 452 | off_t base = corefile_it->Offset() - corefile_it->Start(); |
| 453 | *offset_in_file = base + addr; |
| 454 | return StatusCode::SUCCESS; |
| 455 | } |
| 456 | |
| 457 | CorefileRemoteMemoryManager::StatusCode |
| 458 | CorefileRemoteMemoryManager::initLoadSegments(const std::string& filename) const |