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

Improving the expression evaluator #798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wk8
Copy link
Contributor

@wk8 wk8 commented Jun 13, 2017

  • right after evaluating an expression, the erlang debugger will trigger a new
    "breakpoint reached" event; unfortunately, that means this plugin will try to
    concurrently render the new state of the bindings as well as the result from
    the evaluation, which Intellij doesn't seem to handle too well, resulting in
    the debugging session losing track of what the current frame is... so to fix
    that we just ignore the next "breakpoint reached" event occuring in an Erlang
    process right after evaluating an expression in that process. Better ideas
    welcome!
  • checking whether the evaluation resulted in an error, and nicely formatting
    it in if that's the case

@wk8
Copy link
Contributor Author

wk8 commented Jun 13, 2017

@ignatov sorry for jumping the gun on #797, it had a couple of bugs in it, this PR should fix those, thanks :)

@wk8 wk8 force-pushed the wk8/eval_fixes branch from 01d92b6 to 27c5f20 Compare June 13, 2017 01:20
@@ -58,14 +59,15 @@ public ErlangStackFrame(@NotNull ErlangXDebugProcess debugProcess,
@Nullable
@Override
public XDebuggerEvaluator getEvaluator() {
return new XDebuggerEvaluator() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please comment this change?

myDebuggerNode.evaluate(expression, traceElement);
}

@Override
public synchronized void handleEvaluationResponse(OtpErlangObject response) {
if (myEvalCallback != null) {
myEvalCallback.evaluated(ErlangXValueFactory.create(response));
mySession.resume();
String error = null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for me, it's better to extract a separate function and assign it to the error variable.

if (response instanceof OtpErlangAtom && ((OtpErlangAtom) response).atomValue().equals("Parse error")) {
// it is a parsing error
error = "Parse error";
} else if (response instanceof OtpErlangTuple) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use

if () {
}
else {
}

style.

@ignatov
Copy link
Owner

ignatov commented Jun 29, 2017

@wk8 Any updates?

@wk8
Copy link
Contributor Author

wk8 commented Jun 29, 2017

@ignatov : sorry, I actually don't like this change, there must be a better way of doing this. I need to get back to the drawing board, but haven't had time yet. Soon! :)

@wk8 wk8 force-pushed the wk8/eval_fixes branch from 60d9490 to 71814c4 Compare August 9, 2017 15:28
@wk8 wk8 changed the title Fixing a couple of minor bugs with the expression evaluator Improving the expression evaluator Aug 9, 2017
@wk8
Copy link
Contributor Author

wk8 commented Aug 9, 2017

@ignatov : made a little better, plus addressed your comments, could you please have another look? :) Thanks!

@wk8 wk8 force-pushed the wk8/eval_fixes branch 3 times, most recently from b823e9f to e5c4f49 Compare August 9, 2017 17:10
 * right after evaluating an expression, the erlang debugger will trigger a new
   "breakpoint reached" event; unfortunately, that means this plugin will try to
   concurrently render the new state of the bindings as well as the result from
   the evaluation, which Intellij doesn't seem to handle too well, resulting in
   the debugging session losing track of what the current frame is... so to fix
   that we just ignore the next "breakpoint reached" event occuring in an Erlang
   process right after evaluating an expression if it's the same breakpoint, in
   the same process. Better ideas welcome!
 * checking whether the evaluation resulted in an error, and nicely formatting
   it in if that's the case
@wk8 wk8 force-pushed the wk8/eval_fixes branch from e5c4f49 to b5fb0fa Compare August 9, 2017 17:35
@wk8
Copy link
Contributor Author

wk8 commented Aug 25, 2017

@ignatov Any updates? :) thanks!

@ignatov
Copy link
Owner

ignatov commented Aug 27, 2017

Thanks for the ping.

@wk8
Copy link
Contributor Author

wk8 commented Oct 5, 2017

@ignatov any chance you'd have some time to review this in the coming days? :)

ErlangProcessSnapshot processInBreakpoint = ContainerUtil.find(snapshots, erlangProcessSnapshot -> erlangProcessSnapshot.getPid().equals(pid));
assert processInBreakpoint != null;

boolean ignoreIfSame = myIgnoreNextBreakpointIfSame;
myIgnoreNextBreakpointIfSame = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit tricky assignments, do you need that because of the syncronization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above :)

// unfortunately, that means this plugin will try to concurrently render the new state of the bindings as
// well as the result from the evaluation, which Intellij doesn't seem to handle too well, resulting in
// the debugging session losing track of what the current frame is... so we just ignore the next "breakpoint
// reached" event after evaluating an expression if it's the same breakpoint - better ideas welcome!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a bit tricky condition :)

Copy link
Contributor Author

@wk8 wk8 Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's the thing, I wasn't able to understand exactly why Intellij doesn't handle it well when the "breakpoint reached" event is fired right after an "eval result" event comes in, but it really doesn't; hence the need to ignore that "breakpoint reached" event. But at the same time, we don't want to ignore just any such event: it's very possible that, while evaluating an expression, you hit another breakpoint - and then we do want it to trigger.

Which results in this condition.

But I said, better ideas welcome ;)

@wk8
Copy link
Contributor Author

wk8 commented Dec 3, 2017

@ignatov : any chance you'd have a few moments to spare to review this? :) thanks!!

@wk8
Copy link
Contributor Author

wk8 commented Jan 3, 2018

@ignatov sorry for pinging you again, it's that time of the month ;) (happy new year btw!)

@ignatov
Copy link
Owner

ignatov commented Jan 3, 2018

Could you please provide a small sample for reproducing, ideally a single file and describe steps to reproduce, I'd like to try your patch before the merge. Right now it looks a bit hacky, and it will be great to dive into it.
Happy New Year!

@ignatov
Copy link
Owner

ignatov commented Apr 16, 2018

@wk8 I'd like to merge the PR, could you please provide a small sample for reproducing.

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

Successfully merging this pull request may close these issues.

2 participants