小弟我去,environ变量太诡异了,gdb看不到

我去,environ变量太诡异了,gdb看不到?cenvironc++gdb[解决办法]你可以间接引用:引用:能打印的话,说明envir

我去,environ变量太诡异了,gdb看不到?

c environ c++ gdb
[解决办法]
你可以间接引用:

引用:能打印的话,说明environ就是这个值:
(gdb) p environ
$1 = (char **) 0x0
否则GDB会提示找不到这样的符号。

可以肯定不是NULL,environ变量在linux下是在argv变量之后的,你可以访问environ[0]试试,
如果是NULL的话,肯定core dump了
(gdb……

[解决办法]
对学习编程者的忠告:
眼过千遍不如手过一遍!
书看千行不如手敲一行!
手敲千行不如单步一行!
单步源代码千行不如单步对应汇编一行!

layout regs:显示源代码/反汇编和CPU寄存器窗口

[解决办法]
C:\Program Files\Microsoft Visual Studio\VC98\CRT\SRC\STDENVP.C
    40: /***
    41: *_setenvp - set up "envp" for C programs
    42: *
    43: *Purpose:
    44: *       Reads the environment and build the envp array for C programs.
    45: *
    46: *Entry:
    47: *       The environment strings occur at _aenvptr.
    48: *       The list of environment strings is terminated by an extra null


    49: *       byte.  Thus two null bytes in a row indicate the end of the
    50: *       last environment string and the end of the environment, resp.
    51: *
    52: *Exit:
    53: *       "environ" points to a null-terminated list of pointers to ASCIZ
    54: *       strings, each of which is of the form "VAR=VALUE".  The strings
    55: *       are copied from the environment area. This array of pointers will
    56: *       be malloc'ed.  The block pointed to by _aenvptr is deallocated.
    57: *
    58: *Uses:
    59: *       Allocates space on the heap for the environment pointers.
    60: *
    61: *Exceptions:
    62: *       If space cannot be allocated, program is terminated.
    63: *
    64: *******************************************************************************/


[解决办法]
Access to specific environment variables is normally through the getenv and putenv functions,