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
Promise breakpoint #58
Conversation
72889ec
to
fcb6c45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. Most comments are polish to keep consistent with existing style and avoid code duplication.
@@ -0,0 +1,22 @@ | |||
0 info it worked if it ends with ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not commit such logs
|
||
protected EventualMessage(final EventualMessage causalMessage, final Object[] args, | ||
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint) { | ||
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint, final boolean triggerPromiseResolveBreakpoint, final boolean triggerPromiseResolveReceiverBreakpoint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please break the line after about 80 characters
final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint) { | ||
super(causalMessage, arguments, resolver, onReceive, triggerRcvrBreakpoint); | ||
final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint, final boolean triggerPromiseResolveSenderBreakpoint, final boolean triggerPromiseResolveReceiverBreakpoint) { | ||
super(causalMessage, arguments, resolver, onReceive, triggerRcvrBreakpoint, triggerPromiseResolveSenderBreakpoint, triggerPromiseResolveReceiverBreakpoint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please break the line after about 80 characters
@@ -22,15 +22,19 @@ | |||
protected final RootCallTarget onReceive; | |||
protected final EventualMessage causalMessage; | |||
|
|||
protected final boolean triggerRcvrBreakpoint; | |||
protected boolean triggerRcvrBreakpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to add a comment to the field explaining why it is not final like the other ones.
@@ -22,15 +22,19 @@ | |||
protected final RootCallTarget onReceive; | |||
protected final EventualMessage causalMessage; | |||
|
|||
protected final boolean triggerRcvrBreakpoint; | |||
protected boolean triggerRcvrBreakpoint; | |||
protected final boolean triggerPromiseResolveSenderBreakpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't we have new terminology after the discussion with Elisa? would be good to change the code accordingly.
@@ -0,0 +1,39 @@ | |||
package tools.debugger.nodes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor these classes to avoid code duplication. The only thing that seems to be different is how the BreakpointEnabling object is retrieved. This can be factored out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to refactor the BreakpointNode classes I think there is a problem because of the types of breakpoints. Indeed the BreakpointEnabling object is the one that makes the difference, but to be able to use only one BreakpointNode class I think that we will have to use a superclass and this will bring some changes because the most part of implementation related to breakpoints is specified by each type of breakpoint.
* Disabled breakpoint node that returns false all the time. | ||
* | ||
* (use mainly when the Truffle debugger is not enabled) | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
@@ -74,6 +74,8 @@ export class Controller { | |||
case "AsyncMessageReceiveBreakpoint": | |||
this.view.updateAsyncMethodRcvBreakpoint(<AsyncMethodRcvBreakpoint> bp); | |||
break; | |||
case "PromiseSenderBreakpoint": | |||
case "PromiseReceiveBreakpoint": /** TODO */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? looks like there is code missing
line: line, | ||
sourceUri: sourceUri, | ||
enabled: false}; | ||
export type Breakpoint = LineBreakpoint | MessageBreakpoint | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is a broken merge/rebase.
Please see the breakpoints.ts
file next to messages.ts
. This here seem to duplicate the code that moved there.
source, sourceId, clickedSpan); | ||
} | ||
|
||
export function createMsgBreakpoint(source: Source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the only difference between the various breakpoints is here the type. Please factor out this code to create the object that is passed to the constructor into a helper method to avoid code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some naming, cosmetics, and the breakpoint class
* It is not final because its value can be updated in order that other breakpoints | ||
* can reuse the stepping strategy implemented for message receiver breakpoints. | ||
*/ | ||
protected boolean triggerRcvrBreakpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triggerRcvrBreakpoint should be named triggerMessageReceiverBreakpoint
to be unambiguous within the new set of breakpoints
@@ -131,8 +144,8 @@ protected static Actor determineTargetAndWrapArguments(final Object[] arguments, | |||
protected final Actor originalSender; // initial owner of the arguments | |||
|
|||
public PromiseMessage(final EventualMessage causalMessage, final Object[] arguments, final Actor originalSender, | |||
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint) { | |||
super(causalMessage, arguments, resolver, onReceive, triggerRcvrBreakpoint); | |||
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint, final boolean triggerPromiseResolverBreakpoint, final boolean triggerPromiseResolutionBreakpoint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep lines within 80 chars
@@ -114,7 +112,9 @@ public static boolean isParentResultUsed(final Node current, final Node child) { | |||
|
|||
protected final SourceSection source; | |||
|
|||
protected final AbstractBreakpointNode breakpoint; | |||
protected final AbstractBreakpointNode messageReceivedBreakpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageReceivedBreakpoint -> messageReceiverBreakpoint
public NullResolver(final SourceSection source) { | ||
super(false, source); | ||
} | ||
|
||
@Override | ||
public Object executeEvaluated(final VirtualFrame frame, final SResolver receiver, final Object argument) { | ||
public Object executeEvaluated(final VirtualFrame frame, final SResolver receiver, final Object argument, final boolean isBreakpointOnResolutionAtSender, final boolean isBreakpointOnResolutionAtRcvr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep it to 80chars
if (isBreakpointOnResolutionAtSender) { | ||
haltNode.executeEvaluated(frame, argument); | ||
} | ||
if (isBreakpointOnResolutionAtRcvr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, please avoid committing your todo items as empty if
statements
protected final BreakpointEnabling<?> breakpoint; | ||
|
||
protected BreakpointNode(final SourceSection sourceSection, final MessageBreakpointType type) { | ||
switch (type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this out of the constructor to the corresponding code and please don't use a switch
.
|
||
/** Only to be used by the DisabledBreakpointNode. */ | ||
protected BreakpointNode() { | ||
this.breakpoint = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anymore since DisabledBreakpoint
inherits directly from AbstractBreakpointNode
, right?
If so, please remove.
receiverBreakpoints.put(coord, existingBP); | ||
} else { | ||
existingBP.setEnabled(bId.isEnabled()); | ||
} | ||
} | ||
|
||
public synchronized void addOrUpdate(final PromiseResolverBreakpoint bId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code looks repetitive, looks like one could factor out a helper method here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the addOrUpdate for MessageSenderBreakpoint and AsyncMessageReceiverBreakpoint...But for the case of MessageReceiverBreakpoint and the promises breakpoints I have been trying to do something like this:
public synchronized void addOrUpdate(final PromiseResolutionBreakpoint bId) {
saveBreakpointsEnabling(bId, promiseResolutionBreakpoints);
}
private void saveBreakpointsEnabling(final SectionBreakpoint bId, final Map<FullSourceCoordinate, BreakpointEnabling<? extends SectionBreakpoint>> map) {
FullSourceCoordinate coord = bId.getCoordinate();
BreakpointEnabling<? extends SectionBreakpoint> existingBP = map.get(coord);
if (existingBP == null) {
existingBP = new BreakpointEnabling<>(bId);
map.put(coord, existingBP);
} else {
existingBP.setEnabled(bId.isEnabled());
}
}
the problem is that the argument types are not applicable for '? extends SectionBreakpoint', I'm not sure if there is a way of refactoring these three methods. The only difference between them is the map (receiverBreakpoints, promiseResolverBreakpoints, promiseResolutionBreakpoints)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point you don't really need the info about extends SectionBreakpoint
or do you?
Guess it would work if you drop that part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it keeps saying it is not applicable for the arguments :(
private void saveBreakpointsEnabling(final SectionBreakpoint bId, final Map<FullSourceCoordinate, BreakpointEnabling<?>> map) { FullSourceCoordinate coord = bId.getCoordinate(); BreakpointEnabling<?> existingBP = map.get(coord); if (existingBP == null) { existingBP = new BreakpointEnabling<>(bId); map.put(coord, existingBP); } else { existingBP.setEnabled(bId.isEnabled()); } }
* It has two possible states, enable or disable. | ||
*/ | ||
public abstract class BreakpointNode extends AbstractBreakpointNode { | ||
protected final BreakpointEnabling<?> breakpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this a proper generic type. Replace ?
with T
. And add T
as a generic argument to BreakpointNode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the generic argument T should extend of BreakpointInfo too as BreakpointEnabling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
T extends BreakpointInfo
seems useful, yes
@@ -98,7 +98,7 @@ export interface FarRefData { | |||
export type BreakpointData = LineBreakpointData | SectionBreakpointData; | |||
|
|||
export type SectionBreakpointType = "MessageSenderBreakpoint" | | |||
"MessageReceiveBreakpoint" | "AsyncMessageReceiveBreakpoint"; | |||
"MessageReceiverBreakpoint" | "AsyncMessageReceiverBreakpoint" | "PromiseResolverBreakpoint" | "PromiseResolutionBreakpoint" ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep within 80 chars per line
f7478e9
to
4bd7fb0
Compare
4bd7fb0
to
af9cf57
Compare
bp = Breakpoint.newBuilder(bId.getCoordinate().uri). | ||
lineIs(bId.getCoordinate().startLine). | ||
columnIs(bId.getCoordinate().startColumn). | ||
sectionLength(bId.getCoordinate().charLength). | ||
build(); | ||
bp.setCondition(BreakWhenActivatedByAsyncMessage.INSTANCE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ctrlpz this is a problem, this line is essential :( and we really need tests for these things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I did not notice I removed it...yes we need the tests
- add options to frontend for promise breakpoint on sender and receiver side - change button names in popover - add breakpoint classes - move classes related to breakpoint node from EventualSendNode to an independent package - add SuspendExecutionNode for halting the execution before the promise is resolved (todo: needs to be replaced by stepping strategy) - add helper method to create SectionBreakpointData object to avoid code duplication between the different breakpoints - remove CoverallsTruffle from Eclipse classpath (project is already part of SOMns-deps
Signed-off-by: Stefan Marr <git@stefan-marr.de>
3d5f295
to
f99f5a8
Compare
7410cf4
to
f99f5a8
Compare
Implementation of promise breakpoints for resolver and resolution side.