tools_pc/debug.ps1: fix DLL-not-found on launch from a plain shell

The exe links MSYS2 mingw64 DLLs (SDL2, libgcc, libstdc++, libwinpthread,
zlib). Run from a normal PowerShell those aren't on PATH, so gdb reported
"During startup program exited with code 0xc0000135" and nothing ran.
Prepend the mingw64 bin dir (derived from -Gdb) to PATH before launching.

Also relax ErrorActionPreference around the gdb call so its stderr
progress lines don't raise NativeCommandError noise mid-run.

Claude-Session: https://claude.ai/code/session_01UpTM1AcBRJuTetoZNcCD5V
This commit is contained in:
James Dansereau committed 2026-09-01 20:28:13 -04:00
1 parent e69d7b58a9
commit 5baa53eb61
1 file changed
+14
+14
View File
@@ -30,6 +30,15 @@ $ErrorActionPreference = "Stop"
$exe = "build-pc\ge007.x86_64.exe" $exe = "build-pc\ge007.x86_64.exe"
if (-not (Test-Path $Gdb)) { throw "gdb not found at $Gdb (pass -Gdb <path>)" } if (-not (Test-Path $Gdb)) { throw "gdb not found at $Gdb (pass -Gdb <path>)" }
# The exe links MSYS2 mingw64 DLLs (SDL2, libgcc, libstdc++, libwinpthread,
# zlib). Run from a plain PowerShell those aren't on PATH and the game dies at
# startup with 0xc0000135 (DLL not found) -- gdb reports "During startup program
# exited with code 0xc0000135". Prepend the mingw64 bin dir so it resolves.
$MingwBin = Split-Path $Gdb
if ((Test-Path $MingwBin) -and (($env:PATH -split ';') -notcontains $MingwBin)) {
$env:PATH = "$MingwBin;$env:PATH"
}
if (-not $NoBuild) { if (-not $NoBuild) {
Write-Host "building (bash build-pc.sh ntsc-final) - pass -NoBuild to skip" -ForegroundColor DarkGray Write-Host "building (bash build-pc.sh ntsc-final) - pass -NoBuild to skip" -ForegroundColor DarkGray
& "C:\msys64\usr\bin\bash.exe" -lc "cd '$($PWD -replace '\\','/')' && export PATH=/c/msys64/mingw64/bin:`$PATH && ./build-pc.sh ntsc-final" & "C:\msys64\usr\bin\bash.exe" -lc "cd '$($PWD -replace '\\','/')' && export PATH=/c/msys64/mingw64/bin:`$PATH && ./build-pc.sh ntsc-final"
@@ -64,7 +73,12 @@ $gdbArgs = @(
) + $GameArgs ) + $GameArgs
Write-Host "launching under gdb - play until it crashes, output -> gdb.txt" -ForegroundColor Green Write-Host "launching under gdb - play until it crashes, output -> gdb.txt" -ForegroundColor Green
# gdb writes progress to stderr; with ErrorActionPreference=Stop + 2>&1 that
# raises NativeCommandError noise mid-run. Relax it just for the launch.
$prevEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
& $Gdb @gdbArgs 2>&1 | Tee-Object -FilePath gdb.txt | Out-Null & $Gdb @gdbArgs 2>&1 | Tee-Object -FilePath gdb.txt | Out-Null
$ErrorActionPreference = $prevEAP
Write-Host "`n===================== RESULT =====================" -ForegroundColor Yellow Write-Host "`n===================== RESULT =====================" -ForegroundColor Yellow
$fatal = Select-String -Path gdb.txt -Pattern "FATAL|Unknown GBI|assertion|abort\(\)" | Select-Object -First 5 $fatal = Select-String -Path gdb.txt -Pattern "FATAL|Unknown GBI|assertion|abort\(\)" | Select-Object -First 5