From 87ed36a1e4e685deaf3383c101791f10d6553c78 Mon Sep 17 00:00:00 2001 From: Ben Hillis Date: Wed, 14 Jan 2026 09:26:46 -0800 Subject: [PATCH] diagnostics: combine wprp files in a single one with profiles (#14048) * diagnostics: combine wprp files in a single one with profiles --------- Co-authored-by: Ben Hillis --- .github/copilot-instructions.md | 7 + CONTRIBUTING.md | 6 + diagnostics/collect-networking-logs.ps1 | 17 +- diagnostics/collect-wsl-logs.ps1 | 52 ++- diagnostics/wsl.wprp | 578 +++++++++++++++++++----- diagnostics/wsl_hvsocket.wprp | 172 ------- diagnostics/wsl_networking.wprp | 410 ----------------- diagnostics/wsl_storage.wprp | 123 ----- doc/docs/debugging.md | 8 + 9 files changed, 539 insertions(+), 834 deletions(-) delete mode 100644 diagnostics/wsl_hvsocket.wprp delete mode 100644 diagnostics/wsl_networking.wprp delete mode 100644 diagnostics/wsl_storage.wprp diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 11f406dc..25658a7c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -173,6 +173,13 @@ python3 distributions/validate.py distributions/DistributionInfo.json wpr -start diagnostics\wsl.wprp -filemode # [reproduce issue] wpr -stop logs.ETL + +# Available profiles: +# - WSL (default) - General WSL tracing +# - WSL-Storage - Enhanced storage tracing +# - WSL-Networking - Comprehensive networking tracing +# - WSL-HvSocket - HvSocket-specific tracing +# Example: wpr -start diagnostics\wsl.wprp!WSL -filemode ``` ### Log Analysis Tools diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3cf1e0fd..af52ff9c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,6 +79,12 @@ Set-ExecutionPolicy Bypass -Scope Process -Force ``` The script will output the path of the log file once done. +For specific scenarios, you can use different log profiles: +- `.\collect-wsl-logs.ps1 -LogProfile storage` - Enhanced storage tracing +- `.\collect-wsl-logs.ps1 -LogProfile networking` - Networking-focused tracing +- `.\collect-wsl-logs.ps1 -LogProfile hvsocket` - HvSocket-specific tracing +- `.\collect-networking-logs.ps1` - Alternative script for networking tracing + ### 10) Reporting a Windows crash (BSOD) To collect a kernel crash dump, first run the following command in an elevated command prompt: diff --git a/diagnostics/collect-networking-logs.ps1 b/diagnostics/collect-networking-logs.ps1 index 7fcac4c6..50016281 100644 --- a/diagnostics/collect-networking-logs.ps1 +++ b/diagnostics/collect-networking-logs.ps1 @@ -124,7 +124,8 @@ function Collect-WindowsNetworkState { $folder = "WslNetworkingLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss") mkdir -p $folder -$logProfile = "$folder/wsl_networking.wprp" +$wprpFile = "$folder/wsl.wprp" +$wprpProfile = "WSL-Networking" $networkingBashScript = "$folder/networking.sh" # Detect the super user first. @@ -132,14 +133,14 @@ $networkingBashScript = "$folder/networking.sh" $superUser = & wsl.exe -- id -nu 0 # user name of the super user. # Copy/Download supporting files -if (Test-Path "$PSScriptRoot/wsl_networking.wprp") +if (Test-Path "$PSScriptRoot/wsl.wprp") { - Copy-Item "$PSScriptRoot/wsl_networking.wprp" $logProfile + Copy-Item "$PSScriptRoot/wsl.wprp" $wprpFile } else { - Write-Host -ForegroundColor Yellow "wsl_networking.wprp not found in the current directory. Downloading it from GitHub." - Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile + Write-Host -ForegroundColor Yellow "wsl.wprp not found in the current directory. Downloading it from GitHub." + Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $wprpFile } if (Test-Path "$PSScriptRoot/networking.sh") @@ -183,13 +184,13 @@ if ($RestartWslReproMode) # Start logging. $wprOutputLog = "$folder/wpr.txt" -wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog +wpr.exe -start "$wprpFile!$wprpProfile" -filemode 2>&1 >> $wprOutputLog if ($LastExitCode -Ne 0) { Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it." wpr.exe -cancel 2>&1 >> $wprOutputLog - wpr.exe -start $logProfile -filemode 2>&1 >> $wprOutputLog + wpr.exe -start "$wprpFile!$wprpProfile" -filemode 2>&1 >> $wprOutputLog if ($LastExitCode -Ne 0) { Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)" @@ -309,7 +310,7 @@ if (Test-Path $setupApiPath) Copy-Item $setupApiPath $folder } -Remove-Item $logProfile +Remove-Item $wprpFile Remove-Item $networkingBashScript $logArchive = "$(Resolve-Path $folder).zip" diff --git a/diagnostics/collect-wsl-logs.ps1 b/diagnostics/collect-wsl-logs.ps1 index 6bdd452f..242c2417 100644 --- a/diagnostics/collect-wsl-logs.ps1 +++ b/diagnostics/collect-wsl-logs.ps1 @@ -11,32 +11,44 @@ Set-StrictMode -Version Latest $folder = "WslLogs-" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss") mkdir -p $folder | Out-Null -if ($LogProfile -eq $null -Or ![System.IO.File]::Exists($LogProfile)) +# Check if LogProfile is a custom file path or a profile name +if ($LogProfile -ne $null -And [System.IO.File]::Exists($LogProfile)) { - if ($LogProfile -eq $null) + # User provided a custom .wprp file path - use it directly + $wprpFile = $LogProfile + $wprpProfile = $null # Use default profile in the file +} +else +{ + # Map log profile names to WPRP profile names + $wprpProfile = "WSL" + if ($LogProfile -eq "storage") { - $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" + $wprpProfile = "WSL-Storage" } - elseif ($LogProfile -eq "storage") + elseif ($LogProfile -eq "networking") { - $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_storage.wprp" + $wprpProfile = "WSL-Networking" } elseif ($LogProfile -eq "hvsocket") { - $url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_hvsocket.wprp" + $wprpProfile = "WSL-HvSocket" } - else + elseif ($LogProfile -ne $null) { - Write-Error "Unknown log profile: $LogProfile" + Write-Error "Unknown log profile: $LogProfile. Valid options are: storage, networking, hvsocket, or a path to a custom .wprp file" exit 1 } - $LogProfile = "$folder/wsl.wprp" - try { - Invoke-WebRequest -UseBasicParsing $url -OutFile $LogProfile + # Use the consolidated wsl.wprp file, attempt to use local copy first. + $wprpFile = "$folder/wsl.wprp" + if (Test-Path "$PSScriptRoot/wsl.wprp") + { + Copy-Item "$PSScriptRoot/wsl.wprp" $wprpFile } - catch { - throw + else + { + Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp" -OutFile $wprpFile } } @@ -71,13 +83,23 @@ if (Test-Path $uninstallLogs) $wprOutputLog = "$folder/wpr.txt" -wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog +# Build wpr command - if wprpProfile is set, use profile syntax, otherwise use file only +if ($wprpProfile -ne $null) +{ + $wprCommand = "$wprpFile!$wprpProfile" +} +else +{ + $wprCommand = $wprpFile +} + +wpr.exe -start $wprCommand -filemode 2>&1 >> $wprOutputLog if ($LastExitCode -Ne 0) { Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it." wpr.exe -cancel 2>&1 >> $wprOutputLog - wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog + wpr.exe -start $wprCommand -filemode 2>&1 >> $wprOutputLog if ($LastExitCode -Ne 0) { Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)" diff --git a/diagnostics/wsl.wprp b/diagnostics/wsl.wprp index 53444260..e01386e0 100644 --- a/diagnostics/wsl.wprp +++ b/diagnostics/wsl.wprp @@ -1,37 +1,51 @@ + + - - + + - - - - - - - - - - - - - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -40,129 +54,481 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/diagnostics/wsl_hvsocket.wprp b/diagnostics/wsl_hvsocket.wprp deleted file mode 100644 index 66ed917b..00000000 --- a/diagnostics/wsl_hvsocket.wprp +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/diagnostics/wsl_networking.wprp b/diagnostics/wsl_networking.wprp deleted file mode 100644 index 684cdeb3..00000000 --- a/diagnostics/wsl_networking.wprp +++ /dev/null @@ -1,410 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/diagnostics/wsl_storage.wprp b/diagnostics/wsl_storage.wprp deleted file mode 100644 index 5e0158e5..00000000 --- a/diagnostics/wsl_storage.wprp +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/doc/docs/debugging.md b/doc/docs/debugging.md index 8ea8eecd..6f820e93 100644 --- a/doc/docs/debugging.md +++ b/doc/docs/debugging.md @@ -14,6 +14,14 @@ wpr -start wsl.wprp -filemode wpr -stop logs.ETL ``` +The consolidated `wsl.wprp` file includes multiple profiles for different scenarios: +- `WSL` - General WSL tracing (default) +- `WSL-Storage` - Enhanced storage tracing +- `WSL-Networking` - Comprehensive networking tracing +- `WSL-HvSocket` - HvSocket-specific tracing + +To use a specific profile, append `!ProfileName` to the wprp file, e.g., `wpr -start wsl.wprp!WSL-Networking -filemode` + Once the log file is saved, you can use [WPA](https://apps.microsoft.com/detail/9n58qrw40dfw?hl=en-US&gl=US) to view the logs. Notable ETL providers: