Author Topic: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩  (Read 41751 times)

0 Members and 1 Guest are viewing this topic.

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Just a thought here.  Not sure if it's planned but what would be useful would be breaking on a variable/value is met.  Let's say you have a string or variable that is being changed (badly).  But you have multiple processes in your program that changes the variable.  A automatic break on a match would be more helpful that breakpoints.  Especially if the process run's through 100's of time before the condition is met.

I always found that type of break point very helpful.  Very, very helpful when the O/S you are working on has over 100k pages of code.  Locating that buffer overrun or memory fragmentation problem.  This break point tool is more of a big boy power tool, but who said we can't have it too.  I have used it a lot with Intel I.C.E. equipment.  It has saved the companies butt a number of time as well.

FellippeHeitor

  • Guest
Yes, the feature is being considered 🤗

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #62 on: September 01, 2021, 10:56:33 am »
Hi Fell... is there a way to incorporate a Timing in Debug? I was thinking some of my arrays may work better in a different looping routine. Or perhaps a different order of calculations. Debug lets me run to a particular line of code and I was thinking it would be handy to see the time run of an array along with the value changes.

FellippeHeitor

  • Guest
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #63 on: September 01, 2021, 11:09:32 am »
I don't think I understand the request.

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #64 on: September 01, 2021, 11:54:14 am »
I don't think I understand the request.

Guess he talks about a profiler, a tool to measure the runtime of a loop or how long a function call needs to complete. All that to identify bottlenecks in the code.

However, guess the debugging mode itself will compromise such a tool.
« Last Edit: September 01, 2021, 11:56:30 am by RhoSigma »
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #65 on: September 01, 2021, 01:07:32 pm »
One of the things I'm finding with my code is the time it takes to run through to the end of the program. I do have a Timing Routine which tells me if the total time to run the program is 1 hour or 1/2 hour or 20 minutes. It is this gage which has me going back to find ways of doing things which accomplish the correct values in a shorter period of time. Often times it's a hit and miss in re-working the code for speed improvement.

It occurred to me while observing the Watch List, that if I could let the program do a complete run through and the Watch List could display the total amount of time for Watched Array to come up with it's final value, then this could help me zero in on specific areas of my coding dealing those array taking an inordinate amount of time to complete their task.

I have so many arrays it's just doesn't seem that I can time each one individually. Your excellent Watch List has the array values updating fairly quickly and I was wondering if some kind of timing mechanism could run along side those updating values. Pausing and restarting the run time I think would be difficult. And perhaps this type of feature may not be useful for others or fall within the scope of "debugging".

I guess you just can't give a kid a toy train and not expect him to fly it like an airplane.

FellippeHeitor

  • Guest
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #66 on: September 01, 2021, 01:14:43 pm »
Quote
I guess you just can't give a kid a toy train and not expect him to fly it like an airplane.

🤣
Love the analogy.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #67 on: September 02, 2021, 10:48:55 am »
Seems I'm now having some problems with "Run to this Line".

In Debug options, I select the Watch List, highlight the variables to watch (note: Not arrays). I then place the focus back on the IDE. A couple of weeks ago I was able to then "Start Paused", then locate and select a line where I selected "Run to This Line". I hit run (F5), program stopped at the selected line and I was then able to "Step Into" (F7) and watch the Watch List selections change values as I stepped thru the program from there on.

Today for some reason the program runs to the selected "Run to this Line", the cursor winds up in the Watch List and everything seems to freeze up. Once again I also have the same "old" problem with trying to display the IDE screen and the watch list screen at the same time.

So am I not using the "Run to this Line" properly?? If so what would be the correct order of steps I should take?

The "about" indicates I'm using the e1c148a build.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #68 on: September 02, 2021, 11:08:48 am »
Oh, I forgot to ask. At the end of the run of a some code, where does the Watch List go? It seems to be displayed with the IDE screen during the debugging session. At the end of run of code I do get the Output screen and when I close out of it the IDE with the coding is displayed but not the watch list carrying the final results of the variable/array values. The status window indicates the debug session aborted - Disconnected. Is the Watch List wiped out or is it still available somewhere like the IDE and Output Screen?


FellippeHeitor

  • Guest
It might be a matter of adjusting expectations.

F7 or F8 will start your $DEBUG-enabled program in pause mode.

While in pause mode, you can right-click a line and choose "Run To This Line". Doing so is equivalent to (1) setting a breakpoint to a line, (2) hitting F5 to run, (3) removing the breakpoint once the line is reached.

Even before execution starts you can set breakpoints to lines of interest, so when you start it, even if with F5, execution will halt at the lines you set.

The Watch Panel will only show up during execution, as long as you'd selected some variables in the Watch List dialog (F4). When execution is done with ("Debug session aborted/Disconnected"), the list of values is also gone. What remains is the last stack call list (accessible via F12) and the breakpoints you'd set before.

I'll repeat my suggestion from the other day, that you should place a breakpoint on the last line of your program so it'll pause before it ends and you can inspect your variables' values before all's gone.
« Last Edit: September 02, 2021, 10:47:08 pm by FellippeHeitor »

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #70 on: September 03, 2021, 09:55:10 am »
I have printed a copy of your reply #69 and have taped it to the left of my computer screen with the heading "A Train is just a Train". Thanks Fell

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #71 on: September 03, 2021, 11:11:19 am »
Seems it wasn't just that Run to Line but none of the breakpoints are being respected. I have two breakpoints, one before a major loop to check values before the looping. The line number does light up in red on the far left of the screen. The second set just before the first subroutine which I believe is the last line of the program run. Again the breakpoint line number lights up in red.

Without using Debug, I just run the program, neither one of the breakpoints hold. The program runs to the end.

Next time, I set the same two breakpoints but this time I engage Debug option and start paused, then F5. Again the program runs right through those breakpoints to the end and Debug Session Aborted/Disconnected.

Third time, set same break points, from Debug option select Start Paused. Focus goes to IDE and I can then right click and have an option that says "continue" so rather than F5 I select "Continue" . Again program runs to the end without respecting the breakpoints.

In all 3 test runs I have selected the same couple of variables for the Watch List.

So seems I can't set the break points either before or within Debug. It's got to be me, not sure what I'm doing wrong.

FellippeHeitor

  • Guest
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #72 on: September 03, 2021, 12:11:49 pm »
Send me the file and indicate which lines you’re setting breakpoints to, please.

Do you happen to have $checking:off anywhere?

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #73 on: September 03, 2021, 02:00:02 pm »
Not I do not have $checking:off anywhere

Here is the code I'm running while testing Debug. Actually the only thing I have changed here is the Read/Data. I'm actually using an Open statement which is opening 50 files each with over 3000 items of data. The data with this snippet of code is the first 50 or so items from Event #1 file.

This code is behaving as I described earlier in not recognizing the Breaks Points at line 50 and line 160.
 

FellippeHeitor

  • Guest
Re: [dev build] $DEBUG mode ✨ Step through your code, watch variables! 🤩
« Reply #74 on: September 03, 2021, 02:28:58 pm »
Both lines are empty, good friend. Set breakpoints to lines with actual code.