1 | # |
---|
2 | # To run execute following in command line: |
---|
3 | # |
---|
4 | # powershell -ExecutionPolicy Unrestricted \path\to\win32-trace.ps1 |
---|
5 | # |
---|
6 | |
---|
7 | Param( |
---|
8 | [String]$Exec = '.\stx.com', |
---|
9 | [ValidateScript({Test-Path -LiteralPath $_})] |
---|
10 | [String]$LogDirectoryPath |
---|
11 | ) |
---|
12 | |
---|
13 | if ( (Get-Command $Exec -ErrorAction SilentlyContinue) -eq $Null ) { |
---|
14 | Write-Host "ERROR: '$Exec' not found." |
---|
15 | exit |
---|
16 | } |
---|
17 | |
---|
18 | if ( (Get-Command "procmon.exe" -ErrorAction SilentlyContinue) -eq $Null ) { |
---|
19 | Write-Host "ERROR: 'procmon.exe' not in PATH." |
---|
20 | Write-Host " Add directory with Sysinternals tools to your PATH" |
---|
21 | exit |
---|
22 | } |
---|
23 | |
---|
24 | if ( (Get-Command "vmmap.exe" -ErrorAction SilentlyContinue) -eq $Null ) { |
---|
25 | Write-Host "ERROR: 'vmmap.exe' not in PATH." |
---|
26 | Write-Host " Add directory with Sysinternals tools to your PATH" |
---|
27 | exit |
---|
28 | } |
---|
29 | |
---|
30 | $Timestamp = Get-Date -UFormat "%Y-%m-%d-%H-%M-%S" |
---|
31 | $ProgName = "stx.com" |
---|
32 | |
---|
33 | if ($LogDirectoryPath -ne "") { |
---|
34 | $LogDirectory = Get-Item -Path $LogDirectoryPath |
---|
35 | } else { |
---|
36 | $LogDirectory = New-Item -ItemType directory -Path "stx_issue_200-$timestamp" |
---|
37 | } |
---|
38 | |
---|
39 | $CrashScript = "$LogDirectory\stx_issue_200.$Timestamp.st" |
---|
40 | $CrashStderr = "$LogDirectory\stx_issue_200.$Timestamp.stderr.txt" |
---|
41 | |
---|
42 | @" |
---|
43 | | t | |
---|
44 | ObjectMemory class compile: |
---|
45 | 'printHeapInfo |
---|
46 | <cdecl: void "__dumpSpaceInfo__" () module: "librun"> |
---|
47 | self primitiveFailed |
---|
48 | '. |
---|
49 | t := Unicode16String new: 46. |
---|
50 | [ |
---|
51 | 1 to: 30 do:[:i | |
---|
52 | Stdout nextPutLine: i printString , '-', (t size*2) printString. |
---|
53 | Stderr nextPutLine: i printString , '-', (t size*2) printString. |
---|
54 | Stderr flush. |
---|
55 | ObjectMemory printHeapInfo. |
---|
56 | Stderr flush. |
---|
57 | i == 25 ifTrue:[ |
---|
58 | Stdout nextPutLine: 'Press enter within 10 seconds in the other window'. |
---|
59 | Delay waitForSeconds: 10 |
---|
60 | ]. |
---|
61 | t := t , t |
---|
62 | ] |
---|
63 | ] on: Error do:[:ex | |
---|
64 | Stdout nextPutLine: ex description. |
---|
65 | Smalltalk exit: 1. |
---|
66 | ]. |
---|
67 | Stdout nextPutLine: 'Passed'. |
---|
68 | Smalltalk exit:0" |
---|
69 | "@ | Out-File $CrashScript -Encoding ASCII |
---|
70 | |
---|
71 | |
---|
72 | # procmon.exe /NoFilter /Quiet /BackingFile "$LogDirectory\$ProgName.$Timestamp.pml" |
---|
73 | Write-Host "Starting $ProgName..." |
---|
74 | start $Exec -RedirectStandardError $CrashStderr -a "--load $CrashScript" |
---|
75 | Write-Host "Press 'Enter' once you see a message in the other window" |
---|
76 | Write-Host "telling you to do so" |
---|
77 | Read-Host |
---|
78 | vmmap -64 -p $ProgName "$LogDirectory\stx_issue_200.$Timestamp.mmp" | Out-Null |
---|
79 | # procmon.exe /Terminate /PagingFile | Out-Null |
---|
80 | |
---|
81 | Write-Host "" |
---|
82 | Write-Host "All logs are saved in:" |
---|
83 | Write-Host "" |
---|
84 | Write-Host " $LogDirectory" |
---|
85 | Write-Host "" |
---|
86 | Write-Host "Please make a .zip of it and attach it to issue #200 at:" |
---|
87 | Write-Host "" |
---|
88 | Write-Host " https://swing.fit.cvut.cz/projects/stx-jv/ticket/200" |
---|
89 | Write-Host "" |
---|
90 | Write-Host "Press 'Enter'" |
---|
91 | Read-Host |
---|
92 | |
---|
93 | |
---|
94 | |
---|