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

This commit is contained in:
Andrew Eikum 2021-10-21 09:42:40 -05:00
parent 0d8ab95d90
commit 801e195cfe
2 changed files with 23 additions and 0 deletions

View File

@ -308,6 +308,7 @@ the Wine prefix. Removing the option will revert to the previous behavior.
| | <tt>PROTON_LOG_DIR</tt> | Output log files into the directory specified. Defaults to your home directory. |
| | <tt>PROTON_DUMP_DEBUG_COMMANDS</tt> | When running a game, Proton will write some useful debug scripts for that game into `$PROTON_DEBUG_DIR/proton_$USER/`. |
| | <tt>PROTON_DEBUG_DIR</tt> | Root directory for the Proton debug scripts, `/tmp` by default. |
| | <tt>PROTON_WAIT_ATTACH</tt> | 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. |
| | <tt>PROTON_CRASH_REPORT_DIR</tt> | Write crash logs into this directory. Does not clean up old logs, so may eat all your disk space eventually. |
| <tt>wined3d</tt> | <tt>PROTON_USE_WINED3D</tt> | Use OpenGL-based wined3d instead of Vulkan-based DXVK for d3d11, d3d10, and d3d9. |
| <tt>nod3d11</tt> | <tt>PROTON_NO_D3D11</tt> | Disable <tt>d3d11.dll</tt>, 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;
}