Jump to content
FredS

Debugging Inline Variables in 10.3.2

Recommended Posts

Today was my first attempt to actually use these, but that ended once I placed a Breakpoint on one.

 

Perhaps not news to others..

 

program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils;

{$INLINE OFF}

function NewBytes:TBytes;
begin
  SetLength(Result, 10);
end;

begin
  try
    /// <summary>
    ///   F9 from the Breakpoint will repeat 3 times, once for each Inline Variable
    ///   Uncomment the others to prove my point
    /// </summary>
    /// <remarks>
    ///   You can also try F7 or F8
    /// </remarks>
    var Eins := NewBytes;  // << Breakpoint
    var Zwei := NewBytes;
    var Drei := NewBytes;

//    var NochEins := NewBytes;
//    var NochZwei := NewBytes;
//    var NochDrei := NewBytes;

    writeln('Something Happened!');
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

 

Share this post


Link to post
2 minutes ago, FredS said:

Today was my first attempt to actually use these, but that ended once I placed a Breakpoint on one.

For those of us that don't use this feature yet - what happened?

Share this post


Link to post
27 minutes ago, FredS said:

Today was my first attempt to actually use these, but that ended once I placed a Breakpoint on one.

 

Perhaps not news to others..

 


program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils;

{$INLINE OFF}

function NewBytes:TBytes;
begin
  SetLength(Result, 10);
end;

begin
  try
    /// <summary>
    ///   F9 from the Breakpoint will repeat 3 times, once for each Inline Variable
    ///   Uncomment the others to prove my point
    /// </summary>
    /// <remarks>
    ///   You can also try F7 or F8
    /// </remarks>
    var Eins := NewBytes;  // << Breakpoint
    var Zwei := NewBytes;
    var Drei := NewBytes;

//    var NochEins := NewBytes;
//    var NochZwei := NewBytes;
//    var NochDrei := NewBytes;

    writeln('Something Happened!');
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

 

I'm surprised that you can even set a breakpoint on a variable declaration. Makes no sense in my opinion.  Could you please run to the breakpoint and switch to the CPU disassembly view to see what statement the breakpoint is actually on? I have not been able to install 10.3.2 myself yet due to trouble with the licence, so cannot test that myself.

Share this post


Link to post
35 minutes ago, Remy Lebeau said:

what happened

F9 stops at the line with the breakpoint as many times as there are inline variable declarations.

 

Share this post


Link to post
7 minutes ago, PeterBelow said:

Makes no sense in my opinion.

The inline variable is initialized by the return value of the function. Now if they function is in another unit how do you debug it?

 

Share this post


Link to post
9 minutes ago, PeterBelow said:

what statement the breakpoint is actually on

Project1.dpr.25: var Eins := NewBytes;  // Put a Breakpoint
0041E5AD 33C0             xor eax,eax
0041E5AF A3DC684200       mov [$004268dc],eax
0041E5B4 33C0             xor eax,eax
0041E5B6 55               push ebp
0041E5B7 68BEE64100       push $0041e6be
0041E5BC 64FF30           push dword ptr fs:[eax]
0041E5BF 648920           mov fs:[eax],esp

 

Share this post


Link to post

I see this many times I put a breakpoint into a line with an inline variable declaration - it looks like some debug symbol issue so the breakpoint is not set into the proper instructions but into the prologue code the inline declaration brings with it.

This can be very annoying and confusing indeed.

  • Like 1

Share this post


Link to post
4 hours ago, Stefan Glienke said:

I see this many times I put a breakpoint into a line with an inline variable declaration - it looks like some debug symbol issue so the breakpoint is not set into the proper instructions but into the prologue code the inline declaration brings with it.

This can be very annoying and confusing indeed.

Well, the cure is simple: do not use inline variables 😉. They are alien to the language anyway and serve no real purpose IMNSHO...

  • Like 3

Share this post


Link to post
8 minutes ago, PeterBelow said:

They are alien to the language anyway and serve no real purpose IMNSHO...

I disagree but I am not going into yet another discussion about this.

  • Like 3

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×