Recent

Author Topic: F4 - Run to cursor  (Read 11754 times)

BLL

  • Sr. Member
  • ****
  • Posts: 276
F4 - Run to cursor
« on: June 25, 2016, 11:42:35 am »
Hi, Can anyone help?
I have come to lazarus from CBuilder. One of the debugging options I find very useful is the run to cursor, but it is always greyed out and therefore not available.
Why please?
Brian

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: F4 - Run to cursor
« Reply #1 on: June 25, 2016, 12:12:05 pm »
Yeah, that's also something I needed to get used to.
F4 only works within the procedure you are at that moment.
It doesn't work like in Delphi.

The workaround is... you go to the place where you want to go.
But you don't press F4 but F5 and press F9 (run).
F5 sets a breakpoint.
When the program breaks you directly press F5 again and the breakpoint is released.

It would be neat if Lazarus could implement that F5, F9 & F5 under the F4 button :)
(But for now you can do it that way)
« Last Edit: June 25, 2016, 12:13:51 pm by rvk »

BLL

  • Sr. Member
  • ****
  • Posts: 276
Re: F4 - Run to cursor
« Reply #2 on: June 25, 2016, 06:48:13 pm »
Hi, Thanks for the info. If it's that badly implemented, F4 shouldn't be there!

I also don't understand why compile, make and build are on the Run menu!

If you are going to run a programme, it must be built first! In CBuilder, these items were on the Project menu, which, I think, makes much more sense. You build a project and then you run it!

Brian

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9877
  • Debugger - SynEdit - and more
    • wiki
Re: F4 - Run to cursor
« Reply #3 on: June 25, 2016, 08:42:13 pm »
It is not badly implemented, it implements a different function. It is "step to cursor"

http://bugs.freepascal.org/view.php?id=21958#c59370

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: F4 - Run to cursor
« Reply #4 on: June 25, 2016, 08:53:28 pm »
It is not badly implemented, it implements a different function. It is "step to cursor"
Well, it doesn't say "Step to Cursor (F4)" but it says "Run to Cursor (F4)". And because the naming in Delphi is exactly the same it confuses the hell out of people just beginning with Lazarus :)

Luckily I learned quit quickly to use the F5 for breakpoint but seeing that different function uses the same name and even the same function key as Delphi, I can understand the confusion.

BLL

  • Sr. Member
  • ****
  • Posts: 276
Re: F4 - Run to cursor
« Reply #5 on: June 25, 2016, 09:34:15 pm »
I don't follow your logic! Run to cursor means run the program until it reaches the point where you have put the cursor. Of course you can set a breakpoint, but surely, the whole idea of F4 was to be quicker. Otherwise, you need 2 steps - 1 set breakpoint, 2 run program!
CBuilder had it right, lazarus, in my opinion does not!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9877
  • Debugger - SynEdit - and more
    • wiki
Re: F4 - Run to cursor
« Reply #6 on: June 25, 2016, 10:30:52 pm »
Yes, it is currently wrongly named.

Lazarus does not have "run to cursor" at all. It has a different function.

"step to cursor" can be useful too. So the function itself is not wrong, or bad, it is just a different one.

Both needs to be done:
- fix the name
- implement "run to c"

duzenko

  • New Member
  • *
  • Posts: 41
Re: F4 - Run to cursor
« Reply #7 on: August 30, 2019, 12:14:30 pm »
Nice to know that it's 2019 and still no Run to Cursor

RuudB

  • New Member
  • *
  • Posts: 37
Re: F4 - Run to cursor
« Reply #8 on: April 19, 2020, 02:41:42 pm »
It does work, but..... not the first time. The very first time you have to use the F5/F9 combination and then you can use F4. But I wonder as well why it cannot be used the first time.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9877
  • Debugger - SynEdit - and more
    • wiki
Re: F4 - Run to cursor
« Reply #9 on: April 19, 2020, 02:56:45 pm »
Because it is a "step over" variant.

Code: Pascal  [Select][+][-]
  1. procedure Foo(i : integer);
  2. begin
  3.   if i > 10 then exit
  4.   DoBefore(1);
  5.   DoFoo(i+1);
  6.   DoAfter;
  7. end;

Say you are on "DoBefore" and i = 1.
You want [1] to "Step over to cursor" to "DoAfter".

Then the line DoAfter is executed with i = 3,4,5 to 10.

But "Step over" does not "step in" => so you should expect to stop at "DoAfter" when i=1, and only then.
I.e. you only stop at the target line, if you reach the target line in the very same stack-frame in which you started.

- Any hit of the line, while in a deeper stack frame is skipped
- Exiting the current stack frame, will enter pause (break)

This is what gdb provides under that name. That is were the idea came from.

If you have not started the app yet, then all code is in "deeper stack frames", and can not be reached by "step over to cursor"


You want a completely new command. (a reasonable one, yes)

But no one had yet time to implement it.

As for me (I do a lot of the work on the debugger), I simple have tons of other todo items, that are all at a higher priority.


[1] Well, you do want something else, but this is what it is designed for at current
« Last Edit: April 19, 2020, 03:00:33 pm by Martin_fr »

duzenko

  • New Member
  • *
  • Posts: 41
Re: F4 - Run to cursor
« Reply #10 on: January 09, 2022, 11:01:11 am »
Happy 2022 everyone
I can see F4 run to cursor in the menu but it's greyed out unless the app already runs and is paused in debugger?
« Last Edit: January 09, 2022, 11:14:46 am by duzenko »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9877
  • Debugger - SynEdit - and more
    • wiki
Re: F4 - Run to cursor
« Reply #11 on: January 09, 2022, 11:11:11 am »
Happy 2022 everyone
Just the right topic for some brighter outlook.

Because
Nice to know that it's 2019 and still no Run to Cursor

2022 and we do have "Run to Cursor".
At least when using FpDebug. (IIRC, not yet ported to the gdb/lldb based debuggers)

Mind:
- This is a new command, you need to change your keyboard mapping, if you want that with F4.
  The default for F4 is still "Step to cursor", with the old behaviour.
- FpDebug only stops on lines with code (blue dots). "Run to cursor" to any other line, will never reach that line (nor will it stop at the next / but that will be added in future)
- This may only work, once the app has been started with F9. (not sure, if it can be used to launch the app, and run to line...). So maybe not perfect, but one step at a time.

https://wiki.lazarus.freepascal.org/Debugger_Status
« Last Edit: January 09, 2022, 11:14:44 am by Martin_fr »

duzenko

  • New Member
  • *
  • Posts: 41
Re: F4 - Run to cursor
« Reply #12 on: January 09, 2022, 11:24:08 am »
Exciting! How do I remap F4 to that new menu item? Can't see the key settings in UI anywhere

duzenko

  • New Member
  • *
  • Posts: 41
Re: F4 - Run to cursor
« Reply #13 on: January 09, 2022, 11:30:33 am »
Found in Tools Options Editor Key mappings
Now we're talking  8-)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9877
  • Debugger - SynEdit - and more
    • wiki
Re: F4 - Run to cursor
« Reply #14 on: January 09, 2022, 11:42:48 am »
Menu: Tools > Options >> Editor > "Key Mappings"

Filter for "run".
The entry is in the section "Run menu commands", it is called "Run to cursor" (just below the entry "Step over to cursor").
Double click the entry, assign a key.
If you assign "F4" it will ask if you want to remove it from the existing command.


And I just checked.

In FpDebug, it can be used to launch the app.
So you can place the cursor somewhere in your code (e.g., Button1Pressed), and press "F4". And if that line is not empty (i.e. if it gets a blue dot, after launch), then the debugger will stop there.

Of course, if you hit a breakpoint, or your app gets paused in the debugger for other reasons, then the "F4" location is no longer a target. But you can of course go to this line again, and use "F4" again.

I also checked the gdb based debugger. And "Run to cursor" works too.

 

TinyPortal © 2005-2018