-
Notifications
You must be signed in to change notification settings - Fork 874
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
PHP: New way to set the current breakpoint #6891
PHP: New way to set the current breakpoint #6891
Conversation
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, see my comment, thank you.
CC @junichi11
@@ -54,6 +54,7 @@ public class BreakpointModel extends ViewModelSupport implements NodeModel { | |||
private static final String EXCEPTION = "TXT_Exception"; // NOI18N | |||
private static final String PARENS = "()"; // NOI18N | |||
private final Map<DebugSession, AbstractBreakpoint> myCurrentBreakpoints; | |||
private Boolean searchCurrentBreakpointById = false; |
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.
Inconsistent threading - you are writing it under lock but read it without it. I guess that simple volatile
should be fine in this case, so without any further locking.
} | ||
} | ||
|
||
public Boolean isSearchCurrentBreakpointById() { |
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.
public Boolean isSearchCurrentBreakpointById() { | |
@CheckForNull | |
public Boolean isSearchCurrentBreakpointById() { |
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.
BTW, do we need to allow null
for this field? I mean, cannot it be simply a boolean
?
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 I get it right, I would simply define it as boolean
with default value false
; and, if this feature is enabled/supported, it would be set to true
. So, no need for 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.
I agree with Tomas. If we use Boolean
, we have to check null
every time. It seems that null
is not set. So, we can use boolean
, I think (if I didn't overlook anything).
DebugSession.IDESessionBridge bridge = session.getBridge(); | ||
if (bridge != null) { | ||
BreakpointModel breakpointModel = bridge.getBreakpointModel(); | ||
if (breakpointModel != null && breakpointModel.isSearchCurrentBreakpointById()) { |
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 I am not wrong, breakpointModel.isSearchCurrentBreakpointById()
can produce a NPE, right?
@@ -96,7 +96,7 @@ private void updateBreakpointsView(DebugSession session, List<Stack> stacks) { | |||
IDESessionBridge bridge = session.getBridge(); | |||
if (bridge != null) { | |||
BreakpointModel breakpointModel = bridge.getBreakpointModel(); | |||
if (breakpointModel != null) { | |||
if (breakpointModel != null && !breakpointModel.isSearchCurrentBreakpointById()) { |
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 I am not wrong, breakpointModel.isSearchCurrentBreakpointById()
can produce a NPE, right?
String feature = ((FeatureSetCommand) command).getFeature(); | ||
if (feature.equals(FeatureGetCommand.Feature.BREAKPOINT_DETAILS.toString())) { | ||
Node error = getChild(getNode(), ERROR); | ||
if (error != 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.
Nitpick: this whole condition can be perhaps a bit simplified:
setSearchCurrentBreakpointById(session, error == null);
Thanks a lot for this PR! However, my knowledge of PHP DBG module is very limited, so I hope that @junichi11 will be able to review the change itself properly 😅 |
php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java
Outdated
Show resolved
Hide resolved
@troizet Thank you for your work and great description :) I agree with Tomas. So, could you have a look at the review? |
a38e13e
to
5110799
Compare
Thank you so much for the review! I have made the suggested changes. |
php/php.dbgp/src/org/netbeans/modules/php/dbgp/breakpoints/BreakpointModel.java
Outdated
Show resolved
Hide resolved
5110799
to
b006691
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.
Looks good to me now, thanks a lot! 👍
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.
Looks good to me. Thank you for your work!
Thank you, guys! Merging. |
@tmysik, @junichi11 Thank you! Happy New Year! |
Happy New Year to you too! |
Now the logic of determining the current breakpoint is based on the information received from xdebug's response to the
stack_get
command, which is not always used to correctly determine the current breakpoint.Since version 3.1.0 xdebug provides possibility to get information about current breakpoint.
To do this you need to enable
breakpoint_details
feature.https://bugs.xdebug.org/bug_view_page.php?bug_id=00001969
In this PR I implemented the use of this feature, with fallback to the old logic, in case xdebug does not support this feature.
Examples before and after (using xdebug version 3.1.6):
method breakpoints
on thex()
function: one withstop on call
, the other withstop on return
behavior before:
current_function_breakpoint_before.mp4
behavior after:
current_function_breakpoint_after.mp4
method breakpoints
on thex()
method: one withstop on call
, the other withstop on return
behavior before:
current_method_breakpoint_before.mp4
behavior after:
current_method_breakpoint_after.mp4
exception breakpoint
onNotice
behavior before:
current_exception_breakpoint_before.mp4
behavior after:
current_exception_breakpoint_after.mp4
echo 'Hello';
with different conditions (the order in which the breakpoints are set is important!):$s == 4
$s == 12
behavior before:
current_line_breakpoint_before.mp4
behavior after:
current_line_breakpoint_after.mp4