steam_helper: Add PROTON_WAIT_ATTACH for debuggers to attach to game process at startup

CW-Bug-Id: #19567
This commit is contained in:
Andrew Eikum 2021-10-21 09:42:40 -05:00 committed by Arkadiusz Hiler
parent 2983a44781
commit 8d9c45a6f6
2 changed files with 23 additions and 0 deletions

View File

@ -299,6 +299,7 @@ the Wine prefix. Removing the option will revert to the previous behavior.
| | `PROTON_LOG_DIR` | Output log files into the directory specified. Defaults to your home directory. |
| | `PROTON_DUMP_DEBUG_COMMANDS` | When running a game, Proton will write some useful debug scripts for that game into `$PROTON_DEBUG_DIR/proton_$USER/`. |
| | `PROTON_DEBUG_DIR` | Root directory for the Proton debug scripts, `/tmp` by default. |
| | `PROTON_WAIT_ATTACH` | Wait for a debugger to attach to steam.exe before launching the game process. To attach to the game process at startup, debuggers should be set to follow child processes. |
| | `PROTON_CRASH_REPORT_DIR` | Write crash logs into this directory. Does not clean up old logs, so may eat all your disk space eventually. |
| `wined3d` | `PROTON_USE_WINED3D` | Use OpenGL-based wined3d instead of Vulkan-based DXVK for d3d11, d3d10, and d3d9. |
| `nod3d11` | `PROTON_NO_D3D11` | Disable `d3d11.dll`, for d3d11 games which can fall back to and run better with d3d9. |

View File

@ -62,6 +62,12 @@ EXTERN_C HANDLE CDECL __wine_make_process_system(void);
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
static bool env_nonzero(const char *env)
{
const char *v = getenv(env);
return v != NULL && *v && v[0] != '0';
}
static void set_active_process_pid(void)
{
DWORD pid = GetCurrentProcessId();
@ -1177,6 +1183,22 @@ int main(int argc, char *argv[])
setup_steam_registry();
setup_steam_files();
if (env_nonzero("PROTON_WAIT_ATTACH"))
{
unsigned int sleep_count = 0;
WINE_TRACE("PROTON_WAIT_ATTACH is set, waiting for debugger...\n");
while (!IsDebuggerPresent())
{
Sleep(100);
++sleep_count;
if (sleep_count >= 10)
{
WINE_TRACE("still waiting for debugger...\n");
sleep_count = 0;
}
}
}
wait_handle = __wine_make_process_system();
game_process = TRUE;
}