Re: question about assembly code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok thanks for the information !
But when the floating point happens gdb shows the fcmove instruction, the content of the variable is NAN (because of the UMR) but the condition must be false (at least the function has returned 0).
When the FPE is raised the floating point stack is :
=>R7: Valid   0x3fff8000000000000000 +1
  R6: Empty   0x00000000000000000000
  R5: Empty   0x00000000000000000000
  R4: Empty   0xc0778fb44823c7812000
  R3: Empty   0x3febc9539b888722a000
  R2: Empty   0x3feba10fafa06c1bb5b7
  R1: Empty   0x00000000000000000000
  R0: Empty   0x3feb8637bd05af6c6800



Any idea about what to check in my gdb ?


On 08/09/11 16:44, Ian Lance Taylor wrote:
Olivier Maury<Olivier_maury@xxxxxxxxxx>  writes:

I was wondering, is the following assembly code correct:
      c94:       e8 fc ff ff ff          call   c95
<load_param_def_given+0x1d1>
      c99:       84 c0                   test   %al,%al
      c9b:       dd 45 d0                fldl   -0x30(%ebp)
      c9e:       dd 45 d8                fldl   -0x28(%ebp)
      ca1:       da c9                   fcmove %st(1),%st
      ca3:       dd d9                   fstp   %st(1)
      ca5:       dd 5d d0                fstpl  -0x30(%ebp)
      ca8:       89 f8                   mov    %edi,%eax

This code is some optimized assembly code extracted from the object
file using objdump. My concern here is that I have a test instruction
without the corresponding jump !
The test instruction is setting the flags for the fcmove instruction.


That piece of assembly comes from a code that look like:
if (my_function(param1,&out_param))
     value = out_param;

with :
out_param a double value that is not assigned with a default value
and
char my_function(long param1, double *out)
{
    char ret = 0;
     ... do some stuff ...
     if (some_property)
    {
        ... do some stuff ...
        *out = a_value_computed;
        ret = 1;
    }
    ....
    return ret;
}

And taking that optimized code in a debugger it crash with a FPE from
time to time because even if the my_function returns 0 it seems to do
the assignement (value = out_param) with an unitialized out_param
value !

What do you think ? Am I doing something wrong or is it a gcc bug ?
It's pretty hard to say anything about an incomplete example.  However,
fcmove is a conditional move, so the code will only do the move if the
value returned is non-zero.  I don't see anything wrong in what you have
shown us.

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux