Make the debugger use the TargetList API and support target switching
Categories
(DevTools :: Debugger, task, P1)
Tracking
(Fission Milestone:M6, firefox73 fixed)
Tracking | Status | |
---|---|---|
firefox73 | --- | fixed |
People
(Reporter: yulia, Assigned: jdescottes)
References
(Blocks 1 open bug)
Details
(Whiteboard: dt-fission-m2-mvp)
Attachments
(5 files, 1 obsolete file)
With the work we are currently doing to support target switching (https://bugzilla.mozilla.org/show_bug.cgi?id=1565263).
With fission, we will not have a consistent top level target, but the debugger currently expects this: https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/client/debugger/src/client/firefox/commands.js#60-61
TabTarget should also be renamed to target, to match the rest of the codebase.
Reporter | ||
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Sounds good. I think the debugger should be fine either way.
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 2•6 years ago
•
|
||
Just reviewed Bug 1565263, and I think we can implement this functionality in two different ways:
- by notifying the debugger that the target has been switched. Which is conceptually similar to telling the debugger to go to a source location.
diff --git a/devtools/client/debugger/panel.js b/devtools/client/debugger/panel.js
index 983c34b05064..62f153b52e68 100644
--- a/devtools/client/debugger/panel.js
+++ b/devtools/client/debugger/panel.js
@@ -68,6 +68,10 @@ DebuggerPanel.prototype = {
return this._store.getState();
},
+ switchTarget: function(newTarget) {
+ // we might need to clear the store in a similar manner to navigate
+ dispatch({ action: "SWITCH-TARGET", target: newTarget })
+ // we might need to re-fetch threads based on the new target
+ dispatch(updateThreads())
+ this.action.switchTarget(newTarget);
+ },
+
getToolboxStore: function() {
return this.toolbox.store;
},
diff --git a/devtools/client/debugger/src/actions/toolbox.js b/devtools/client/debugger/src/actions/toolbox.js
index 6b31c0f428a0..397ac91c412d 100644
--- a/devtools/client/debugger/src/actions/toolbox.js
+++ b/devtools/client/debugger/src/actions/toolbox.js
@@ -40,3 +40,9 @@ export function unHighlightDomElement(grip: Grip) {
return panel.unHighlightDomElement(grip);
};
}
+
+export function switchTarget(newTarget) {
+ return ({ client }: ThunkArgs) => {
+ return client.switchTarget(newTarget);
+ };
+}
diff --git a/devtools/client/debugger/src/client/firefox/commands.js b/devtools/client/debugger/src/client/firefox/commands.js
index 9abca08a9a85..e8b308d0985e 100644
--- a/devtools/client/debugger/src/client/firefox/commands.js
+++ b/devtools/client/debugger/src/client/firefox/commands.js
@@ -65,6 +65,11 @@ function setupCommands(dependencies: Dependencies) {
breakpoints = {};
}
+function switchTarget(newTarget) {
+ currentTarget = newTarget;
+ currentThreadFront = newTarget.threadFront;
+}
+
function hasWasmSupport() {
return supportsWasm;
}
- by emitting an event on the appropriate client/front instance. Either the
DebuggerClient
orRootFront
should work.
diff --git a/devtools/client/debugger/src/client/firefox/commands.js b/devtools/client/debugger/src/client/firefox/commands.js
index 9abca08a9a85..f26233a1c57b 100644
--- a/devtools/client/debugger/src/client/firefox/commands.js
+++ b/devtools/client/debugger/src/client/firefox/commands.js
@@ -63,6 +63,11 @@ function setupCommands(dependencies: Dependencies) {
targets = {};
sourceActors = {};
breakpoints = {};
+
+ debuggerClient.on("switch-target", async newTarget => {
+ currentTarget = newTarget;
+ currentThreadFront = await newTarget.getFront("thread");
+ });
}
function hasWasmSupport() {
@@ -356,9 +361,7 @@ function setEventListenerBreakpoints(ids: string[]) {
}
// eslint-disable-next-line
-async function getEventListenerBreakpointTypes(): Promise<
- EventListenerCategoryList
-> {
+async function getEventListenerBreakpointTypes(): Promise<EventListenerCategoryList> {
let categories;
try {
categories = await currentThreadFront.getAvailableEventBreakpoints();
diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js
index a402630680d4..31989b91c054 100644
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -464,6 +464,13 @@ Toolbox.prototype = {
this.doc.querySelector("window").classList.toggle("dragging");
},
+ async switchToTarget(newTarget) {
+ this._target = newTarget;
+
+ // Notify panels that the target has been switched
+ this.target.client.emit("switch-target", newTarget);
+ },
+
/**
* Get/alter the target of a Toolbox so we're debugging something different.
* See Target.jsm for more details.
If we rely on the toolbox event, the design will be a bit different:
Updated•6 years ago
|
Updated•6 years ago
|
Comment 3•6 years ago
|
||
(In reply to Jason Laster [:jlast] from comment #2)
Just reviewed Bug 1565263, and I think we can implement this functionality in two different ways:
- by notifying the debugger that the target has been switched. Which is conceptually similar to telling the debugger to go to a source location.
I'm still waiting for more feedback, but we will most likely proceed with this way of doing target switching.
We may revisit that later if there is opportunities to clean up things with Target descriptors and the Resource API.
- by emitting an event on the appropriate client/front instance. Either the
DebuggerClient
orRootFront
should work.
I don't see us do something like that, at least in the first iteration. We may later have some target-switching event, but that would be on the target, or the Descriptor (more likely, but for now, we only have that API for Processes and Addons), or the resource API to come.
Comment 5•6 years ago
|
||
No. Bug 1565263 is still in progress.
But the way to support target-switching should be stable:
- Toolbox will call panel's
switchToTarget
method, passing the new target object - when this get called, you should unregister the previous target
- and acknowledge the new. Fetch sources, set RDP event listeners...
You may start crafting a patch based on the attached patches and look at WebConsole integration.
I'm currently revisiting my approach to DebuggerClient destruction, which is the source of complexity here
My hope is that I will finally be able to proceed.
Comment 6•6 years ago
|
||
Bug 1471754 and the TargetList will kill two birds with one stone.
Using TargetList.watchTarget will allow to observe additional targets as well as changes made to the top level target.
This WIP patch https://phabricator.services.mozilla.com/D48861 demonstrate a beginning of usage of this new API for the debugger.
More work will be needed here to properly support it.
Updated•5 years ago
|
Comment 7•5 years ago
|
||
Comment 8•5 years ago
|
||
https://phabricator.services.mozilla.com/D48861 demonstrate a very first approach on how to possibly use the TargetList in the Debugger.
But the integration is imperfect for various reasons:
- First, I hacked something gross to hand over the TargetList down to events and targets module. We should probably replace
currentTarget
byTargetList
. You can derivate the current top level target viatargetList.targetFront
. We should avoid storing thecurrentTarget
anywhere as it can change when navigating to another process, insteadcurrentTarget
should always be a getter mapped totargetList.targetFront
.
Should I open a bug to focus on just that? - Then, I updated
setupEvents
to useTargetList.watchTargets
andupdateProcessTargets
to useTargetList.getAllTargets
. It works, but we do not benefit from TargetList improvements: the fact that it notifies about which Target is available and which Target has been destroyed. InsetupEvents
we callactions.updateThreads
sources, anytime a target is created or destroyed. This will ultimately callupdateProcessTargets
, which will fetch all the targets. We fetch all the threads and them compare the previous and the new list of threads. But this is all unecessary as the two callbacks passed toTargetList.watchTargets
will highlight which thread has been created and which thread has been destroyed.
Should I also open a bug about just that and use this one as a meta? (This would depends on the previous task)
Even if I wrote this WIP patch, I'm not planning to work on this soon. So feel free to pick up that work.
Updated•5 years ago
|
Assignee | ||
Comment 9•5 years ago
|
||
Will give this a try this week.
Updated•5 years ago
|
Assignee | ||
Comment 10•5 years ago
|
||
Assignee | ||
Comment 11•5 years ago
|
||
Depends on D55668
Assignee | ||
Comment 12•5 years ago
|
||
Depends on D55669
Assignee | ||
Comment 13•5 years ago
|
||
Depends on D55670
Assignee | ||
Comment 14•5 years ago
|
||
Attached a few patches. They are focused on the top level target, not on the worker targets.
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 16•5 years ago
|
||
Depends on D55671
Comment 17•5 years ago
|
||
Comment 18•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0e339f6175af
https://hg.mozilla.org/mozilla-central/rev/b6cd01327d3f
https://hg.mozilla.org/mozilla-central/rev/69e7c56dcc30
https://hg.mozilla.org/mozilla-central/rev/ec5d2d6f96bb
https://hg.mozilla.org/mozilla-central/rev/79e6b0610d0d
Updated•5 years ago
|
Description
•