Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Revert breakpoint clearing#3113

Merged
jasonLaster merged 2 commits into
firefox-devtools:masterfrom
jasonLaster:revert-bp-clearing
Jun 7, 2017
Merged

Revert breakpoint clearing#3113
jasonLaster merged 2 commits into
firefox-devtools:masterfrom
jasonLaster:revert-bp-clearing

Conversation

@jasonLaster

@jasonLaster jasonLaster commented Jun 6, 2017

Copy link
Copy Markdown
Contributor

This fixes an issue we were seeing with breakpoints being added when they already existed on the server.

This fix is basically reverting the behavior we had before.

bomsy
bomsy previously approved these changes Jun 7, 2017

@codehag codehag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm i think this might be breaking some stuff. lets chat about it before it gets merged!

Comment thread src/actions/sources.js Outdated
const bp = getBreakpoint(state, location);

if (sameSource) {
if (sameSource && !bp) {

@codehag codehag Jun 7, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are a couple of issues with this fix.

  • we are no longer syncing if the debuggee code is changed and the debuggee is reloaded. in other words, the debugger does not reflect the state of the server
  • we lose the reference to where the breakpoint is on the server, so if we update the debuggee, and the breakpoint moves, we can no longer delete it.

An alternative to get the debuggee breakpoints working again: do not add the breakpoint if the location is the same. the best solution would be if we had a function in the client to do this, but when i was implementing this, i was nervous about touching the client code. For now we could do the following. This will need some work ... i did it quickly (probably isn't performant / the best solution), but it should work, and we don't need to check if the BP exists in check pending breakpoint. Later, when we set the bp while syncing, it won't matter if it exists in the reducer, since set is idempotent:

diff --git a/src/actions/breakpoints.js b/src/actions/breakpoints.js
index f525de5c..1e2e093b 100644
--- a/src/actions/breakpoints.js
+++ b/src/actions/breakpoints.js
@@ -62,9 +62,10 @@ async function syncClientBreakpoint(
     sourceId: generatedSourceId
   };
 
-  // early return if breakpoint is disabled with overrides to update
-  // the id as expected, without talking to server
-  if (pendingBreakpoint.disabled) {
+  const existingClient = client.getBreakpointByLocation(oldGeneratedLocation);
+  // early return if breakpoint is disabled, or exist on the server with
+  // overrides to update the id as expected
+  if (pendingBreakpoint.disabled || existingClient) {
     return {
       id: generatedSourceId,
       actualLocation: { ...pendingBreakpoint.location, id: sourceId },
diff --git a/src/client/firefox/commands.js b/src/client/firefox/commands.js
index f886401a..45308dbc 100644
--- a/src/client/firefox/commands.js
+++ b/src/client/firefox/commands.js
@@ -1,5 +1,6 @@
 // @flow
 
+import _ from "lodash";
 import type {
   BreakpointId,
   BreakpointResult,
@@ -74,6 +75,28 @@ function sourceContents(sourceId: SourceId): Source {
   return sourceClient.source();
 }
 
+function getBreakpointByLocation(location: Location) {
+  const values = _.values(bpClients);
+  console.log(values, location);
+  const bpClient = values.find(value => {
+    const { actor, line, column, condition } = value.location;
+    return (
+      location.line === line &&
+      location.sourceId === actor &&
+      location.column === column &&
+      location.condition === condition
+    );
+  });
+
+  if (bpClient) {
+    return {
+      id: bpClient.actor,
+      actualLocation: bpClient.location
+    };
+  }
+  return null;
+}
+
 function setBreakpoint(
   location: Location,
   condition: boolean,
@@ -251,6 +274,7 @@ const clientCommands = {
   stepOut,
   stepOver,
   breakOnNext,
+  getBreakpointByLocation,
   sourceContents,
   setBreakpoint,
   removeBreakpoint,

@codehag codehag force-pushed the revert-bp-clearing branch from fd24070 to 01b7152 Compare June 7, 2017 17:08
@codecov

codecov Bot commented Jun 7, 2017

Copy link
Copy Markdown

Codecov Report

Merging #3113 into master will decrease coverage by 0.24%.
The diff coverage is 44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3113      +/-   ##
==========================================
- Coverage   66.86%   66.61%   -0.25%     
==========================================
  Files          76       76              
  Lines        2698     2714      +16     
  Branches      544      549       +5     
==========================================
+ Hits         1804     1808       +4     
- Misses        894      906      +12
Impacted Files Coverage Δ
src/reducers/breakpoints.js 90.19% <ø> (+1.16%) ⬆️
src/client/firefox/commands.js 17.27% <0%> (-2.32%) ⬇️
src/utils/breakpoint/index.js 91.66% <100%> (ø) ⬆️
src/actions/breakpoints.js 87.62% <90%> (-0.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a3e034...01b7152. Read the comment docs.

@jasonLaster jasonLaster merged commit cdccd0a into firefox-devtools:master Jun 7, 2017
@jasonLaster

Copy link
Copy Markdown
Contributor Author

Thanks so much @codehag. This was really great work. I hope we can simplify the server in the future, but i will sleep better knowing you can tame the system too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants