Compare commits

...

9 Commits

Author SHA1 Message Date
Delan Azabani
b051dcceb4 Prepare program for future subcommands
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 20:37:08 +08:00
Delan Azabani
a4ce1d674b Avoid crashing due to non-deterministic updateConfiguration order
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:59 +08:00
Delan Azabani
4cc58eb1b2 Set tracing to RUST_LOG=trace by default
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:58 +08:00
Delan Azabani
8f49b78678 Allow records to be commented out with //
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:58 +08:00
Delan Azabani
8040a51d07 Treat missing queues as empty queues
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:57 +08:00
Delan Azabani
35447e0c12 Split resources-available-array by watchResources resourceTypes
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:57 +08:00
Delan Azabani
56e13ac4a8 Forgive client requests we have no reply for
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:56 +08:00
Delan Azabani
02b9ab09c5 Handle some types of spontaneous messages
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:55 +08:00
Delan Azabani
091874e1ae Devtools replay tool
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-03-31 15:41:46 +08:00
6 changed files with 1020 additions and 0 deletions

1
etc/devtools-tools/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

686
etc/devtools-tools/Cargo.lock generated Normal file
View File

@@ -0,0 +1,686 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "addr2line"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
dependencies = [
"anstyle",
"once_cell",
"windows-sys",
]
[[package]]
name = "backtrace"
version = "0.3.71"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "cc"
version = "1.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
dependencies = [
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "color-eyre"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f1885697ee8a177096d42f158922251a41973117f6d8a234cee94b9509157b7"
dependencies = [
"backtrace",
"color-spantrace",
"eyre",
"indenter",
"once_cell",
"owo-colors",
"tracing-error",
]
[[package]]
name = "color-spantrace"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6eee477a4a8a72f4addd4de416eb56d54bc307b284d6601bafdee1f4ea462d1"
dependencies = [
"once_cell",
"owo-colors",
"tracing-core",
"tracing-error",
]
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "devtools-tools"
version = "0.1.0"
dependencies = [
"clap",
"jane-eyre",
"serde",
"serde-jsonlines",
"serde_json",
"tracing",
"tracing-subscriber 0.3.19",
]
[[package]]
name = "eyre"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
dependencies = [
"indenter",
"once_cell",
]
[[package]]
name = "gimli"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "jane-eyre"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ccd957c837e264dcbc6e75b58fcf85fd329a66e4836f820779c40563a2d0be0"
dependencies = [
"color-eyre",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "log"
version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata 0.1.10",
]
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "miniz_oxide"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
dependencies = [
"adler",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "object"
version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owo-colors"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2386b4ebe91c2f7f51082d4cefa145d030e33a1842a96b12e4885cc3c01f7a55"
[[package]]
name = "pin-project-lite"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]]
name = "proc-macro2"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.4.9",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "rustc-demangle"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "ryu"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]]
name = "serde"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde-jsonlines"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "013e069239d98648ea43a9c01845b381445e88de08b5a895ef9302e3bffde03d"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "serde_derive"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"itoa",
"memchr",
"ryu",
"serde",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "smallvec"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thread_local"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
dependencies = [
"cfg-if",
"once_cell",
]
[[package]]
name = "tracing"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-error"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4d7c0b83d4a500748fa5879461652b361edf5c9d51ede2a2ac03875ca185e24"
dependencies = [
"tracing",
"tracing-subscriber 0.2.25",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
dependencies = [
"sharded-slab",
"thread_local",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "valuable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

View File

@@ -0,0 +1,15 @@
[workspace]
[package]
name = "devtools-tools"
version = "0.1.0"
edition = "2024"
[dependencies]
clap = { version = "4.5.34", features = ["derive"] }
jane-eyre = "0.3.0"
serde = { version = "1.0.219", features = ["derive"] }
serde-jsonlines = "0.7.0"
serde_json = "1.0.140"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }

View File

@@ -0,0 +1,201 @@
use std::{
collections::BTreeMap,
fs::File,
io::{BufReader, Read},
net::TcpListener,
};
use jane_eyre::eyre;
use serde_json::Value;
use serde_jsonlines::BufReadExt;
use tracing::{debug, info, warn};
use crate::protocol::{
DevtoolsRead, DevtoolsWrite, EmptyResponse, Message, ResourcesAvailableArray, WrappedMessage,
};
#[derive(clap::Args, Debug)]
pub struct Replay {
json_path: String,
}
pub fn main(args: Replay) -> eyre::Result<()> {
// Allow records to be commented out by prefixing the line with `//`.
let mut file = String::default();
File::open(args.json_path)?.read_to_string(&mut file)?;
let file = file
.split_terminator('\n')
.filter(|x| !x.starts_with("//"))
.collect::<Vec<_>>()
.join("\n");
let file = BufReader::new(file.as_bytes());
// Collect messages by parsing and unwrapping records from `devtools_parser.py --json`.
let mut messages = vec![];
for line in file.json_lines::<WrappedMessage>() {
messages.push(line?.message);
}
let Some((initial_message, subsequent_messages)) = messages.split_first() else {
warn!("No initial message! Exiting");
return Ok(());
};
// Organise client requests into queues by actor.
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
struct Actor(String);
let mut requests: BTreeMap<Actor, Vec<&Message>> = BTreeMap::default();
for message in subsequent_messages.iter() {
if let client_message @ Message::Client { to, .. } = message {
requests
.entry(Actor(to.clone()))
.or_default()
.push(client_message);
}
}
// Match up server responses with client requests, organised into queues by actor and type.
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
struct Type(String);
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
struct ResourceType(String);
let mut transactions: BTreeMap<(Actor, Type), Vec<(&Message, &Message)>> = BTreeMap::default();
let mut spontaneous_messages: BTreeMap<Actor, Vec<&Message>> = BTreeMap::default();
let mut target_available_form_messages = vec![];
let mut frame_update_messages = vec![];
let mut resources_available: BTreeMap<ResourceType, BTreeMap<Actor, Vec<Value>>> =
BTreeMap::default();
for message in subsequent_messages.iter() {
if let server_message @ Message::Server { from, r#type, .. } = message {
// Server messages with types are probably spontaneous messages (often in request/reply/notify pattern),
// e.g. watcher resources-available-array, watcher target-available-form, thread newSource.
// Each of these messages need custom logic defining when they should be replayed, but this logic may not
// be perfect, so its always a *model* of the real behaviour.
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#common-patterns-of-actor-communication>
match r#type.as_deref() {
Some("target-available-form") => {
// watcher target-available-form model: send all on watcher watchTargets
target_available_form_messages.push(message);
},
Some("frameUpdate") => {
// watcher frameUpdate model: send all on watcher watchTargets, after all watcher target-available-form
frame_update_messages.push(message);
},
Some("resources-available-array") => {
// watcher resources-available-array model: on watcher watchResources, send resources with the
// given resourceTypes, from their original actors
let message: ResourcesAvailableArray =
serde_json::from_str(&serde_json::to_string(message)?)?;
for (resource_type, resources) in message.array {
resources_available
.entry(ResourceType(resource_type))
.or_default()
.entry(Actor(from.clone()))
.or_default()
.extend(resources);
}
},
Some(r#type) => {
// TODO: figure out how to realistically replay other spontaneous messages at the right time
// (maybe the client will be completely deterministic, but if not, we need some way to anchor them)
spontaneous_messages
.entry(Actor(from.clone()))
.or_default()
.push(server_message);
warn!(%r#type, ?server_message, "Spontaneous");
},
None => {
let client_message = requests.entry(Actor(from.clone())).or_default().remove(0);
let Message::Client { to, r#type, .. } = client_message else {
unreachable!("Guaranteed by code populating it")
};
let Some(r#type) = r#type else {
panic!("Message from client has no type! {client_message:?}")
};
assert_eq!(to, from);
transactions
.entry((Actor(from.clone()), Type(r#type.clone())))
.or_default()
.push((client_message, server_message));
},
}
}
}
let listen_addr = "0.0.0.0:6080";
info!(%listen_addr, "Listening");
let (mut stream, remote_addr) = TcpListener::bind(listen_addr)?.accept()?;
info!(%remote_addr, "Accepted connection");
let mut reader = BufReader::new(stream.try_clone()?);
stream.write_json_packet(initial_message)?;
loop {
let message = reader.read_packet()?;
debug!(?message);
let Message::Client { to, r#type, rest } = &message else {
panic!("Not a client message: {message:?}")
};
let Some(r#type) = r#type else {
panic!("Message from client has no type! {message:?}")
};
let queue = transactions
.entry((Actor(to.clone()), Type(r#type.clone())))
.or_default();
let Some((expected_message, reply_message)) = (!queue.is_empty()).then(|| queue.remove(0))
else {
warn!(?message, "No reply found for message");
continue;
};
match &**r#type {
"updateConfiguration" => {
// thread-configuration updateConfiguration is sometimes sent in groups of non-deterministic order,
// such as one for shouldPauseOnDebuggerStatement, one for observeWasm and pauseWorkersUntilAttach, and
// one for ignoreCaughtExceptions and pauseOnExceptions. It looks like the response is always empty, so
// lets just send an empty response without checking that the requests came in the correct order.
// TODO: this could make thread-configuration queues go out of sync, if there are other request types
stream.write_json_packet(&EmptyResponse { from: to.clone() })?;
continue;
},
_ => {},
}
// The key idea here is that for each actor and type, the client will send us the same requests.
assert_eq!(&message, expected_message);
stream.write_json_packet(reply_message)?;
match &**r#type {
"watchTargets" => {
for spontaneous_message in target_available_form_messages.drain(..) {
debug!(?spontaneous_message);
stream.write_json_packet(spontaneous_message)?;
}
for spontaneous_message in frame_update_messages.drain(..) {
debug!(?spontaneous_message);
stream.write_json_packet(spontaneous_message)?;
}
},
"watchResources" => {
let resource_types = rest.get("resourceTypes");
let resource_types = resource_types
.iter()
.flat_map(|x| x.as_array())
.flat_map(|x| x.iter())
.flat_map(|x| x.as_str());
for resource_type in resource_types {
let resources = resources_available
.entry(ResourceType(resource_type.to_owned()))
.or_default();
for (actor, resources) in resources.iter() {
stream.write_json_packet(&ResourcesAvailableArray {
from: actor.0.clone(),
r#type: "resources-available-array".to_owned(),
array: vec![(resource_type.to_owned(), resources.clone())],
})?;
}
}
},
_ => {},
}
}
}

View File

@@ -0,0 +1,33 @@
mod command {
pub mod replay;
}
mod protocol;
use core::str;
use clap::Parser;
use jane_eyre::eyre;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
#[derive(clap::Parser, Debug)]
enum Args {
Replay(crate::command::replay::Replay),
}
fn main() -> eyre::Result<()> {
jane_eyre::install()?;
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(
tracing_subscriber::EnvFilter::builder()
.with_default_directive("trace".parse()?)
.from_env()?,
)
.init();
let args = Args::parse();
match args {
Args::Replay(args) => crate::command::replay::main(args),
}
}

View File

@@ -0,0 +1,84 @@
use std::{
collections::BTreeMap,
io::{BufRead, BufReader, Read, Write},
net::TcpStream,
str,
};
use jane_eyre::eyre;
use serde::{Deserialize, Serialize};
use serde_json::Value;
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#id1>
pub trait DevtoolsWrite {
/// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#json-packets>
fn write_json_packet<T: Serialize>(&mut self, message: &T) -> eyre::Result<()>;
}
// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#id1>
pub trait DevtoolsRead {
/// <https://firefox-source-docs.mozilla.org/devtools/backend/protocol.html#json-packets>
fn read_packet(&mut self) -> eyre::Result<Message>;
}
impl DevtoolsWrite for TcpStream {
fn write_json_packet<T: Serialize>(&mut self, message: &T) -> eyre::Result<()> {
let result = serde_json::to_string(message)?;
let result = format!("{}:{}", result.len(), result);
self.write_all(result.as_bytes())?;
Ok(())
}
}
impl DevtoolsRead for BufReader<TcpStream> {
fn read_packet(&mut self) -> eyre::Result<Message> {
let mut prefix = vec![];
self.read_until(b':', &mut prefix)?;
let Some(prefix) = prefix.strip_suffix(b":") else {
panic!("Unexpected EOF")
};
let prefix = str::from_utf8(&prefix)?;
// TODO: implement bulk packets
let len = prefix.parse::<usize>()?;
let mut result = vec![0u8; len];
self.read_exact(&mut result)?;
Ok(serde_json::from_slice(&result)?)
}
}
/// Message wrapped in an object with a `_to` or `_from` field, as generated by `devtools_parser.py --json`.
#[derive(Debug, Deserialize, Serialize)]
pub struct WrappedMessage {
pub message: Message,
}
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[serde(untagged)]
pub enum Message {
Server {
from: String,
r#type: Option<String>,
#[serde(flatten)]
rest: BTreeMap<String, Value>,
},
Client {
to: String,
r#type: Option<String>,
#[serde(flatten)]
rest: BTreeMap<String, Value>,
},
}
#[derive(Debug, Deserialize, Serialize)]
pub struct ResourcesAvailableArray {
pub from: String,
pub r#type: String,
pub array: Vec<(String, Vec<Value>)>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct EmptyResponse {
pub from: String,
}