Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Opt.out mean?

Looking at the call stack I just noticed this:

enter image description here

Notice the Opt.out at the top.

Just curious, what does Opt.out mean?

Here's the snippet that I'm stepping through:

function BinaryEquals(Left, Right: pointer; Size: integer): boolean;
....
{$IFDEF CPUX64}
asm
 ....
  sub r8,4
@loop1:
  inc  R8
like image 241
Johan Avatar asked Jun 24 '15 09:06

Johan


1 Answers

I'm not sure what the mnemonic means, but what the call stack is telling you is that it cannot reliably report the value of the arguments.

Consider this program:

procedure Foo(Bar: Pointer);
asm
  xor eax,eax
end;

begin
  Foo(nil);
end.

Step into Foo. When you do so the call stack looks like this in 32 bit:

Project1.Foo(nil)
Project1.Project1
:76f5337a kernel32.BaseThreadInitThunk + 0x12
:775b92e2 ntdll.RtlInitializeExceptionChain + 0x63
:775b92b5 ntdll.RtlInitializeExceptionChain + 0x36

and this in 64 bit:

Project1.Foo(nil)
Project1.Project1
:00000000772959CD ; C:\Windows\system32\kernel32.dll
:00000000773CB981 ; ntdll.dll

Then step over the first line of Foo. Now the call stack looks like this for in 32 bit:

Project1.Foo(???)
Project1.Project1
:76f5337a kernel32.BaseThreadInitThunk + 0x12
:775b92e2 ntdll.RtlInitializeExceptionChain + 0x63
:775b92b5 ntdll.RtlInitializeExceptionChain + 0x36

and this in 64 bit:

Project1.Foo(Opt.out)
Project1.Project1
:00000000772959CD ; C:\Windows\system32\kernel32.dll
:00000000773CB981 ; ntdll.dll

What the debugger is telling you is that the arguments arrived in registers. It has no control over what you do with registers once the body of the asm function is executed. And so it declines to attempt to report argument values.

If you switch to the 32 bit compiler, and change calling convention so that the arguments arrive on the stack rather than in registers, then the behaviour is different. In that scenario the debugger feels confident to report argument values because it believes that you are not going to trash the stack.

In 32 bit that is made clear by the using of ???. Quite why the text Opt.out is used in 64 bit I don't know, but the meaning of it is clear.

like image 83
David Heffernan Avatar answered Sep 23 '22 17:09

David Heffernan