Sunday, October 23, 2016

More sophisticated brreak points with the debugger

I had to add an entry box to grab the user analysis module for on the fly user specific code analysis. Do we call our code on each break?  Why not have more sophisticated traps, a python expression which if evaluated to true causes the user code to be imported? Easy to do, enter the expression and the trap call back will call eval with the proper dictionary.

Easy to do, but right now I am trying the imported module, and the cost is yet another 30 lines of code. And, again, this all depends upon me learning more about the two interrupts I have running.

Soeof the code is boiler plate, like the inline help text.  And ultimately we needed message and entry source anyway, so the two tkinter types are re-usable in other operations.  Holding it at 350 makes it entirely self contained, and still cut and pastable.  I use a mix of simple classes, subroutines, and globals,mainly because I experiment always.  But simple classes seem to work, they group the code properly.

Like this screen shot:
I have two copies of the debugger.  The one called the other upon a break because I specified the pbug module import.  See the entry box to the left, that is where I enter the module to import when a specific break condition is reached.

I got some conflict now, the new version is initialized with some bogus label.  I will sort that out.   But the idea works, We can have a text box denoting  python expression to evaluate.  And we figure out how the imported module gets a reference to the code under test class. Hence, no more features needed, make the user write and keep analysis libraries for complex code.  Turn pbug into a sophisticated trap machine for code testing.

One the analysis module is loaded, he proper method to obtain attributed of eh code under test is via the OS, get attributes.  Python has system calls for finding a class and instance, and extracting method or attributes.  Thus, expose this to the module loaded and it can deal with the originals source, and original instance having the trap conditions. In other words, expose the trap machine internals in a stuctured manner to the user analysis code.

No comments: