문제

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

It's not clear from your question, but you likely get that value when running program outside of 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).

In other words, run the program under GDB, print addr, then use x/s addr to examine the string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top