Ignore:
Timestamp:
Sep 30, 2007, 11:41:15 PM (18 years ago)
Author:
bird
Message:

Fixed some unwinding stuff on msc+amd64.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kStuff/kProfiler2/prfamd64msc.asm

    r3592 r3593  
    9191        or      r8, rax                 ; param 3 - the timestamp
    9292        mov     [rsp + 20h], r8         ; save the tsc for later use.
    93         lea     rdx, [rsp + 8*8 + 28h]  ; Param 2 - frame pointer (pointer to the return address of the function calling us)
     93        lea     rdx, [rsp + 8*8 + 28h]  ; Param 2 - default frame pointer
    9494        mov     rcx, [rdx]              ; Param 1 - The function address
     95
     96        ; MSC seems to put the _penter both before and after the typical sub rsp, xxh
     97        ; statement as if it cannot quite make up its mind. We'll try adjust for this
     98        ; to make the unwinding a bit more accurate wrt to longjmp/throw. But since
     99        ; there are also an uneven amount of push/pop around the _penter/_pexit we
     100        ; can never really make a perfect job of it. sigh.
     101        cmp     word [rcx - 5 - 4], 08348h  ; sub rsp, imm8
     102        jne     .not_byte_sub
     103        cmp     byte [rcx - 5 - 2], 0ech
     104        jne     .not_byte_sub
     105        movzx   eax, byte [rcx - 5 - 1]     ; imm8
     106        add     rdx, rax
     107        jmp     .call_prf_enter
     108.not_byte_sub:
     109        cmp     word [rcx - 5 - 7], 08148h  ; sub rsp, imm8
     110        jne     .not_dword_sub
     111        cmp     byte [rcx - 5 - 5], 0ech
     112        jne     .not_dword_sub
     113        mov     eax, [rcx - 5 - 4]          ; imm32
     114        add     rdx, rax
     115;        jmp     .call_prf_enter
     116.not_dword_sub:
     117.call_prf_enter:
    95118        call    KPRF_ENTER
    96119        jmp     common_return_path
     
    135158        or      r8, rax                 ; param 3 - the timestamp
    136159        mov     [rsp + 20h], r8         ; save the tsc for later use.
    137         lea     rdx, [rsp + 8*8 + 28h]  ; Param 2 - frame pointer (pointer to the return address of the function calling us)
     160        lea     rdx, [rsp + 8*8 + 28h]  ; Param 2 - frame pointer.
    138161        mov     rcx, [rdx]              ; Param 1 - The function address
     162
     163        ; MSC some times put the _pexit before the add rsp, xxh. To try match up with
     164        ; any adjustments made in _penter, we'll try detect this.
     165        cmp     word [rcx], 08348h      ; add rsp, imm8
     166        jne     .not_byte_sub
     167        cmp     byte [rcx + 2], 0c4h
     168        jne     .not_byte_sub
     169        movzx   eax, byte [rcx + 3]     ; imm8
     170        add     rdx, rax
     171        jmp     .call_prf_leave
     172.not_byte_sub:
     173        cmp     word [rcx], 08148h      ; add rsp, imm32
     174        jne     .not_dword_sub
     175        cmp     byte [rcx + 2], 0c4h
     176        jne     .not_dword_sub
     177        mov     eax, [rcx + 3]          ; imm32
     178        add     rdx, rax
     179;        jmp     .call_prf_leave
     180.not_dword_sub:
     181.call_prf_leave:
    139182        call    KPRF_LEAVE
    140183        jmp common_return_path
Note: See TracChangeset for help on using the changeset viewer.