Event/Action execution trace ...

Discussion and feedback on Construct 2

Post » Thu Jun 05, 2014 5:35 am

Hi,

Is there a way to "switch on" a log for an execution trace -- perhaps some kind of hidden C2 function :-) (@Ashley)

If not, i think this would be a great help to debugging in particular for complex event, function call interactions. Instead of requiring to instrument all of the code with trace code.
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Thu Jun 05, 2014 5:39 am

Alternatively, in spirit of aspect-oriented programming/meta programming, it would be great to have a system "meta function" that is triggered for every event that fires and every action that gets executed ... while also passing along the meta information -- such as layout name, event expression (and even a unique identifier), action name, etc.

This could then be customized via event conditions to produce a trace or other interesting features across C2 programs ...

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Thu Jun 05, 2014 6:28 am

Here is one example how this could look like in C2. Essentially, the System "plug-in" gets the following additional event conditions.

System.before any event fire
System.after any event fire
System.before any action executed
System.after any action executed

And two system variables that hold the string of the event condition that fired, and a string that holds the action executed. Ideally, it would be nice if some event conditions and actions could be tagged, and the tags would show up in a system variable also.

If one wants to make code further customizable, then there could also be a system action to stop the execution of an action. System.Discard Action. This would make this facility very close to aspect-oriented programming facilities -- i.e. code can be overridden.

thanks,

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Thu Jun 05, 2014 10:48 am

If you want to see the execution trace, why not just open the debugger, set a breakpoint on the first event, then step through each event one by one?
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Thu Jun 05, 2014 1:01 pm

Good idea. Didn't know this feature existed ... :-)

Although a idea of system events for events firing and action execution, could still be interesting in its own right -- although, probably, at a lower priority ...
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Fri Jun 06, 2014 12:38 am

I agree an debug log would be good, although potentially overwhelming considering the fact that event sheets get cycled through so many times (you'd have to be careful what/where you logged). Stepping in the debugger is not quite the same.. and you can't put a breakpoint inside triggered events and loops. The debugger is very useful though.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Jun 06, 2014 2:04 am

que yo sepa no
B
4
Posts: 4
Reputation: 208

Post » Sat Jun 07, 2014 7:05 pm

Hi @Ashley,

I now checked, and now recalled an initial issue.

Breakpoints can not be placed on trigger events, which reduces the utility of tracing via the debugger. Hence, it seem that reviving my initial idea of having an explicit system event for tracing selected calls, could be quite helpful.

Dan
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Post » Sun Jun 08, 2014 2:08 am

@OP

Actually, there is, you can print to the Chrome console using the Browser object, with the Log function (Opening the console is Ctrl + Shift + J)
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461

Post » Sun Jun 08, 2014 3:41 am

Thanks!,

So this means you need to add a browser.print statemement everywhere of interest.

How about if you could do the following:

system.oneventfire
layoutname="L1"
gameState=1

browser.print system.eventfired.Name & system.currentAction
B
8
S
4
G
1
Posts: 205
Reputation: 1,354

Next

Return to Construct 2 General

Who is online

Users browsing this forum: justifun, tarek2, tumira and 6 guests