Faculty of Information Technology
Software Engineering Group

Ticket #200: issue_200_trace_v1.ps1

File issue_200_trace_v1.ps1, 2.8 KB (added by Jan Vrany, 5 years ago)
Line 
1#
2# To run execute following in command line:
3#
4#    powershell -ExecutionPolicy Unrestricted \path\to\win32-trace.ps1
5#
6
7Param(       
8    [String]$Exec = '.\stx.com',
9    [ValidateScript({Test-Path -LiteralPath $_})]
10    [String]$LogDirectoryPath
11)
12
13if ( (Get-Command $Exec -ErrorAction SilentlyContinue) -eq $Null ) {
14    Write-Host "ERROR: '$Exec' not found."
15    exit   
16}
17
18if ( (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
24if ( (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
33if ($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 |
44ObjectMemory class compile:
45'printHeapInfo
46    <cdecl: void "__dumpSpaceInfo__" () module: "librun">   
47    self primitiveFailed
48'.
49t := 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].
67Stdout nextPutLine: 'Passed'.
68Smalltalk exit:0"
69"@ | Out-File $CrashScript -Encoding ASCII
70
71
72# procmon.exe /NoFilter /Quiet /BackingFile "$LogDirectory\$ProgName.$Timestamp.pml"
73Write-Host "Starting $ProgName..."
74start $Exec -RedirectStandardError $CrashStderr -a "--load $CrashScript"
75Write-Host "Press 'Enter' once  you see a message in the other window"
76Write-Host "telling you to do so"
77Read-Host 
78vmmap -64 -p $ProgName "$LogDirectory\stx_issue_200.$Timestamp.mmp" | Out-Null
79# procmon.exe /Terminate /PagingFile | Out-Null
80
81Write-Host ""
82Write-Host "All logs are saved in:"
83Write-Host ""
84Write-Host "    $LogDirectory"
85Write-Host ""
86Write-Host "Please make a .zip of it and attach it to issue #200 at:"
87Write-Host ""
88Write-Host "    https://swing.fit.cvut.cz/projects/stx-jv/ticket/200"
89Write-Host ""
90Write-Host "Press 'Enter'"
91Read-Host 
92
93
94