PDA

View Full Version : Experimental TRACE module



ErosOlmi
06-04-2008, 00:36
Be sure to have at least thinBasic preview version 1.6.0.4 installed before testing this module
_________________________________________________

I am experimenting a new module called TRACE. This module will let you:

trace script execution line by line
inspect and change script variables value during execution
setting breakpoints
... other things
In reality I'm still very far from the above list but I wanted to show what's going on here.

How to use:

download attached file
substitute thinCore.dll you have in \thinBasic\ directory with the attached one
place thinBasic_Trace* files into \thinBasic\Lib\ directory

Done that, you can start tracing your first script just adding:

USES "TRACE"
as first line of your script. This line will invoke new TRACE module. A new window will appear (see attached image) and script will stop at every line.

We are developing TRACE as module and not as native thinAir tool because we are adding to thinBasic Core engine some new function interfaces that will let everybody to develop its own Tracing tools exactly like we are doing now. So everyone knowing how to develop a thinBasic module in whatvever compiled language will be able to develop its own methods to interact with script execution. Done that, we will integrate tracing functionalities directly into thinAir.

For the moment PLEASE JUST TRACE VERY SIMPLE SCRIPTS AND do not trace any script working with UI module because otherwise you will enter a never ending sequence: messages to close windows will never be handled (in case, use TaskManager and stop thinBasic.exe process).
Module is not tested much, interaction is very very minimal but I feel confident I will get something usefull from this job.
Of course obfuscated scripts cannot be traced. For the moment if you try you will get a GPF but in next version you will get a runtime error.

Let me know what you think, any evident bugs or just ideas.
I will keep into consideration during development.

Ciao
Eros

Updates:

2008.04.06: removed messagebox. Added F8 (execute line) and CTRL+F8 (execute up to cursor position). Much more usable
2008.04.13: big improvements in Trace module user interface and possibilities: single line steps, execute, break points, variable inspection
2008.04.14: traced script is now shown with its original comments and indentations

ErosOlmi
06-04-2008, 00:56
Working direction:

remove messagebox stop Done
F5 full execution Done
F8 for line execution Done
CTRL+F2 set/remove break point Done
add rebar buttons with interaction functionalities: line execute, block execute, stop, ...
manage source script in native mode (with full comments and indentations). Currently TRACE module loads script already optimized by thinCore
manage scripts with included files. Now if script has included files they are inline expanded
ability to trace scripts working with UI module messages
manage variables inspection Done
manage variables interactions
store Trace user configuration options


This list will be updated and integrated with the help of feedbacks.

Ciao
Eros

Petr Schreiber
06-04-2008, 08:28
Thanks Eros,

I would like to see some Trace_AddWatch(VariableName), Trace_RemoveWatch(VariableName), which could somehow integrate to the debugger editor window (and eliminate MSGBOXing).

And maybe some TRON ;) ... Trace_On, Trace_Off would be also nice.

I like it very much so far, the editor with yellow line looks nice, I think I have seen it before in some other sample you posted?


Really promising!,
Petr

Michael Hartlef
06-04-2008, 09:10
Hey, that is really cool and for sure become very very helpfull. Thank you!

ErosOlmi
06-04-2008, 18:57
Version updated.
Removed message box.
Added F8 for line execution
Added CTRL + F8 execution till cursor (place cursor in some line after current line)

Petr Schreiber
06-04-2008, 19:14
Hey Eros,

this is gona be really powerful, the manual control + run to cursor is really very usable!
I like the speed, and everything. I got idea the watch variables could be in listview below under the richedit.

Only problem now are some artifacts, but when I move the window "under the screen" and back they get properly repainted,
see the picture.


Petr

ErosOlmi
06-04-2008, 20:03
Yes, I know about screen repaint but do not worry about screen or whatever related to the edit window.
I'm currently using CodeSense edit control but only because it gives me fast integration without the need to concentrate on the edit control. Maybe I will change it to something else like Scintilla or even to something home made like we did in thinAir. Or maybe we will use thinAir.

Currently I'm more target on the "way" to do the whole thing, on the way to interact between script execution engine and tracer/debugger.
Using an external module open the way to also other to develop other debuggers. For example what about a remote tracer via IP where you execute the script on one computer but trace it on another?

Just thinking and experimenting.

Next thing I will work on:

break points
variable inspections


Ciao
Eros

Michael Hartlef
06-04-2008, 20:51
Thanks for the update!

Michael Hartlef
06-04-2008, 20:56
Works perfect!

kryton9
06-04-2008, 23:01
Thanks Eros. Fantastic idea and I like what is yet to be added too. Thanks a lot, really inspiring to see the coolness that is being added to thinBasic by you, Roberto and all the great module makers!

ErosOlmi
13-04-2008, 00:48
Hi all.
I've updated attached files in first post of this thread.
In order to test, be sure to have latest thinBasic 1.6.0.4 installed.

Extract attached files and:

place thinCore.dll into \thinBasic\ directory
place thinBasic_Trace.dll into \thinBasic\Lib\ directory
place thinBasic_TRACE_Editor.dll into \thinBasic\Lib\ directory


To trace a source code just add somewhere the following line:

USES "Trace"

I'm very excited to list here new features:

new commands:
F8 (Execute next line)
CTRL+F2 (set or remove a break point to a line)
F5 (Execute all or till next break point)

new user interface allows resizable areas
variable inspection (2 text fields on the right side).
It is not so advanced in terms of user interface (I will improve a lot) but will let you specify on the fly a list of variables to be inspected. Just type variable names separated by any space, comma, CRLF. In next line execution they will be searched and evaluated. The whole thing seems working fine. I will make some additional tests and when stable, I will improve user interface, user interaction and more options like multiple level stack variables with the same name, ...
Current bif limitations: variable inspection works only with numeric and string variables. In case of arrays, only the first element is returned, if a variable is present both as global and local so a function, value returned is the innest staking level (the one under the tracing cursor)
module command TRACE_Print(StringToPrint [, WriteToBottomTrueFalse])
will let you print text into the bottom text box of the tracing window. I will improve this behave also adding new commands to clear, append text in that area
break point will let you trace also more complex scripts like UI or TBGL scripts. Just add a break point in critical lines and than press F5 to run execution. F5 will not stop script execution unless a break point is reached.
and of course interaction with tracing window is possible even if script is executing. This is great for UI and TBGL scripts


Hope you like it.
Please let me know any impression.

Ciao
Eros

Dave
13-04-2008, 05:22
Hi Eros.

Works fine - thank you very much.

ErosOlmi
13-04-2008, 08:05
Good.

I feel I can make nice things with this module because quite a lot of things seems possible.

In any case, tracing a dialog message pump (the loop handling dialog messages) can be difficult because messages comes to high speed and do not wait for the programmer to trace line by line. For this reason the best is to place some break points in the areas that need to be inspected.

Once tested better, I will work to improve user interaction adding a statubar, a toolbar and a better and more user friendly way to interact with variable inspection. One thing I want is to show traced source code script in its original way with all comments and indentations.

Ciao and thanks a lot for testing.
Eros

Petr Schreiber
13-04-2008, 09:02
Thanks,

it is getting better and better with each version!
I like I can run the script at full steam using F5 and then using F8 fall back to step mode.


Good!,
Petr

ErosOlmi
14-04-2008, 16:44
Hi again.

I've updated attached file in first post of this thread.

Traced script is now shown with its original comments and indentations allowing a more precise and better understanding of what it's going on in tracing steps.
Hope you like it.

Ciao
Eros

Petr Schreiber
14-04-2008, 16:59
No I do not like it at all ;D


Very nice!,
I also realised I can split the view to 4 viewports :)


Thanks,
Petr