Recent

Author Topic: Debugger "step over" jumps up and down  (Read 305 times)

Markus

  • Newbie
  • Posts: 3
Debugger "step over" jumps up and down
« on: September 03, 2020, 11:40:23 am »
I am using Lazarus 2.0.10 with Win7-64bit.

Debugging the code with F8 to step over within a with object do begin ... end section, the active line jumps up and down with every F8-press.

If I want to step over a procedure call with 6 arguments belonging to the object above, the debugger jumps 6 times up to the "with line" and down to the procedure call before it steps over it.

Can this annoying behaviour be switched off?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6600
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger "step over" jumps up and down
« Reply #1 on: September 03, 2020, 11:52:40 am »
This is how the FPC compiler writes the line info.

The "procedure with arguments" (where arguments are each on a line of its own) are sometimes useful.
Arguments can themself be function results, and you may or may not want to enter those functions.

As for "with" or more generic begin/end, this represent internals of the compiler. So it is not very useful, imho. But there is no switch.
I don't know how much work it be to fix that. Needs to be answered by the FPC team.

As long as your target line is within the same function as you currently are in, then you can use "step over to cursor" (iirc F4).
Place the cursor where you want to stop, then F4.

Again: Only within the same function.

Lazarus trunk also has "run to cursor" that does not have the function bounds.
« Last Edit: September 03, 2020, 11:56:12 am by Martin_fr »

Markus

  • Newbie
  • Posts: 3
Re: Debugger "step over" jumps up and down
« Reply #2 on: September 03, 2020, 12:48:00 pm »
This is a pitty.

Apart from jumping up and down at procedure calls with several arguments, the main problem is that it jumps up and down at least once every line within the with object do begin ... end block.

But thanks for the idea with F4. Presently I am generating new breakpoints with mouse clicks, so F4 might be slightly faster.

I am not familiar with Sourceforge. Is there a simple way to contact the developers about that?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6600
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger "step over" jumps up and down
« Reply #3 on: September 03, 2020, 01:09:23 pm »
Some (not all) of the developers (both fpc and Lazarus) are here on the Forum..
Other ways to reach out are the mailing list.  (See forum menu on the left)


In the forum it's a matter of which board and the right Subject. I.e. "Compiler generated line info" vs "step over".
"step over" usually will attract me. Because it refers to the debugger site of things.


I admit it's hard to know what to ask for. Some topics (like the debugger) are complex that way, because internally the split into many different areas of responsibility. In the IDE they are (as much as possible) integrated as a single entity.

In general, debugging is line based (that contradicts the statement based Pascal a little). It would in theory be possible to change this, but in practice I can't see that happen anytime soon.
So that means "step over" will go line by line. Never statement by statement.

But that does not mean that a procedure's begin line should be entered more than once. (Or I have even found that the local "var" line is entered.


-O- / no optimization
I have made no direct comparison myself. And even with no optimizations, the described issues do happen.
I do not know if the degree to which they happen would change. (In case you use -O1)



Actually the multi param procedure call, ideally it should go (params are evaluated backwards)
Code: Pascal  [Select][+][-]
  1. foo( //  // stop this line 4th
  2.    arg1, // stop this line third
  3.    arg2, // stop this line second
  4.    arg3  // stop this line first
  5. );   // never stop here
But well...


The "begin" line of the procedure has another issue. Its called a "proloque" and during it's execution the program creates the space for local vars. That means when you are (the first time) at the start of the "begin" local vars do not exist yet.
Anything that the debugger tries to access when showing locals is invalid memory. (usually the debugger deals with this).
a) The compiler forgets to tell the debugger: https://bugs.freepascal.org/view.php?id=34995
b) if the compiler did tell the debugger, some debuggers (not all) could skip that line. (you never need to step to "begin" of procedure.) / Note that if the compiler added that, the debugger would still need to learn about it too.

Anyway that last bit are internals, that you do not need to know. I just thought to get you an insight into the fun behind the scenes.




« Last Edit: September 03, 2020, 01:45:23 pm by Martin_fr »

Markus

  • Newbie
  • Posts: 3
Re: Debugger "step over" jumps up and down
« Reply #4 on: September 03, 2020, 02:24:30 pm »
I hope to be correctly understood. No problem with "step over" going line by line.

The problem is this irritating up-and-down-jumping to the "with-line" and back. Sometimes i have a with opject do begin ... end section going over several screen pages. This means that the complete screen content is changing twice with each "step over" and I have to press F8 also twice per line.

I checked also different compiler options but it does not help. I never saw such a behaviour with Delphi.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6600
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger "step over" jumps up and down
« Reply #5 on: September 03, 2020, 02:44:45 pm »
Yes, I do understand about the up/down. I get the same.

Delphi is a compiler of its own. The behaviour is a result of the compiler used.

For each assembler statement that the compiler generates, the compiler leaves a note to the debugger, saying this is part of line nnn.
For some reason when writing code that is executed when entering a new function (begin), the compiler tells the debugger some of the assembler is part of the "end" line.
The debugger just follows that.
I.e. the debugger goes over the assembler until it finds a statement that has a different line number.

 

TinyPortal © 2005-2018