debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Breakpoints] we should resume if we pause at an old breakpoint

Open jasonLaster opened this issue 9 years ago • 28 comments

With AST BPs and original BPs, it's possible that we've paused at a breakpoint before we've had a chance to move it to a new location. See GIF. In that case, we should check to see if the breakpoint is missing... or in an old location...

Missing

diff --git a/src/actions/pause.js b/src/actions/pause.js
index 4fa84b5..4462642 100644
--- a/src/actions/pause.js
+++ b/src/actions/pause.js
@@ -104,6 +104,11 @@ export function paused(pauseInfo: Pause) {
       dispatch(evaluateExpressions(frame.id));
     }

+    const bp = getBreakpoint(getState(), frame.location);
+    if (why.type == "breakpoint" && !bp) {
+      dispatch(resume());
+    }
+
     dispatch(
       selectSource(frame.location.sourceId, { line: frame.location.line })

has moved

+    const { location, astLocation } = pendingBreakpoint;
+    const previousLocation = { ...location, sourceId };
+
+    const scopedLocation = await makeScopedLocation(
+      astLocation,
+      previousLocation,
+      source
+    );
+
+    const scopedGeneratedLocation = await getGeneratedLocation(
+      getState(),
+      source,
+      scopedLocation,
+      sourceMaps
+    );
+
+    const hasMoved = locationMoved(generatedLocation, scopedGeneratedLocation);
+
+    const bp = getBreakpoint(getState(), frame.location);
+    if ((why.type == "breakpoint" && !bp) || hasMoved) {
+      dispatch(resume());
+    }
+

jasonLaster avatar Sep 20 '17 14:09 jasonLaster

@jasonLaster where's the GIF mentioned in the post?

jacobjzhang avatar Nov 14 '17 14:11 jacobjzhang

debugger_pinned_bp.gif

jasonLaster avatar Nov 14 '17 21:11 jasonLaster

/claim

zaggy avatar Nov 21 '17 04:11 zaggy

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Nov 21 '17 04:11 claim

I started this and got pretty close:

diff --git a/src/actions/pause/paused.js b/src/actions/pause/paused.js
index 40b7589..9763516 100644
--- a/src/actions/pause/paused.js
+++ b/src/actions/pause/paused.js
@@ -7,7 +7,8 @@
 import {
   getHiddenBreakpointLocation,
   isEvaluatingExpression,
-  getSelectedFrame
+  getSelectedFrame,
+  getBreakpointForLine
 } from "../../selectors";
 import { mapFrames } from ".";
 import { removeBreakpoint } from "../breakpoints";
@@ -16,6 +17,7 @@ import { selectLocation } from "../sources";
 import { togglePaneCollapse } from "../ui";

 import { fetchScopes } from "./fetchScopes";
+import { resume } from "./commands";

 import type { Pause } from "../../types";
 import type { ThunkArgs } from "../types";
@@ -48,6 +50,18 @@ export function paused(pauseInfo: Pause) {
       dispatch(evaluateExpressions());
     }

+    const frame = frames[0];
+    if (
+      why.type == "breakpoint" &&
+      !getBreakpointForLine(
+        getState(),
+        frame.location.sourceId,
+        frame.location.line
+      )
+    ) {
+      return resume();
+    }
+

jasonLaster avatar Jan 20 '18 21:01 jasonLaster

Hey @zaggy still interested?

jasonLaster avatar Jan 25 '18 02:01 jasonLaster

Hey, @zaggy i'm un-assigning you as it's been a month. Feel free to-reclaim it.

jasonLaster avatar Mar 07 '18 21:03 jasonLaster

This is a really cool issue that I would be happy to mentor someone on

jasonLaster avatar Mar 16 '18 14:03 jasonLaster

/claim

Sekhmet avatar Apr 16 '18 20:04 Sekhmet

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Apr 16 '18 20:04 claim

/unclaim

I unclaim myself as I'm short on time currently, and don't want to block this issue for others.

Sekhmet avatar May 05 '18 13:05 Sekhmet

Done :+1:

claim avatar May 05 '18 13:05 claim

/claim

rohanprasad avatar Oct 01 '18 17:10 rohanprasad

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Oct 01 '18 17:10 claim

Hey @jasonLaster, I would like to work on this. Can you guide me which places to look at to better understand the flow? Thanks!

rohanprasad avatar Oct 01 '18 18:10 rohanprasad

sure. ping me on slack if you want to jump on a call.

the best thing to do, i think is to find a way to fake it in the paused action and then play with it

jasonLaster avatar Oct 01 '18 19:10 jasonLaster

@rohanprasad Is this something you're still looking into?

loganfsmyth avatar Oct 22 '18 19:10 loganfsmyth

@loganfsmyth sorry, I am unable to find time to look into this issue. Unclaiming for now.

rohanprasad avatar Oct 23 '18 06:10 rohanprasad

/unclaim

rohanprasad avatar Oct 23 '18 06:10 rohanprasad

Done :+1:

claim avatar Oct 23 '18 06:10 claim