Debugger problem

As I was testing the information in Watch returns the function value only from another unit I had come across a problem with using Debugger, specifically with the Trace Into option.

A) Use the following script in IDE Demo.
If you were to Click on the Trace Into button. It will start the Running of the script and stop at line 8. If you were to click on the Trace Into button 4 more times. It would trace into the _2Text function return to the Main procedure and exit out of the script. From beginning to end you should have clicked on the Trace Into button 5 times.

This is Normal, and expected, behavior.

Unit1:

  function _2Text: string;
  begin
    Result := 'text';
  end;

          
begin 
  _2Text;
end;

B) Using the following two Unit script in IDE Demo.
With this script the normal expected behavior of using the Trace Into button. Should be the exact same as the example A above. Except that it should trace into the Text function in Unit2.

  1. The debugger should go to line 5 of Unit1.
  2. Then Line 3 of Unit2.
  3. Then Line 4 of Unit2.
  4. Then Line 6 of Unit1
  5. Then exit the script.

But the problem is, you end up clicking on the Trace Into button 14 times. The process is as follows:

  1. Debugger goes to Line 4 of Unit1.
  2. Then Line 3 of Unit2.
  3. Then Line 4 of Unit2.
  4. Then Line 1 of Unit2.
  5. Then Line 3 of Unit2.
  6. Then Line 4 of Unit2.
  7. Then Line 3 of Unit2.
  8. Then Line 4 of Unit2.
  9. Then Line 3 of Unit2.
  10. Then Line 4 of Unit2.
  11. Then Line 1 of Unit2.
  12. Then Line 3 of Unit2.
  13. Then Line 4 of Unit2.
  14. Then returns to Unit1 as the script ends.

This is not Normal, or expected, behavior.

Unit1:

uses    
  Unit2;
  
begin
  Text;
end;

Unit2:

function Text: string
begin
  Result := 'test';
end;

C) Now if you use the following two Unit script in the IDE Demo. This is a combining of the two previous scripts.

Now, with this script. The normal expected behavior. Is that you should only need to click on the Trace Into button 8 times. And it should trace into the Main procedure, the _2Text function, the Text function, and then exit the script. But, that is not the case. What ends up happening is the following:

  1. Goes to line 3 of Unit2.
  2. thru 27. Cycles through the Text function in Unit2. Just like in Example B above.
  3. Returns to Unit1 where the script ends.

This is not normal, or expected, behavior.

Unit1:

uses     
  Unit2;

  function _2Text: string
  begin
    Result := 'text';
  end;
begin
  _2Text;
  Text;
end;

Unit2:

function Text: string
begin
  Result := 'test';
end;

D) Now use the following two Unit script in IDE Demo.
With the following script, you end up clicking on the Trace Into button 20 times. With the following results:

  1. Goes to Line 8 in Unit2.
  2. Goes to Line 9 in Unit2.
  3. Goes to Line 1 in Unit2.
  4. Goes to Line 8 in Unit2.
  5. Goes to Line 9 in Unit2.
  6. Goes to Line 3 in Unit2.
  7. Goes to Line 4 in Unit2.
  8. thru 19 cycles through the Text function in Unit2.
  9. Returns to Unit1 where the script ends.

Again, This is not normal, or expected, behavior.

Unit1:

uses   
  Unit2;
  
begin
  _2Text;
  Text;
end;

Unit2:

function _2Text: string;
begin
  Result := 'test';
end;

function Text: string;
begin
  Result := 'test';
end;

The expected behavior for C and D above. Is that the debugger should Trace into the Main procedure. Trace Into _2Text function, then return to the Main procedure. Trace into the Text procedure. And then finally return to the Main procedure before the script ends. It should not matter what units the functions are in.

1 Like

Support replied that it is impossible to use Watch for a function from the same unit. But this is very strange...

@Hagin_Michael: Sorry, but I cannot reproduce your issues. F7 (Trace Into) works fine here in all the described situations.

I confirm the tests. The debugger executes the code multiple times as shown @Hagin_Michael.

Maybe I'm doing the tests wrongly then. I just run ScriptProIDE project, copy/paste the mentioned scripts, press F7 multiple times and it goes well.
Do you have a video showing the problem, maybe there is a slightly difference between your tests and mine?

Wagner, I think you need to add Watch for correspondent functions in test. Without Watch everything works fine.

Which watch? That is not even mentioned in the original post.

Ok, I'll show you what I mean in the video. In the video, I repeatedly press F7, but the function value is not evaluated.

Video_2021-02-18_222230.zip (1.3 MB)

@wlandgraf After seeing your response. I went and tested the my original scripts provided. And Yes, you are correct the debugger works as indented.

What I had failed to mention in my OP, was that you need to create a Watch.

  1. For Example A: _2Text
  2. For Example B: Text
  3. For Example C & D: _2Text and/or Text

And it is after you have created the watch(s) that the problem that I mentioned occurs. I had not mentioned it at that time. Because I did not believe it was part of the problem.

I understand that the Watch function is not supposed to work with functions, based on what you had stated in the other thread. But, if a person was to create a watch on a function. Then the above Debugger issues shows up.

1 Like

Thank you both, but ok, that's a misuse. You should not use functions in watches.