Can not see mmap memory in GDB

-1

I am testing mmap with the following code:

...
int memFd;
char *sharedMem;
memFd = open("/dev/mem", O_RDWR);
sharedMem = (unsigned int *) mmap(NULL, 0x10000000, PROT_READ | PROT_WRITE, MAP_SHARED, memFd, SHARD_MEM);
...

When I try to look up the 'sharedMem' or 'SHARD_MEM' address in gdb, I get the following error:

cannot access memory at address 0x********

After searching, I understood that it was impossible to view sharedMem.

What I'm curious about is:

  • I did not understand why not. Please explain in detail
  • Why can not I get access to mmap virtual memory instead of physical memory?
gdb
mmap
asked on Stack Overflow May 20, 2019 by 김어진

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0