In my code I mmap some memory and can read and write from it. For some reason when I run the code in gdb though, gbd can't access it. What's the problem?
The code in question
cout << "creating temp" << endl;
int *temp = mmap(... PROT_READ | PROT_WRITE ...);
*temp = 5;
cout << "temp = " << *temp << endl;
The output when ran
creating temp
temp = 5
My gdb prompt
(gdb) n
77 *temp = 5;
(gdb) p temp
$1 = (int *)0x7fffec4000;
(gdb) x temp
0x7fffec4000: cannot access memory at 0x7fffec4000
(gdb) n
78 cout << "temp = " << *temp << endl;
(gdb) x temp
0x7fffec4000: cannot access memory at 0x7fffec4000
(gdb) n
temp = 5
(gdb) x temp
0x7fffec4000: cannot access memory at 0x7fffec4000