Вопрос

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