Is it possible to get the value of an unused variable using gdb? Is there any configuration for GCC so that the garbage value for an unused variable is not displayed "optimized"?
c file:
#include<stdio.h> void main() { int x; int y; printf("value of x: %d",x); }
In gdb, I want to get the garbage value of the variable y.
(gdb) run Starting program: /home/charmae/workspace/AVT/a.out Breakpoint 1, main () at file4.c:7 7 printf("value of x: %d",x); (gdb) info locals x = 2789364 (gdb) py $1 = <optimized out> (gdb) px $2 = 2789364
source share