[fpc-devel] Internal jump instructions for longer conditional jumps
Martin Frb
lazarus at mfriebe.de
Mon Apr 20 23:38:13 CEST 2020
On 20/04/2020 23:11, Florian Klämpfl wrote:
> Am 20.04.20 um 22:45 schrieb Martin Frb:
>>
>
> Can you post also the relevant output of -al? It makes it easier to
> see where every assembler instruction comes from.
This is the entire proc
I put long
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
to mark the lines.
1) the begin of the IF
2) the jmp at the very end of that IF
3) the label
4) the next jmp
.section
.text.n_fpdbgcontroller$_$tdbgcontrollerstepoutcmd_$__$$_internalcontinue$tdbgprocess$tdbgthread,"x"
.balign 16,0x90
.globl
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_INTERNALCONTINUE$TDBGPROCESS$TDBGTHREAD
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_INTERNALCONTINUE$TDBGPROCESS$TDBGTHREAD:
.Lc206:
# Temps allocated between rbp-72 and rbp-32
.seh_proc
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_INTERNALCONTINUE$TDBGPROCESS$TDBGTHREAD
.Ll380:
# [793] begin
pushq %rbp
.seh_pushreg %rbp
.Lc208:
.Lc209:
movq %rsp,%rbp
.Lc210:
leaq -112(%rsp),%rsp
.seh_stackalloc 112
movq %rbx,-72(%rbp)
movq %rdi,-64(%rbp)
movq %rsi,-56(%rbp)
movq %r12,-48(%rbp)
movq %r13,-40(%rbp)
.seh_savereg %rbx, 40
.seh_savereg %rdi, 48
.seh_savereg %rsi, 56
.seh_savereg %r12, 64
.seh_savereg %r13, 72
.seh_endprologue
# Var AProcess located at rbp-8, size=OS_64
# Var AThread located at rbp-16, size=OS_64
# Var $self located at rbp-24, size=OS_64
# Var Outside located at rbp-32, size=OS_8
movq %rcx,-24(%rbp)
movq %rdx,-8(%rbp)
movq %r8,-16(%rbp)
.Ll381:
movb $85,-32(%rbp)
.Ll382:
# [794] assert(FProcess=AProcess, 'TDbgControllerStepOutCmd.DoContinue:
FProcess=AProcess');
movq -24(%rbp),%rax
movq 24(%rax),%rax
cmpq -8(%rbp),%rax
jne .Lj1617
jmp .Lj1618
.Lj1617:
movq %rbp,%r9
leaq _$FPDBGCONTROLLER$_Ld1(%rip),%rdx
leaq _$FPDBGCONTROLLER$_Ld24(%rip),%rcx
movl $794,%r8d
call fpc_assert
.Lj1618:
.Ll383:
# [796] if (AThread = FThread) then begin
movq -24(%rbp),%rax
movq 16(%rax),%rax
cmpq -16(%rbp),%rax
je .Lj1627
jmp .Lj1628
.Lj1627:
.Ll384:
# [797] if IsSteppedOut then begin
movq -24(%rbp),%rcx
call
FPDBGCONTROLLER$_$TDBGCONTROLLERHIDDENBREAKSTEPBASECMD_$__$$_GETISSTEPPEDOUT$$BOOLEAN
testb %al,%al
jne .Lj1629
jmp .Lj1630
.Lj1629:
.Ll385:
# [798] CheckForCallAndSetBreak;
movq -24(%rbp),%rcx
call
FPDBGCONTROLLER$_$TDBGCONTROLLERHIDDENBREAKSTEPBASECMD_$__$$_CHECKFORCALLANDSETBREAK$$BOOLEAN
jmp .Lj1635
.Lj1630:
.Ll386:
# [801] if not assigned(FHiddenBreakpoint) then begin
movq -24(%rbp),%rax
cmpq $0,72(%rax)
je .Lj1636
jmp .Lj1637
.Lj1636:
.Ll387:
# [802] if GetOutsideFrame(Outside) then begin
leaq -32(%rbp),%rdx
movq -24(%rbp),%rcx
call
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_GETOUTSIDEFRAME$BOOLEAN$$BOOLEAN
testb %al,%al
jne .Lj1638
jmp .Lj1639
.Lj1638:
.Ll388:
# [803] SetReturnAdressBreakpoint(AProcess, Outside);
movzbl -32(%rbp),%r8d
movq -8(%rbp),%rdx
movq -24(%rbp),%rcx
call
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_SETRETURNADRESSBREAKPOINT$TDBGPROCESS$BOOLEAN
jmp .Lj1650
.Lj1639:
.Ll389:
# [806] if FStepCount < 12 then
movq -24(%rbp),%rax
cmpl $12,136(%rax)
jl .Lj1651
jmp .Lj1652
.Lj1651:
.Ll390:
# [811] Inc(FStepCount);
movq -24(%rbp),%rax
movslq 136(%rax),%rbx
addq $1,%rbx
jno .Lj1655
call FPC_OVERFLOW
.Lj1655:
movq %rbx,%rax
subq $-2147483648,%rax
# Fix for Win64-GAS bug
movl $4294967295,%edx
cmpq %rdx,%rax
jbe .Lj1656
call fpc_rangeerror
.Lj1656:
movq -24(%rbp),%rax
movl %ebx,136(%rax)
.Ll391:
# [812] if NextInstruction.IsCallInstruction or
NextInstruction.IsLeaveStackFrame then // asm "call" // set break
before "leave" or the frame becomes unavail
movq -24(%rbp),%rax
cmpq $0,40(%rax)
je .Lj1663
jmp .Lj1664
.Lj1663:
movq -24(%rbp),%rax
movq 24(%rax),%rcx
call FPDBGCLASSES$_$TDBGPROCESS_$__$$_GETDISASSEMBLER$$TDBGASMDECODER
movq %rax,%rbx
movq -24(%rbp),%rax
movq 16(%rax),%rdi
movq -24(%rbp),%rax
movq 16(%rax),%rsi
testq %rsi,%rsi
jne .Lj1675
movl $210,%ecx
call fpc_handleerror
.Lj1675:
movq (%rsi),%rsi
movq %rsi,%rcx
call fpc_check_object
movq %rdi,%rcx
call *248(%rsi)
movq %rax,%rsi
movq %rbx,%rdi
movq %rbx,%r12
testq %r12,%r12
jne .Lj1678
movl $210,%ecx
call fpc_handleerror
.Lj1678:
movq (%r12),%r12
movq %r12,%rcx
call fpc_check_object
movq %rdi,%rcx
movq %rsi,%rdx
call *256(%r12)
movq -24(%rbp),%rdx
movq %rax,40(%rdx)
movq -24(%rbp),%rax
movq 40(%rax),%rcx
movq $0,%r8
movq $0,%rdx
call
LAZCLASSES$_$TREFCOUNTEDOBJECT_$__$$_ADDREFERENCE$POINTER$ANSISTRING
.Lj1664:
movq -24(%rbp),%rax
movq 40(%rax),%rbx
movq %rbx,%rsi
movq %rbx,%rdi
testq %rdi,%rdi
jne .Lj1689
movl $210,%ecx
call fpc_handleerror
.Lj1689:
movq (%rdi),%rdi
movq %rdi,%rcx
call fpc_check_object
movq %rsi,%rcx
call *224(%rdi)
testb %al,%al
jne .Lj1657
jmp .Lj1659
.Lj1659:
movq -24(%rbp),%rax
cmpq $0,40(%rax)
je .Lj1693
jmp .Lj1694
.Lj1693:
movq -24(%rbp),%rax
movq 24(%rax),%rcx
call FPDBGCLASSES$_$TDBGPROCESS_$__$$_GETDISASSEMBLER$$TDBGASMDECODER
movq %rax,%rbx
movq -24(%rbp),%rax
movq 16(%rax),%rdi
movq -24(%rbp),%rax
movq 16(%rax),%rsi
testq %rsi,%rsi
jne .Lj1705
movl $210,%ecx
call fpc_handleerror
.Lj1705:
movq (%rsi),%rsi
movq %rsi,%rcx
call fpc_check_object
movq %rdi,%rcx
call *248(%rsi)
movq %rax,%rsi
movq %rbx,%rdi
movq %rbx,%r12
testq %r12,%r12
jne .Lj1708
movl $210,%ecx
call fpc_handleerror
.Lj1708:
movq (%r12),%r12
movq %r12,%rcx
call fpc_check_object
movq %rdi,%rcx
movq %rsi,%rdx
call *256(%r12)
movq -24(%rbp),%rdx
movq %rax,40(%rdx)
movq -24(%rbp),%rax
movq 40(%rax),%rcx
movq $0,%r8
movq $0,%rdx
call
LAZCLASSES$_$TREFCOUNTEDOBJECT_$__$$_ADDREFERENCE$POINTER$ANSISTRING
.Lj1694:
movq -24(%rbp),%rax
movq 40(%rax),%rbx
movq %rbx,%rsi
movq %rbx,%rdi
testq %rdi,%rdi
jne .Lj1719
movl $210,%ecx
call fpc_handleerror
.Lj1719:
movq (%rdi),%rdi
movq %rdi,%rcx
call fpc_check_object
movq %rsi,%rcx
call *240(%rdi)
testb %al,%al
jne .Lj1657
jmp .Lj1658
.Lj1657:
.Ll392:
# [814] SetReturnAdressBreakpoint(AProcess, False);
movq -8(%rbp),%rdx
movq -24(%rbp),%rcx
movl $0,%r8d
call
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_SETRETURNADRESSBREAKPOINT$TDBGPROCESS$BOOLEAN
jmp .Lj1726
.Lj1658:
.Ll393:
# [817] if NextInstruction.IsReturnInstruction then // asm "ret"
// 1
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
movq -24(%rbp),%rax
cmpq $0,40(%rax)
je .Lj1732
jmp .Lj1733
.Lj1732:
movq -24(%rbp),%rax
movq 24(%rax),%rcx
call FPDBGCLASSES$_$TDBGPROCESS_$__$$_GETDISASSEMBLER$$TDBGASMDECODER
movq %rax,%rbx
movq -24(%rbp),%rax
movq 16(%rax),%rdi
movq -24(%rbp),%rax
movq 16(%rax),%rsi
testq %rsi,%rsi
jne .Lj1744
movl $210,%ecx
call fpc_handleerror
.Lj1744:
movq (%rsi),%rsi
movq %rsi,%rcx
call fpc_check_object
movq %rdi,%rcx
call *248(%rsi)
movq %rax,%rsi
movq %rbx,%rdi
movq %rbx,%r12
testq %r12,%r12
jne .Lj1747
movl $210,%ecx
call fpc_handleerror
.Lj1747:
movq (%r12),%r12
movq %r12,%rcx
call fpc_check_object
movq %rdi,%rcx
movq %rsi,%rdx
call *256(%r12)
movq -24(%rbp),%rdx
movq %rax,40(%rdx)
movq -24(%rbp),%rax
movq 40(%rax),%rcx
movq $0,%r8
movq $0,%rdx
call
LAZCLASSES$_$TREFCOUNTEDOBJECT_$__$$_ADDREFERENCE$POINTER$ANSISTRING
.Lj1733:
movq -24(%rbp),%rax
movq 40(%rax),%rbx
movq %rbx,%rsi
movq %rbx,%rdi
testq %rdi,%rdi
jne .Lj1758
movl $210,%ecx
call fpc_handleerror
.Lj1758:
movq (%rdi),%rdi
movq %rdi,%rcx
call fpc_check_object
movq %rsi,%rcx
call *232(%rdi)
testb %al,%al
jne .Lj1727
jmp .Lj1728 // 2
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.Lj1727:
.Ll394:
# [819] FStepCount := MaxInt; // Do one more single-step, and we're
finished.
movq -24(%rbp),%rax
movl $2147483647,136(%rax)
.Ll395:
# [820] FProcess.Continue(FProcess, FThread, True);
movq -24(%rbp),%rax
movq 16(%rax),%r13
movq -24(%rbp),%rax
movq 24(%rax),%r12
movq -24(%rbp),%rax
movq 24(%rax),%rdi
movl $1,%esi
movq -24(%rbp),%rax
movq 24(%rax),%rbx
testq %rbx,%rbx
jne .Lj1769
movl $210,%ecx
call fpc_handleerror
.Lj1769:
movq (%rbx),%rbx
movq %rbx,%rcx
call fpc_check_object
movl %esi,%r9d
movq %rdi,%rcx
movq %r12,%rdx
movq %r13,%r8
call *400(%rbx)
.Ll396:
# [821] exit;
jmp .Lj1611
.Lj1728: // 3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.Lj1726:
jmp .Lj1770 // 4
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
.Lj1652:
.Ll397:
# [827] SetReturnAdressBreakpoint(AProcess, False);
movq -8(%rbp),%rdx
movq -24(%rbp),%rcx
movl $0,%r8d
call
FPDBGCONTROLLER$_$TDBGCONTROLLERSTEPOUTCMD_$__$$_SETRETURNADRESSBREAKPOINT$TDBGPROCESS$BOOLEAN
.Lj1770:
.Lj1650:
.Lj1637:
.Lj1635:
.Lj1628:
.Ll398:
# [832] FProcess.Continue(FProcess, FThread, FHiddenBreakpoint = nil);
movq -24(%rbp),%rax
cmpq $0,72(%rax)
seteb %bl
movzbl %bl,%ebx
movq -24(%rbp),%rax
movq 16(%rax),%r13
movq -24(%rbp),%rax
movq 24(%rax),%r12
movq -24(%rbp),%rax
movq 24(%rax),%rdi
movq -24(%rbp),%rax
movq 24(%rax),%rsi
testq %rsi,%rsi
jne .Lj1785
movl $210,%ecx
call fpc_handleerror
.Lj1785:
movq (%rsi),%rsi
movq %rsi,%rcx
call fpc_check_object
movq %rdi,%rcx
movq %r12,%rdx
movq %r13,%r8
movl %ebx,%r9d
call *400(%rsi)
.Lj1611:
.Ll399:
# [833] end;
movq -72(%rbp),%rbx
movq -64(%rbp),%rdi
movq -56(%rbp),%rsi
movq -48(%rbp),%r12
movq -40(%rbp),%r13
leaq (%rbp),%rsp
popq %rbp
ret
.seh_endproc
.Lc207:
.Lt73:
.Ll400:
# [820:44]
.byte 2
.uleb128 .Ll395-.Ll394
.byte 5
.uleb128 44
.byte 13
# [821:9]
.byte 2
.uleb128 .Ll396-.Ll395 // Ll396 is the label before the "exit"
.byte 5
.uleb128 9
.byte 13
# [827:7]
.byte 2
.uleb128 .Ll397-.Ll396 // and line info for it goes up to Ll397
which is the first statement in the following "else" block
.byte 5
.uleb128 7
.byte 18
# [832:40]
More information about the fpc-devel
mailing list