MCPcopy Create free account
hub / github.com/bloomberg/pystack / getMemoryLocationFromCore

Method getMemoryLocationFromCore

src/pystack/_pystack/mem.cpp:436–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434}
435
436CorefileRemoteMemoryManager::StatusCode
437CorefileRemoteMemoryManager::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
457CorefileRemoteMemoryManager::StatusCode
458CorefileRemoteMemoryManager::initLoadSegments(const std::string& filename) const

Callers

nothing calls this directly

Calls 3

StartMethod · 0.80
FileSizeMethod · 0.80
OffsetMethod · 0.80

Tested by

no test coverage detected