English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 02 September 2011, 20:40   #21
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Nice one Leffmann - as usual mate, your code knocks mine sideways - I'll give my routine some more thought.
pmc is offline  
Old 04 September 2011, 22:51   #22
jman
Registered User
 
Join Date: Nov 2010
Location: .
Posts: 382
Quote:
Originally Posted by pmc View Post
I've never done a routine and not been able to debug it and get it working by using Monam (the Devpac debugger) and *all* the code I do takes over the system. In my experience, it's just a question of thinking carefully about the correct ways to do your testing and testing smaller pieces of code separately. Use logic, think about what you're doing and narrow down where a bug can be and where it can't be by process of elimination - that's my best advice.
What I do, when my code is not crashing the system, is exit (tipically using LMB) as soon as the bug appears (example a condition that never occurs), then step back immediately into the debugger: registers are cleaned but memory still contains my code. I guess this more or less equals to using an Action Replay ;-)

I would be happy to use MonAm for debugging step by step, it has lovely features like complete breakpoints management but after system is excluded this is not an option anymore. I don't understand how can you do it.
Anyway, I'll follow your suggestion and patiently try some copy&paste.
Thanks
jman is offline  
Old 05 September 2011, 09:36   #23
pmc
gone
 
pmc's Avatar
 
Join Date: Apr 2007
Location: completely gone
Posts: 1,596
Quote:
Originally Posted by jman
What I do, when my code is not crashing the system, is exit (tipically using LMB) as soon as the bug appears (example a condition that never occurs), then step back immediately into the debugger: registers are cleaned but memory still contains my code.
This to me is where logic and process of elimination comes in.

For example, for the sake of argument, and taking this thread as inspiration - say I have a routine to draw a line but I don't get the results I expect. The system doesn't crash but the line is drawn wrong.

Now, chances are there are two parts to a routine like this, one part will manipulate the coordinates required to draw the line and another will do the actual line drawing. So the bug could be in either routine. So, use logic and test. Go into a drawing package and draw a line that has the same start and end points that your routine should draw a line for. Now you can manually see all the coordinates that make up that line when it's correctly drawn so write them all down.

Next start your debugger and single step the piece of code that generates the line coordinates for your line draw routine. Do they all match all the pixel coordinates you wrote down? If not, there's a problem in your code and chances are during single stepping you will have seen what. Perhaps a calculation was wrong or a branch might have been taken that you didn't expect. So, fix each issue you find and single step debug again until you get no errors and all the numbers are correct.

Now re-run your line draw routine. Is the line OK now? If not, then you know it can't be your coordinate routine cos you just tested that OK so there must be a problem with the pixel plot routine that draws the line, so single step that and so on and so on until the code is error free.

Tested logically and sequentially like this, all code can be fixed.

Last edited by pmc; 05 September 2011 at 10:30. Reason: typo
pmc is offline  
Old 05 September 2011, 22:59   #24
Lonewolf10
AMOS Extensions Developer
 
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
Quote:
Originally Posted by jman View Post
I would be happy to use MonAm for debugging step by step, it has lovely features like complete breakpoints management but after system is excluded this is not an option anymore.

err.... simply ignore the system shutdown code (just don't forget to also jump over the system restore code, if appropriate)!! I added a temporary branch in my start-up code just to jump over my system kill routine. Admittedly, it did crash after multiple attempts at debugging the routine, but it beats transferring huge amounts of data and code to a separate file (or files) for debugging.
I did get to the root of the problem in the end


Regards,
Lonewolf10
Lonewolf10 is offline  
Old 06 September 2011, 00:46   #25
jman
Registered User
 
Join Date: Nov 2010
Location: .
Posts: 382
@Lonewolf10 and @pmc

Invaluable advice, no kidding. I will definitively take this approach and see how faster do I get into debugging!

Thank you very much.
jman is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Old drawing of a book absence request.Other 8 04 June 2012 17:19
Drawing circles h0ffman Coders. Asm / Hardware 4 31 January 2012 22:25
Some questions about blitting and ordering of drawing neoman Coders. General 23 29 October 2010 18:03
drawing tablet improvements pbareges request.UAE Wishlist 2 10 April 2009 14:06
USB Drawing tablet support. oldpx request.UAE Wishlist 3 28 July 2004 13:24

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:50.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08193 seconds with 14 queries