Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model based instrumentation #58

Open
miho opened this issue Aug 4, 2015 · 5 comments
Open

Model based instrumentation #58

miho opened this issue Aug 4, 2015 · 5 comments
Milestone

Comments

@miho
Copy link
Member

miho commented Aug 4, 2015

Instead of a Groovy based transform we need a model based instrumentation in the future to ensure that instrumentation also works for other (potential) language bindings. Instead of a special utility method the idea is to directly insert pre/post events into the source.

Example 1:

int a;
a=2;

will be transformed to something like:

preEvent("declare a");
int a;
postEvent("declare a");
preEvent("assign a");
a=2;
postEvent("assign a");

For chained invocations and operators we need to introduce additional tmp-variables:

Example 2:

if(a < b) {
  //
}

will be transformed to something like:

preEvent("LESS Operator");
boolean __vrl__tmpVar_1 = a < b;
postEvent("LESS Operator");
preEvent("if");
if(__vrl__tmpVar_1) {
  //
}
postEvent("if");

We will also need to introduce a mapping between events and visual nodes to use the instrumentation from the ui.

Loops:

Loops need special treatment:

while(a<b){
  //
}

will be transformed to:

boolean __vrl_tmpVar_1 = true;
while(true) {
  preEvent("LESS Operator");
  __vrl_tmpVar_1 = a < b;
  postEvent("LESS Operator");
  if(!__vrl_tmpVar_1) break;
  //
}

For complex condition arguments we need to extract the whole invocation chain and move it into the while loop.

@miho miho added this to the 0.5 milestone Aug 4, 2015
miho added a commit that referenced this issue Aug 4, 2015
@miho
Copy link
Member Author

miho commented Aug 4, 2015

The current implementation only inserts one invocation into the loop. Chained or nested invocations are left outside of the loop.

miho added a commit that referenced this issue Aug 6, 2015
…hains, such as i < 2*3+myMethod(4))

issue #58 : #58

Some minor aspects of the model have been changed (e.g. supports move of one invocation to another scope, objvar rename)
@miho
Copy link
Member Author

miho commented Aug 7, 2015

To improve the current instrumentation implementation we should introduce a clean event api that can publish events to registered observers without changing the instrumented code. Therefore, we should add an API like the previously, Groovy specific VRLInstrumentationUtilclass and

static void VRLInstrumentationUtil.__preEvent(...)
static void VRLInstrumentationUtil.__postEvent(...)

and ideally invocation generators that generate the static method calls in the corresponding model:

static void VRLInstrumentationUtil.generatePreEvent(...)
static void VRLInstrumentationUtil.generatePostEvent(...)

miho added a commit that referenced this issue Aug 7, 2015
instrumentation highly improved, clean event generation api introduced
miho added a commit that referenced this issue Aug 7, 2015
preEvent generation was buggy and didn't work for while-loops
miho added a commit that referenced this issue Aug 7, 2015
this should be sufficient for visualizing instrumentation events (issue #58)

TODO investigate whether id generation should be inside object initialization or inside the code-builder
miho added a commit that referenced this issue Aug 10, 2015
- custom instrumentatin event handlers can be added to VRLInstrumentationUtil
miho added a commit that referenced this issue Aug 10, 2015
- timestamp works, toString implemented for logging and debugging
miho added a commit that referenced this issue Aug 10, 2015
- timestamp works, toString implemented for logging and debugging
miho added a commit that referenced this issue Aug 10, 2015
- timestamp works, toString implemented for logging and debugging
miho added a commit that referenced this issue Aug 10, 2015
temporary indent argument removed since debugging can now be done with much more accurate event handling api
@miho
Copy link
Member Author

miho commented Aug 10, 2015

Basic CSG instrumentation works!

vrl-0 5-first-working-version-with-3d-02

@miho
Copy link
Member Author

miho commented Aug 10, 2015

another example:

screenshot 2015-08-10 20 01 43

miho added a commit that referenced this issue Aug 13, 2015
(before, we only visualized return values)

issue #58
miho added a commit that referenced this issue Aug 19, 2015
- return statements need to be executed after post-event (since nothing gets executed after return)
miho added a commit that referenced this issue Aug 19, 2015
- return statements need to be executed after post-event (since nothing gets executed after return)
@miho
Copy link
Member Author

miho commented Aug 20, 2015

Event generation for return statements has a bug (no event can be fired after returning from a method).

Example:

        __vrl_reserved_intermediate_var_6);
        VRLInstrumentationUtil.__preEvent("14", "return", 
        __vrl_reserved_intermediate_var_6);
        return __vrl_reserved_intermediate_var_6;
        VRLInstrumentationUtil.__postEvent("14", "return");
    }

Therefore, we need to swap the return statement invocation and its post-event invocation:

        __vrl_reserved_intermediate_var_6);
        VRLInstrumentationUtil.__preEvent("14", "return", 
        __vrl_reserved_intermediate_var_6);
        VRLInstrumentationUtil.__postEvent("14", "return");
        return __vrl_reserved_intermediate_var_6;
    }

The same applies to continue and break.

miho added a commit that referenced this issue Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant