while debugging I need to print the value of a variable that is declared in the else block. something like this :
if(condition){
}
else {
string str = "abcd";
strcpy(globalvariable,str,sizeOf(str));
}
I want to see the value of str.
break command. In your case, (gdb) break strcpy to break every time it is being called strcpy in else.x str, x/s str, print str, print "%s", str. You can't see the value of str if condition is true during program flow because it does not exist in memory in this case.
You have to enter else block somehow, either during normal program flow or using gdb jump command.