dbx: Can't evaluate local variables in optimized functions
I turned on the optimization for the whole product. Now I found that I can not print the local variables declared in side the main funciton or inside the function locals.
eg.
int factorial (int n)
{
int factorial = 1;
while (n > 1)
{
factorial *= n--;
}
return factorial;
}
When I tried to print n or factorial, I would not able to do so...
Is there any way can I get the local variables printed?
Is there any compiler options to overcome this problem and printing the local variables...
I know this is an difficult question becuase the locals go to Register instead of memory. By reverting it back to memory, I may loose the efficiency I gained with this optimizations.
options : -fast -xtarget=ultra3 -xarch=v8plusa -g0
Please let me know....
#include <iostream>
#include <string>
#include <unistd.h>
#include <stdio.h>
using namespace std;
int main(int argc, char **argv)
{
FILE *fp=freopen("myfile.txt","w",stdout);
int bytes_read;
char buffer[10000];
std::cout<<"##This should be 0 15238.0.172435 written in to the 1 file with out any HICK-UPs"<<endl;
FILE *myfp=fopen("myfile.txt","r");
cerr><<"This goes to std error file"<<endl;
fseek(myfp, 0, SEEK_END);
int len = ftell(myfp);
fseek(myfp, 0, SEEK_SET);
fread(buffer,len,1,myfp);
fclose(myfp);
fclose(fp);
string mystring(buffer);
std::string::size_type location=mystring.find("15238.0.172435",0);
std::string::size_type location1=mystring.find("116530640358374636",0);
if(location != std::string::npos )
cerr><<"Buffer Read that is read from file inside the if condition \n<\n"<<buffer><<"\n>"<<endl;
if(location1 != std::string::npos )
cerr><<"Buffer Read that is read from file inside the if condition and location1 \n<\n"<<buffer><<"\n>"<<endl;
remove("myfile.txt");
return 0;
}
stopped in main (optimized) at line 8 in file "fileex.cc"
8int main(int argc, char **argv)
(dbx) cont
This goes to std error file
stopped in main (optimized) at line 27 in file "fileex.cc"
27int len = ftell(myfp);
(dbx) print len
dbx: Can't evaluate local variables in optimized functions>

