2014-02-27 132 views
0

flds指令應該將值存儲在寄存器st0中。我正在調試我沒有編碼的共享庫。有時flds指令對st0沒有任何影響。下面是gdb輸出的情況下,當它的工作和一個案件,當它失敗。在破碎的情況下,fstat寄存器是0x2261而不是0x2061。 0x200標誌表示什麼?Mac OSX上的flds指令失敗

工作版本:

 
    0x6d9b4f : flds -0x4(%ebp) 
    0x6d9b52 : leave 
    0x6d9b53 : ret 
    (gdb) info registers fstat st0 st1 st2 st3 st4 st5 st6 st7 
    fstat   0x2061 8289 
    st0   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st1   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st2   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st3   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st4   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st5   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st6   780250362506194 (raw 0x4030b1688c6c5af48000) 
    st7   1  (raw 0x3fff8000000000000000) 
    (gdb) ni 
    0x006d9b52 in Startup() 
    1: x/3i $pc 
    0x6d9b52 : leave 
    0x6d9b53 : ret 
    0x6d9b54 : push %ebp 
    (gdb) info registers fstat st0 st1 st2 st3 st4 st5 st6 st7 
    fstat   0x1861 6241 
    st0   -1584 (raw 0xc009c600000000000000) 
    st1   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st2   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st3   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st4   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st5   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st6   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st7   780250362506194 (raw 0x4030b1688c6c5af48000) 

破碎的版本:

 
    0x6d9b4f : flds -0x4(%ebp) 
    0x6d9b52 : leave 
    0x6d9b53 : ret 
    (gdb) info registers fstat st0 st1 st2 st3 st4 st5 st6 st7 
    fstat   0x2261 8801 
    st0   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st1   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st2   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st3   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st4   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st5   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st6   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st7   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    (gdb) ni 
    0x006d9b52 in Startup() 
    1: x/3i $pc 
    0x6d9b52 : leave 
    0x6d9b53 : ret 
    0x6d9b54 : push %ebp 
    (gdb) info registers fstat st0 st1 st2 st3 st4 st5 st6 st7 
    fstat   0x1a61 6753 
    st0   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st1   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st2   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st3   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st4   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st5   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st6   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 
    st7   -nan(0xc000000000000000) (raw 0xffffc000000000000000) 

回答

4

標誌0x200稱爲C1條件位,它提供了在FPU堆棧問題的情況下的附加信息。英特爾手冊上說:

C1條件代碼標誌用於各種功能。當0x87 FPU狀態字中的IE和SF標誌均置位時, 表示 表示堆棧溢出或下溢異常(#IS),C1標誌將區分溢出(C1 = 1)和下溢(C1 = 0)。

請注意,info float將給你一個更詳細的轉儲,包括狀態和控制位的名稱,即使有後者的解釋。

Status Word:   0x1a61 IE    PE  SF  C1 
         TOP: 3 

這一切意味着代碼不能正確平衡fpu堆棧。顯然,工作版本和損壞版本都有堆棧問題,只有一個是下溢,另一個是溢出,或者C1標誌已被更改。

其中一個原因的原因可能是FPU寄存器在一種情況下是空的。我們不能說沒有FPU標籤字(哪個info float也會顯示)。

+0

謝謝你的幫助。我現在已經解決了這個問題。正如你所說,在這兩種情況下堆棧已經損壞。問題是庫在我的代碼中調用了一個回調函數,它返回一個float而不是int。 – user3359929

+1

幹得好,感謝您的更新。瞭解你如何設法解決問題總是很好的。 – Jester