简体   繁体   English

使用gdb 64bit超出范围检查内存

[英]Examine memory with gdb 64bit out of bounds

Using 使用

char *addr = getenv("CNFG") 

I get 我懂了

0x7fffffffebea

Then debugging my program I get this error message: 然后调试我的程序,我得到以下错误消息:

(gdb) x/ls 0x7fffffffebea 
0x7fffffffebea:  <Address 0x7fffffffebea out of bounds>

How do I to examine the contents of that environment variable (in order to to check that has a valid value)? 如何检查该环境变量的内容(以便检查是否具有有效值)?

I get 0x7fffffffebea 我得到0x7fffffffebea

It's not clear from your question, but you likely get that value when running program outside of GDB. 从您的问题尚不清楚,但是在GDB外部运行程序时,您可能会获得该值。 That value should change from run to run (due to address space layout randomization), and you should get a different value inside GDB (due to differences in stack layout when running under GDB). 该值应随运行而变化(由于地址空间布局随机化), 并且您应该在GDB中获得一个不同的值(由于在GDB下运行时堆栈布局的差异)。

In other words, run the program under GDB, print addr, then use x/s addr to examine the string. 换句话说,在GDB下运行该程序,打印addr, 然后使用x/s addr检查该字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM