Debugger/stepping back thru handler/variable calls/values per run

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

mcelvain
Posts: 58
Joined: Sat Apr 29, 2023 10:13 pm

Debugger/stepping back thru handler/variable calls/values per run

Post by mcelvain » Tue Jun 20, 2023 12:23 am

SuperCard's debugger allowed us to "step back" in debugging mode through the list of handlers called; variables set.

Does LiveCode, as well ?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by mwieder » Tue Jun 20, 2023 1:19 am

Hmmm... been a while since I've used the built-in debugger, but I think it does.
PowerDebug, of course, allows you to step back through the execution contexts and see the variables.
I think there's a control in the built-in debugger to do that as well, but someone else will have to chime in with a definitive answer.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9751
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by dunbarx » Tue Jun 20, 2023 3:30 am

Hi.

I never heard of such a thing. Anyone?

Craig

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Apr 13, 2006 6:25 pm

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by rkriesel » Tue Jun 20, 2023 3:51 am

mwieder wrote:
Tue Jun 20, 2023 1:19 am
I think there's a control in the built-in debugger to do that as well, but someone else will have to chime in with a definitive answer.
When debugging, directly below the title bar of the script editor window, the seventh control from the left is the execution context menu. The script field and the variables pane respect the menu selection.
But actually stepping backwards, as far as I know, is only a dream, albeit a very pleasant one.
-- Dick

stam
Posts: 2756
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by stam » Tue Jun 20, 2023 7:14 am

rkriesel wrote:
Tue Jun 20, 2023 3:51 am
When debugging, directly below the title bar of the script editor window, the seventh control from the left is the execution context menu. The script field and the variables pane respect the menu selection.
I think that’s exactly what’s being asked for judging by the OP’s description. I, too, had missed that drop down menu for the longest time that lets you step up into calling handlers. Extremely useful and something one expects from a “proper” debugger.

I don’t think I’ve ever heard of a debugger that rewinds the code backwards, which is the other interpretation of the OP…

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9751
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by dunbarx » Tue Jun 20, 2023 2:51 pm

Stam.

I bet it is the rewinding that is asked for.

I also have never used that menu. :oops:

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7258
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by jacque » Tue Jun 20, 2023 4:53 pm

dunbarx wrote:
Tue Jun 20, 2023 2:51 pm
I also have never used that menu. :oops:
I use it a lot, it's very handy to see where a variable gets set or where the call came from.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by mwieder » Tue Jun 20, 2023 6:01 pm

Thanks, Dick. I thought I remembered it being in there somewhere.

I think I've only seen actual rewinding in one experimental java demonstration.
I did build it into PowerDebug some time back, but it's *so* intrusive to real-time code execution that I never released it - you end up with a virtual breakpoint at every line of code, taking a snapshot of the execution point and all the variables indexed by the time, and moving on to the next line. That allows you to work backwards through the accumulated snapshots, but the pain of accumulating the data way offset the advantage of being able to move back through the code execution.

mcelvain
Posts: 58
Joined: Sat Apr 29, 2023 10:13 pm

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by mcelvain » Tue Jun 20, 2023 9:35 pm

You are correct, was looking for rewind similar to what SuperCard’s debugger can do.

I assume the SC team considered the variable grid as a table, which was exported to a temporary recallable file each time any value was changed or handler passed.

Maybe these temp files were named using the ticks or something, and clicking the forward/backward arrow advanced/reversed through a directory list.

There was an “exit to script” button that would then trash the temp files perhaps.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by mwieder » Tue Jun 20, 2023 9:55 pm

I assume the SC team considered the variable grid as a table, which was exported to a temporary recallable file each time any value was changed or handler passed.
Don't know.
In LC as long as you're in active debug mode you can examine the variables at any point in the current context by

set the debugContext to <index into the executionContexts>
debugDo "get the variables"

The variables will be comma-delimited, with one type per line.
Then you can query for an individual variable value

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9751
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by dunbarx » Tue Jun 20, 2023 10:05 pm

Mark.

"deBugDo" sounds like a hair product. If I have:

Code: Select all

on mouseUp
   put random(99) into temp
  breakpoint
end mouseUp
and execute debugDo "temp", I get nothing. How does one use this?

And "debugContext" is yet one more of those undocumented words?

Craig

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Apr 13, 2006 6:25 pm

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by rkriesel » Wed Jun 21, 2023 12:08 am

mwieder wrote:
Tue Jun 20, 2023 9:55 pm
In LC as long as you're in active debug mode you can examine the variables at any point in the current context by

set the debugContext to <index into the executionContexts>
debugDo "get the variables"

The variables will be comma-delimited, with one type per line.
Then you can query for an individual variable value
With an "internal" that stores a complete copy of the user's variables tree, and another that reinstates it, debugging our algorithms could be simpler and faster. Is that right, Mark?
-- Dick

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by mwieder » Wed Jun 21, 2023 1:00 am

Possibly. It would take serious instrumentation of the execution machine. Changing the context is fast, but getting the variables list and getting the individual variable values requires runtime string evaluation. There's probably a way around that, but I'm not gonna hold my breath waiting for the team to implement it. Maybe monkeypatching the engine could work, but that's serious code injection.

stam
Posts: 2756
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by stam » Wed Jun 21, 2023 1:56 am

mcelvain wrote:
Tue Jun 20, 2023 9:35 pm
You are correct, was looking for rewind similar to what SuperCard’s debugger can do.
Probably safest to assume that many here don't know what the SuperCard debugger does ;)

Regardless, if I understood you correctly then you would also need an undo mechanism for the interface (to 'rewind' the outward effect of code as you would step backwards).

That would be a dealbreaker in the current IDE, as undo in the graphical interface is extremely limited (if you manage to delete a control, there is no undo from that and in general where undo does work in the interface it's only 1 step deep - as opposed to the script editor which has unlimited undo).

So it would take more than just creating steroid-infused debugger, you'd need to upgrade the IDE as well.
I'm gonna say that isn't going to happen any time soon.

Will LC consider implementing this? Who's to say - but there's the fact that other than SC, pretty much no other IDE offers this - meaning that the traditional step into/step over techniques work for pretty much everyone. If you have one handler calling anther then at any breakpoint you can change contexts from one handler to another with the dropdown menu at the top and instantly examine the variables used in each handler, either by hovering over the variable name in the script editor, or in the variable list.

I'm not sure I understand the real value of stepping backwards is personally, although I get that if you're used to a particular feature, you may miss it when it's not there...

Short answer: No you can't do this in LC and seems extremely unlikely this will be possible in the near future.
But there's nothing to stop you submitting an enhancement request with the team at https://quality.livecode.com, you never know...

regards,
S.

mcelvain
Posts: 58
Joined: Sat Apr 29, 2023 10:13 pm

Re: Debugger/stepping back thru handler/variable calls/values per run

Post by mcelvain » Thu Jun 22, 2023 10:48 pm

Thank-you for responding, S.

The LC debugger does have abilities SC debugger lacks, such as the ability to keep variable windows open through various runs of a given handler.

And its ability to manage simultaneous scripts is fantastic.

The stepping “into” and “over” seems identical to the SC debugger.

You’re correct that my question referred to applicability of SC habit.

My knowledge level of LC is still quite low; much to learn about various debuggers.

I appreciate your concise response.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”