dMZX Forums: How do you debug robotic? - dMZX Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How do you debug robotic? Share your prefered methods of finding and fixing bugs

#1 User is offline   Graham 

  • . "@Master Procrastinator"
  • PipPipPipPip
  • Group: Members
  • Posts: 625
  • Joined: 28-December 12
  • Gender:Male
  • Location:Oregon

Posted 09 July 2013 - 03:27 AM

I think my most common method as of now is to add numbered message lines around my programming. Around the spot the problem is persisting I'll add * "1", * "2", * "3" and so on in between the lines and run the program to watch where the numbers stop displaying. Then I'll study the code and look for spelling errors or expression syntax mistakes or reasons a label is not being called, etc. of course there are many variations of this method depending on the section of code it's being applied in, but that's the basic idea.

What are some of your methods for finding and fixing bugs? I may use some of the methods given in an upcoming tutorial I'm planning on doing on debugging. Plus you can help out some of the newer programmers out there.

Also you could help me, you see I'm trying to figure out a complex bug right now and my usual method isn't working out. So maybe a fresh idea will help me, thanks. :(
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...

"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
0

#2 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,936
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 09 July 2013 - 03:51 AM

I generally use counters and strings and the F11 menu to do debugging. I just set a bunch of debug counters and strings (typically with names preceded with underscores so they appear at the top) with whatever data I feel I might need and use that to try and work out what's going wrong.

This is partly because I'm often working in an area that makes stuff hard to trivially display on the screen and partly because I generally want to output a ton of information, more than could really be displayed on the message row. I can also export the counter set from the F11 menu and look at both my debug counters + strings and the actual counters + strings in a text editor while editing the suspect code, so I can attempt to work out the ways in which the current program state is inconsistent with what the code should be doing.

For particularly hardcore tasks I will sometimes write out logging data to a file; I'll typically have a log.txt that I erase at the start in the global robot:
set "log.txt" "fwrite_open"
set "" "fwrite_open

and then I'll just write out anything that happens to it with fwrite_append so I can close the file each time so that it doesn't interfere with any actual file writing my game might do:
set "log.txt" "fwrite_append"
set "$_dbg" "d &loopcount& &local2&\n"
set "$_dbg" "fwrite&$_dbg.length&"
set "" "fwrite_append"

I also tend to throw in the occasional assertion, although usually not too many because they take up space and can't be automatically removed in a trivial fashion. For me an assertion is usually something like:
if "(('local2'<0)o('local2'>150))" = 1 "wtf"

...
: "wtf"
ask "WTF"
end

if local2 will always be between 0 and 150. I tend to use the "wtf" label for all assertions, so this doesn't tell you which one triggered, but at least you know something is up and can dig into it later. The reason I use ask is because the 'ask' dialogue uses the protected palette and charset (or just charset in SMZX mode) so you can actually see the message. Not that it really matters because it's not a very descriptive message, but still!
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#3 User is offline   Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,895
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 09 July 2013 - 03:52 AM

I'd hold off a tutorial for debugging until the next MZX release. There will be a Robotic Debugger in 2.84d. It's even been in the latest GIT for months, it just can't be released until I write debytecode support for it (:
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository
0

#4 User is offline   Graham 

  • . "@Master Procrastinator"
  • PipPipPipPip
  • Group: Members
  • Posts: 625
  • Joined: 28-December 12
  • Gender:Male
  • Location:Oregon

Posted 09 July 2013 - 04:37 AM

Lachesis - That's good to know, thanks.
Lancer - That's useful, I've been thinking of creating a text log and seeing how you do it certainly helps, thanks a lot.
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...

"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
0

#5 User is offline   Graham 

  • . "@Master Procrastinator"
  • PipPipPipPip
  • Group: Members
  • Posts: 625
  • Joined: 28-December 12
  • Gender:Male
  • Location:Oregon

Posted 11 July 2013 - 06:17 AM

I forgot to mention another quick trick that I often use. If I need to keep an eye on the status of a counter, I'll add a robot to the board with a loop displaying the counter.
: "top
cycle 1
* "~f&counter&"
goto "top"

This way I can see how the robot controlling the counter is behaving. This is a real basic method though and I'm sure most everyone already does something similar to this.
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...

"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
0

#6 User is offline   Dr Lancer-X 

  • 電波、届いた?
  • Group: DigiStaff
  • Posts: 8,936
  • Joined: 20-March 02
  • Location:ur mom nmiaow

Posted 11 July 2013 - 06:53 AM

A similar trick I like to use is:

: "l"
set "time" "(60+'counter')"
cycle 1
goto "l"


The trick here is that the timer uses the protected charset and palette, so you can see it even if you're using those chars for non-number-related purposes! The 60+ is so you get 01:## where ## is your counter (up to 59)- if you just use 'counter' it could hit zero and the timer-running-out event will occur.
Posted Image
<Malwyn> Yes, yes. Don't worry I'd rather masturbate with broken glass than ask you for help again. :(
0

#7 User is offline   ThDPro 

  • Brontosaurus-Sea-slug; Gooey and phallic
  • PipPipPipPip
  • Group: Members
  • Posts: 718
  • Joined: 03-December 06
  • Gender:Male
  • Location:Portland, OR

Posted 11 July 2013 - 07:13 AM

I did a thing for awhile in MAR's development where I'd have error messages add to specific places on a string and then print it to a file with date and time in the string as well... I ended up abandoning it entirely for various reasons, it's application was terribly specific and the results took a little too much effort per gain. I can however, see that system working for someone.

: "l"
set "$ERROR" "A0B0C0D0E0"
. "just and example of a labeled error code, letters representing"
. "different errors and 0 or 1 being set at the error message writer"
set "$tmp" "$error"
. "setting $tmp to check if there were any errors by cross ref"
wait 1
goto "#TEST"
. "this can be anything really"
if "$error" != "$tmp" "#WRITE_ERROR"
goto "l"
: "#TEST"
if "counter" != "othercounter" "#ERROR_D"
goto "#return"
: "#ERROR_D"
set "$ERROR.(4*2)" 49
. "4 because it's triggering the fourth error, which in the string is D"
. "49 being char 1, signifying the error being triggered"
. "*2 because there are two chars per error"
goto "#return"
: "#write_error"
inc "$ERROR" "_&TIME_HOURS&:&TIME_MINUTES&:&TIME_SECONDS&"
set "errors.dat" "fwrite_append"
set "$error" "FWRITE"
set "" "fwrite_open"
goto "#return"


I did SOMETHING like this in MAR, it was pretty useful while I was using it, but it's... totally cumbersome and more or less useless to most applications. god I'm tired...

EDIT: I dunno if this is helpful in any way, and it's worth noting I only ever used this idea once and even then, it may have been badly misapplied.

This post has been edited by ThDPro: 11 July 2013 - 07:22 AM

original soundtracks
Better Than Nothing - DOMINATION - Commander Keen: Heroes Lost - Welkin - A Confectioner's Recipe - random ThDPro music stuff
<Risu21121> if you're not going to make a good game, you might as well make a blatantly racist one.
<Kuddy> Testicles.
"Where are my folder?" - KKairos
0

#8 User is offline   Risu2112 

  • I can't get the top off this bottle
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,864
  • Joined: 12-August 01
  • Gender:Male

Posted 12 July 2013 - 05:34 AM

I'll fix your bug. send it to me.
Respond! Vibrate! Feed back! Resonate!
<Cybersilver> "All my sugestions are for FUTER VERSIONS. Say it with me Fu-ter futer. Yep..."
9-21-2009, SFMZX game play video: HERE
Risu2112
0

#9 User is offline   Graham 

  • . "@Master Procrastinator"
  • PipPipPipPip
  • Group: Members
  • Posts: 625
  • Joined: 28-December 12
  • Gender:Male
  • Location:Oregon

Posted 12 July 2013 - 08:15 PM

Thanks, I finally figured it out though. Basically if you save your game (mine saves through robotic commands) and you have less robots on the board then when you started it (because some died) then MegaZeux reorders the robots and some of them will have a different robot_id. This was a problem because robots were loading programs according to their robot_id leading to some of them no longer working. So the fix was to set a local counter to the robot_id and load from that.
Currently working on Servo for MegaZeux, I hope to complete it by the middle of 2015? Who knows...

"Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you’re a mile away and you have their shoes."
-Jack Handey
0

#10 User is offline   CJA 

  • «≡larch bucket≡»
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 3,262
  • Joined: 23-June 05
  • Gender:Male
  • Location:......@.c....

Posted 14 July 2013 - 01:28 AM

I just add a bunch of message strings to loops with informative counters embedded in the message.
Need a dispenser here.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users