Skip to content

Commit

Permalink
Updates procdump
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Nov 22, 2024
1 parent 5780d95 commit 53bf014
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions procDump.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,41 @@ Write-Host "Running schema generator"
#$process = Start-Process -FilePath "dotnet.exe" -PassThru -ArgumentList "tool run ModernUOSchemaGenerator -- ModernUO.sln"
$toolProcess = Run-Process "dotnet.exe" "tool run ModernUOSchemaGenerator -- ModernUO.sln"

Write-Host "Running procdump"
$dumpProcess = Run-Process "$procDumpFolder\procdump.exe" "-accepteula -ma -s 5 -n 5 $($toolProcess.Id) $procDumpFolder"
$dumpProcesses = @()
$startTime = Get-Date
while (-not $toolProcess.HasExited) {

# break after 1 minute as the tool process will likely never exit
$currentTime = Get-Date
$elapsedTime = $currentTime - $startTime

if ($elapsedTime.TotalMinutes -ge 1) {
Write-Host "Ending, 1 minute has passed."
break
}

$commandLines = Get-CimInstance Win32_Process | Select-Object ProcessId, Name, CommandLine
foreach ($commandLine in $commandLines) {
if ($dumpProcesses -contains $commandLine.ProcessId) {
continue
}

if ($commandLine.CommandLine -like "*ModernUOSchemaGenerator.dll*") {
$dumpProcesses += $commandLine.ProcessId
Write-Host "Attaching to tool process: $($commandLine.ProcessId), Name: $($commandLine.Name), CommandLine: $($commandLine.CommandLine)"
$dmp = Run-Process "$procDumpFolder\procdump.exe" "-accepteula -ma -s 5 -n 5 $($commandLine.ProcessId) $procDumpFolder\Tool_PROCESSNAME_YYMMDD_HHMMSS.dmp"

}
if ($commandLine.CommandLine -like "*Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll*") {
$dumpProcesses += $commandLine.ProcessId
Write-Host "Attaching to build host process: $($commandLine.ProcessId), Name: $($commandLine.Name), CommandLine: $($commandLine.CommandLine)"
$dmp = Run-Process "$procDumpFolder\procdump.exe" "-accepteula -ma -s 5 -n 5 $($commandLine.ProcessId) $procDumpFolder\BuildHost_PROCESSNAME_YYMMDD_HHMMSS.dmp "
}
}

Write-Host "Waiting for proc dump exit"
while (-not $dumpProcess.HasExited) {
Start-Sleep -Seconds 1
}

Write-Host "Killing schema generator"
$toolProcess.Kill()

# Start-Sleep -Seconds 30
# $dumpProcess = Run-Process "$procDumpFolder\procdump.exe" "-accepteula -ma -h $($toolProcess.Id) $procDumpFolder"
# $dumpProcess.WaitForExit()
if (-not $toolProcess.HasExited) {
$toolProcess.Kill()
}

0 comments on commit 53bf014

Please sign in to comment.