mirror of
https://github.com/servo/servo
synced 2026-05-05 06:32:13 +02:00
script: Add new worker globals as debuggees (#38551)
to debug workers in a page with the [SpiderMonkey Debugger API](https://firefox-source-docs.mozilla.org/js/Debugger/), we need to pass the worker’s global object to [Debugger.prototype.**addDebuggee()**](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.html#adddebuggee-global). we could pick up the global via the [onNewGlobalObject() hook](https://firefox-source-docs.mozilla.org/js/Debugger/Debugger.html#onnewglobalobject-global), but if our script system passes the global to the debugger script instead, we can later add details like the PipelineId that will help servo identify debuggees that the API is notifying us about (#38334). this patch creates a debugger global in worker threads, runs the debugger script in those new globals, and plumbs new worker globals from those threads into addDebuggee() via the debugger script. since worker threads can’t generate PipelineId values, but they only ever run workers on behalf of one pipeline, we use that pipeline’s PipelineId as the PipelineId of the debugger global, rather than generating a unique PipelineId like we do in script threads. Testing: will undergo many automated tests in #38334 Fixes: part of #36027 Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
@@ -12,7 +12,9 @@
|
||||
|
||||
use core::fmt;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use std::net::TcpStream;
|
||||
use std::str::FromStr;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use base::cross_process_instant::CrossProcessInstant;
|
||||
@@ -488,6 +490,18 @@ impl StartedTimelineMarker {
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub struct WorkerId(pub Uuid);
|
||||
impl Display for WorkerId {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
impl FromStr for WorkerId {
|
||||
type Err = uuid::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(Self(s.parse()?))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
||||
Reference in New Issue
Block a user