acdream/tools/cdb/run-issue269-slope-stop.ps1

74 lines
2.6 KiB
PowerShell

param(
[Parameter(Mandatory = $false)]
[ValidatePattern('^[A-Za-z0-9_.-]+$')]
[string]$ScenarioTag = "slope-stop",
[Parameter(Mandatory = $false)]
[ValidateRange(60, 1800)]
[int]$MaxQuanta = 450
)
$ErrorActionPreference = "Stop"
$cdbExe = "C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\cdb.exe"
if (-not (Test-Path -LiteralPath $cdbExe)) {
throw "cdb.exe was not found at '$cdbExe'."
}
$retail = Get-CimInstance Win32_Process -Filter "Name = 'acclient.exe'" |
Select-Object -First 1
if ($null -eq $retail) {
throw "No live retail acclient.exe process was found."
}
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
$checkScript = Join-Path $repoRoot "tools\pdb-extract\check_exe_pdb.py"
$pairing = & py $checkScript $retail.ExecutablePath 2>&1 | Out-String
if ($pairing -notmatch "=== MATCH:") {
throw @"
The live retail executable does not pair with the named-retail PDB.
Process path: $($retail.ExecutablePath)
$pairing
"@
}
$symbolCandidates = @(
(Join-Path $repoRoot "refs"),
(Join-Path $env:USERPROFILE "source\repos\acdream\refs"),
(Join-Path $env:USERPROFILE ".windbg\x86\sym")
)
$symbolPath = $symbolCandidates |
Where-Object { Test-Path -LiteralPath $_ } |
Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($symbolPath)) {
throw "The matching acclient.pdb symbol directory could not be found."
}
$templatePath = Join-Path $PSScriptRoot "issue269-slope-stop.cdb"
$artifactDir = Join-Path $repoRoot "artifacts\issue269"
New-Item -ItemType Directory -Path $artifactDir -Force | Out-Null
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$logPath = Join-Path $artifactDir "$ScenarioTag-retail-$timestamp.log"
$scriptPath = Join-Path $env:TEMP "issue269-$ScenarioTag-$timestamp.cdb"
$script = Get-Content -LiteralPath $templatePath -Raw
$script = $script.Replace('${ARG_LOG_PATH}', $logPath)
$script = $script.Replace('${ARG_SYMBOL_PATH}', $symbolPath)
$script = $script.Replace('${ARG_MAX_QUANTA}', $MaxQuanta.ToString(
[System.Globalization.CultureInfo]::InvariantCulture))
Set-Content -LiteralPath $scriptPath -Value $script -Encoding ASCII
Write-Host "Attaching cdb to retail PID $($retail.ProcessId)."
Write-Host "Capture: $logPath"
Write-Host "Perform the slope run, release movement, and let the character settle."
Write-Host "The probe detaches after $MaxQuanta player physics quanta."
try {
& $cdbExe -p $retail.ProcessId -cf $scriptPath 2>&1 |
Out-File -LiteralPath "$logPath.console" -Encoding ASCII
}
finally {
Remove-Item -LiteralPath $scriptPath -ErrorAction SilentlyContinue
}
Write-Host "Retail capture complete: $logPath"