hcttrace.cmd 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. @echo off
  2. if "%1"=="/?" goto :showhelp
  3. if "%1"=="-?" goto :showhelp
  4. if "%1"=="-help" goto :showhelp
  5. if "%1"=="--help" goto :showhelp
  6. setlocal
  7. if "%HLSL_SRC_DIR%"=="" (
  8. echo Missing source directory.
  9. if exist %~dp0..\..\LLVMBuild.txt (
  10. set HLSL_SRC_DIR=%~dp0..\..
  11. echo Source directory deduced to be %~dp0..\..
  12. ) else (
  13. exit /b 1
  14. )
  15. )
  16. set _TRACE_SESSION_NAME=hctetwsession
  17. if "%_PROVIDER_GUIDS%" == "" (
  18. echo _PROVIDER_GUIDS not set - setting to dxcompiler provider.
  19. set _PROVIDER_GUIDS=5c65fe8c-9f96-4bfd-9a87-9f8ebd45da64
  20. ) else (
  21. echo _PROVIDER_GUIDS already set - appending dxcompiler providers.
  22. set _PROVIDER_GUIDS=%_PROVIDER_GUIDS%+5c65fe8c-9f96-4bfd-9a87-9f8ebd45da64
  23. )
  24. set _TRACE_FILENAME=%TEMP%\hctetwsession.etl
  25. if not "%2"=="" (
  26. set _TRACE_FILENAME=%2
  27. )
  28. if "%1"=="-start" (
  29. call :do_start
  30. ) else if "%1"=="-stop" (
  31. call :do_stop
  32. ) else if "%1"=="-view" (
  33. call :do_view
  34. ) else (
  35. echo Unknown command.
  36. goto :showhelp
  37. )
  38. goto :eof
  39. :do_start
  40. xperf -start %_TRACE_SESSION_NAME% -on %_PROVIDER_GUIDS% -f %_TRACE_FILENAME%
  41. if errorlevel 1 (
  42. echo xperf command failed to start the session
  43. exit /b 1
  44. )
  45. exit /b 0
  46. :do_stop
  47. xperf -stop %_TRACE_SESSION_NAME%
  48. if errorlevel 1 (
  49. echo xperf command failed to stop the session
  50. exit /b 1
  51. )
  52. exit /b 0
  53. :do_view
  54. if not exist %_TRACE_FILENAME% (
  55. echo %_TRACE_FILENAME% does not exist.
  56. echo Consider running hcttrace -start
  57. exit /b 1
  58. )
  59. tracerpt %_TRACE_FILENAME% -import %HLSL_SRC_DIR%\include\dxc\Tracing\dxcetw.man -y -o %_TRACE_FILENAME%.xml
  60. if errorlevel 1 (
  61. echo Failed to generate trace report.
  62. exit /b 1
  63. )
  64. rem Move to location of prior file.
  65. rem cscript //Nologo %HLSL_SRC_DIR%\utils\hct\hcttracei.js /i:%_TRACE_FILENAME%.xml
  66. where python.exe 1>nul 2>nul
  67. if errorlevel 1 (
  68. rem TODO - discover rather than hard-code
  69. %SystemDrive%\Python27\python.exe %HLSL_SRC_DIR%\utils\hct\hcttracei.py %_TRACE_FILENAME%.xml
  70. ) else (
  71. python.exe %HLSL_SRC_DIR%\utils\hct\hcttracei.py %_TRACE_FILENAME%.xml
  72. )
  73. exit /b 0