Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

Debug library

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2008, 06:37 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default Debug library

Like me, have you had, on occasion, to scatter your code with debugging code trying to find an obscure bug and then found it difficult to identify all that additional code and clear it out. This library tries to avoid that by providing the ability to insert readily identifiable debug statements in the code and centralise the debugging code in a single event Sub that may just be deleted when the problem is solved. In addition these debug statments are conditional so that debugging code is only invoked when a problem is likely to exist. This makes debugging long loops much easier.

As the help file says, this library doesn't do more than you could do in B4PPC code. However as it is isolated in a library it does it much more neatly! Let me know if you have any suggestions for improvement.

EDIT: Version 1.1 posted. See post below.

EDIT: Version 1.2 posted with the awesome new Watcher object. See post #6. This now needs .NET 2.0 so I have left version 1.1 which only needs .NET 1.0/1.1

EDIT: Version 1.3 posted with a greatly enhanced Watcher that can examine and change properties and invoke methods. See post#7.

EDIT: Version 1.4 posted with Watcher polished a bit and a new Tracer object. See post #10.

EDIT: Version 1.5 posted with support for module name prefixes and the awesome new Caller object. . See post #11.
Attached Files
File Type: zip Debug1.1.zip (12.7 KB, 62 views)
File Type: zip Debug1.5.zip (32.3 KB, 95 views)

Last edited by agraham : 10-15-2008 at 04:06 PM.
Reply With Quote
  #2 (permalink)  
Old 05-17-2008, 06:40 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 993
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Reply With Quote
  #3 (permalink)  
Old 05-18-2008, 12:23 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I thought that I would offer some words of explanation to those of you who have looked at the demo program and may be curious why I declared a global array, then assigned it to a Debug property and then unnecessarily assigned the property back to the global array when it always accessible.
Code:
    DebugVals(0) = localvar
Debug.Values = DebugVals() 
' can save local variables to pass to DebugEvent
...
Sub Debug_DebugEvent
DebugVals() = Debug.Values 
' this can get back saved local variable values
...
I had intended to use the new Array keyword to allow saving local variables for analysis without going via a global array but it didn't work! I have asked Erel why and left the property in and documented for the time being. I also anticipated that local arrays may be available some time which will not be visible outside the Sub where thay are declared.
Code:
    Debug.Values = Array(lvar1, lvar2) ' can save local variables to pass to DebugEvent
...
Sub Debug_DebugEvent
DebugVals() = Debug.Values 
' this can get back saved local variable values
...
Reply With Quote
  #4 (permalink)  
Old 05-18-2008, 03:50 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

The Array keyword is a "special" keyword. It first checks the left hand side variable and finds it type. This way it knows which type of array it should create (String, Double...).
In version 6.30 the Array keyword can only be used to initialize already declared arrays.
Reply With Quote
  #5 (permalink)  
Old 05-18-2008, 04:56 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Thanks for the explanation Erel.

Version 1.1 now posted with the internal Values array removed as what I intended it for will not work. ID renamed EventID and the example demo tidied up. A new IfTrueTest debug method to test a boolean added. Help file amended.
Reply With Quote
  #6 (permalink)  
Old 07-16-2008, 05:13 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Presently the debugging of optimised compiled programs is limited to popping up message boxes and maybe writing debug info to temporary controls. I've added a Watcher object to this library that can look inside optimised compiled apps at runtime and display and alter Global variables. It even works on the device. Have a play!

At present it is limited to normal variables and single dimensioned arrays. I plan to cope with multi-dimensioned arrays and will have a go at typed arrays sometime.
Reply With Quote
  #7 (permalink)  
Old 07-24-2008, 07:37 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

The Watcher in version 1.3, now posted in the first ,post has been hugely enhanced and can now watch and modify multi-dimensioned and typed arrays, it could also deal with typed variables but B4ppc doesn't support them (yet!).

It can display and alter control properties and invoke control methods, including library controls. Try it on the Debug object in the demo.

All variables, controls, properties and methods may be selected from combo-boxes so minimising key input on the device. It is thread safe so you can modify GUI elements at runtime if you want.

Note that it runs on both device and desktop so you can debug an optimised compiled exe on the device.

An extra breakpoint facility has been added to the Debugger object so that individual breakpoints can be enabled and disabled.
Reply With Quote
  #8 (permalink)  
Old 07-24-2008, 08:55 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You did an amazing job!
Reply With Quote
  #9 (permalink)  
Old 07-24-2008, 09:24 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Erel View Post
You did an amazing job!
Praise from the master! Thanks Erel I really enjoyed writing that one, and learning along the way
Reply With Quote
  #10 (permalink)  
Old 07-28-2008, 10:52 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Version 1.4 is posted with the Watcher improved by a new layout with larger combo boxes and indicators added for array rank, property readable/writeable and method number of parameters.

A new Tracer object allows messages to be written to a separate trace window at runtime without having to stop the application by showing message boxes.

Although needing .NET 2.0 the Debug and Tracer will work in the IDE, legacy and optimised compiled apps. The watcher will only work in an optimised compiled app.
Reply With Quote
Reply


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

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
V6-not-optim, V6-Debug, and V6-optimised give not the same nested FOR-NEXT execution dan kabestan Questions (Windows Mobile) 1 01-04-2008 08:17 PM
debug and watches dennishea Questions (Windows Mobile) 1 12-27-2007 06:08 PM
Debug problem Gale Johnson Bug Reports 4 08-14-2007 08:44 PM
hung when using search in help file while in debug mode adukes Bug Reports 2 07-02-2007 06:37 PM
debug mode stuck.. belotrei Bug Reports 2 06-05-2007 05:17 PM


All times are GMT. The time now is 10:05 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0