I am trying to debug the problem I posted earlier here:
C++ and pin tool -- very weird DOUBLE variable issue with IF statement.
I tracked down the moment when the weird behavior occurred using gdb. What I found is shown in the figure below that shows the gdb screenshot displaying the disassembled code and floating pointer register values. (larger image here)
Left-hand side image shows the screenshot before the highlighted FLDZ
instruction is executed and the right-hand side image is after the instructions is executed. I looked up the x86 ISA and FLDZ
is for loading +0.0
into ST(0)
. However, what I get is -nan
instead of +0.0
.
Does anybody know why this happens?
The system I am using is Intel xeon 5645 running 64-bit CentOS, but the target program I am trying to debug is 32-bit application. Also, as I mentioned in the earlier post, I tried two versions of gcc, 4.2.4 and 4.1.2 and observed the same problem.
Thanks.
--added-- By the way, below is the source code.
void Router::Evaluate( )
{
if (_id == 0) aaa++;
if ( _partial_internal_cycles != 0 )
{
aaa += 12345;
cout << "this is not a zero : " << endl;
on = true;
}
_partial_internal_cycles += (double) 1.0;
if ( _partial_internal_cycles >= (double)1.0 ) {
_InternalStep( );
_partial_internal_cycles -= (double)1.0;
}
if (GetSimTime() > 8646000 && _id == 0) cout << "aaa = " << aaa << endl;
if ( on)
{
cout << "break. id = " << _id << endl;
assert(false);
}
}