At the time of a crash I have a post crash handler where I try to dump whats in certain memory regions
auto memdump = std::fstream("FileMemDump.bin", std::ios::out | std::ios::binary);
auto memRegion = getMemoryRegion();
std::cout << "Memory region start: " << memRegion.start << " size: " << memRegion.size;
memdump.write((char*)memRegion.start, memRegion.size);
memdump.close();
Run Code Online (Sandbox Code Playgroud)
and after the file has created a core file So after I load the core in the following manner :
#gdb ./exec ./core.file
Run Code Online (Sandbox Code Playgroud)
I give the restore command; the start address is what is printed from the above log... and it fails with the following message
(gdb) restore ./FileMemDump.bin binary 0 0xFFAA0000
You can't do that without a process to debug.
Run Code Online (Sandbox Code Playgroud)
a. Are the options given to the std::fstream OK or
b. Is it possible call the gdb-dump command from with in the code (since dump from gdb can be restored)
or what I am trying to do is not feasible
EDIT:
mmap() it to a /dev device and similarly I mmap() the nonvolatile dimm area as well (we do not use conventional malloc)With this ; when the process asserts/cores I am not able to access the hugepages or the non volatile dimm areas
mmap()的参数
fp = open("/dev/mem", O_RDWR);
mmap(NULL,
region.size,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE,
fp,
phybaseaddr);
Run Code Online (Sandbox Code Playgroud)