C++ GDB无法访问内存I mmap

C++ GDB无法访问内存I mmap,c++,ubuntu,gdb,mmap,C++,Ubuntu,Gdb,Mmap,在我的代码中,我映射了一些内存,可以从中读写。但由于某种原因,当我在gdb中运行代码时,gbd无法访问它。有什么问题吗 有问题的代码 cout << "creating temp" << endl; int *temp = mmap(... PROT_READ | PROT_WRITE ...); *temp = 5; cout << "temp = " << *temp << endl; 我的gdb提示符 (gdb) n 77

在我的代码中,我映射了一些内存,可以从中读写。但由于某种原因,当我在gdb中运行代码时,gbd无法访问它。有什么问题吗

有问题的代码

cout << "creating temp" << endl;
int *temp = mmap(... PROT_READ | PROT_WRITE ...);
*temp = 5;
cout << "temp = " << *temp << endl;
我的gdb提示符

(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
(gdb)n
77*温度=5;
(gdb)p温度
$1=(int*)0x7fffec4000;
(gdb)x温度
0x7fffec4000:无法访问0x7fffec4000处的内存
(gdb)n

那个地址真的有效吗?在一个页面地址上读起来像是“死牛肉”
。你改变语言的原因是什么?(然后去掉错误语言的标签)。我为这个简单化的例子写了一个易于识别的地址。实际地址是一个随机地址,沿着0x7FFEC400i写的C++代码,但是我的问题是代码,它不是针对C++的,什么类型的对象被映射?我听说
ptrace
无法访问已映射到设备特殊文件的内存。另外,你能添加一个标识你的操作系统的标签吗?这真的是一个有效的地址吗?在一个页面地址上读起来像是“死牛肉”。你改变语言的原因是什么?(然后去掉错误语言的标签)。我为这个简单化的例子写了一个易于识别的地址。实际地址是一个随机地址,沿着0x7FFEC400i写的C++代码,但是我的问题是代码,它不是针对C++的,什么类型的对象被映射?我听说
ptrace
无法访问已映射到设备特殊文件的内存。另外,您可以添加标识您的操作系统的标记吗?
(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