| 1 | @echo off
|
|---|
| 2 | :: PDumpCtl - ProcDump control front-end
|
|---|
| 3 | :: Dump named process/pid or run interactive
|
|---|
| 4 | :: OK to exit to shell and update options
|
|---|
| 5 |
|
|---|
| 6 | :: Copyright (c) 2001, 2006 Steven Levine and Associates, Inc.
|
|---|
| 7 | :: All rights reserved.
|
|---|
| 8 |
|
|---|
| 9 | rem $TLIB$: $ &(#) %n - Ver %v, %f $
|
|---|
| 10 | rem TLIB: $ $
|
|---|
| 11 |
|
|---|
| 12 | :: 27 Jun 01 SHL Baseline
|
|---|
| 13 | :: 21 Jan 04 SHL Add -f -x options
|
|---|
| 14 | :: 14 Jun 05 SHL Add -a option
|
|---|
| 15 | :: 05 Jul 05 SHL Update usage
|
|---|
| 16 | :: 08 Jul 05 SHL Support dec/hex pid and quoted name
|
|---|
| 17 | :: 09 Dec 06 SHL Add sysvm to full mode to allow .m commands
|
|---|
| 18 |
|
|---|
| 19 | on errormsg pause
|
|---|
| 20 | setlocal
|
|---|
| 21 |
|
|---|
| 22 | :: Scan args, I=num A=value X=scratch
|
|---|
| 23 |
|
|---|
| 24 | set D= %+ :: Dump directory
|
|---|
| 25 | set M=a %+ :: Auto/Interactive (a/i)
|
|---|
| 26 | set N= %+ :: Process name
|
|---|
| 27 | set P= %+ :: Pid
|
|---|
| 28 | set T=n %+ :: Normal/Full/eXtended
|
|---|
| 29 |
|
|---|
| 30 | :: N and P mutually exclusive
|
|---|
| 31 |
|
|---|
| 32 | do I = 1 to %[#]
|
|---|
| 33 | set A=%[%I]
|
|---|
| 34 | set X=%@substr[%A,0,1]
|
|---|
| 35 | iff "%X" eq "/" .or. "%X" eq "-" then
|
|---|
| 36 | :: Got switch
|
|---|
| 37 | set X=%@lower[%@substr[%A,1,1]]
|
|---|
| 38 | iff "%X" == "h" .or. "%X" == "?" then
|
|---|
| 39 | goto Help
|
|---|
| 40 | elseiff "%X" == "a" then
|
|---|
| 41 | set T=a
|
|---|
| 42 | elseiff "%X" == "f" then
|
|---|
| 43 | set T=f
|
|---|
| 44 | elseiff "%X" == "i" then
|
|---|
| 45 | set M=i
|
|---|
| 46 | elseiff "%X" == "x" then
|
|---|
| 47 | set T=x
|
|---|
| 48 | else
|
|---|
| 49 | echo Switch %X unexpected
|
|---|
| 50 | goto Usage
|
|---|
| 51 | endiff
|
|---|
| 52 | else
|
|---|
| 53 | :: Got proc/pid - detect/convert decimal to hex
|
|---|
| 54 | set P=%A
|
|---|
| 55 | iff '%@left[1,%P]' == '%="' then
|
|---|
| 56 | set N=%@strip[%=",%P]
|
|---|
| 57 | set P=
|
|---|
| 58 | elseiff "%@left[2,%A]" == "0x" then
|
|---|
| 59 | set P=%@substr[%P,2,100]
|
|---|
| 60 | set X=%@convert[16,16,%P]
|
|---|
| 61 | if "%P" != "%X" ( echo Bad PID %+ goto usage )
|
|---|
| 62 | elseiff "%@left[2, %P]" == "0n" then
|
|---|
| 63 | set P=%@substr[%P,2,100]
|
|---|
| 64 | set X=%@convert[10,10,%P]
|
|---|
| 65 | if "%P" != "%X" ( echo Bad PID %+ goto usage )
|
|---|
| 66 | set P=%@convert[10,16,%P]
|
|---|
| 67 | else
|
|---|
| 68 | :: Try for hext PID
|
|---|
| 69 | set X=%@convert[16,16,%P]
|
|---|
| 70 | if "%P" != "%X" ( set N=%P %+ set P= )
|
|---|
| 71 | endiff
|
|---|
| 72 | endiff
|
|---|
| 73 | enddo
|
|---|
| 74 |
|
|---|
| 75 | if %M == a if "%P %N" == " " ( echo No process/pid selected %+ goto usage )
|
|---|
| 76 |
|
|---|
| 77 | :: Set defaults
|
|---|
| 78 |
|
|---|
| 79 | echo on
|
|---|
| 80 | pdumpusr reset
|
|---|
| 81 | @echo off
|
|---|
| 82 |
|
|---|
| 83 | iff isdir c:\ then
|
|---|
| 84 | set D=c:\
|
|---|
| 85 | elseiff isdir c:\ then
|
|---|
| 86 | set D=c:\
|
|---|
| 87 | elseiff isdir c:\ then
|
|---|
| 88 | set D=c:\
|
|---|
| 89 | else
|
|---|
| 90 | echo Dump directory not found - checked i:\Dumps d:\tmp\Dumps and j:\tmp\Dumps
|
|---|
| 91 | cancel
|
|---|
| 92 | endiff
|
|---|
| 93 |
|
|---|
| 94 | echo.
|
|---|
| 95 | echo on
|
|---|
| 96 | procdump on /l:%D
|
|---|
| 97 | @echo off
|
|---|
| 98 |
|
|---|
| 99 | :: instance Instance data referenced by the process.
|
|---|
| 100 | :: krheaps Kernel Resident Heaps
|
|---|
| 101 | :: ksheaps Kernel Swappable Heaps
|
|---|
| 102 | :: idt Interrupt descriptor table
|
|---|
| 103 | :: laddr Linear address range(s)
|
|---|
| 104 | :: mvdm MVDM instance data for process
|
|---|
| 105 | :: paddr(all) Add physical memory
|
|---|
| 106 | :: private Private code and data referenced by process
|
|---|
| 107 | :: sem Semaphore information for all blocked threads in process
|
|---|
| 108 | :: shared Shared code and data referenced by process
|
|---|
| 109 | :: summ Summary for dumped threads
|
|---|
| 110 | :: sysfs File System data for all processes
|
|---|
| 111 | :: sysio IO subsystem structures (AIRQI, DIRQ, PDD eps, PDD chain)
|
|---|
| 112 | :: sysldr Loader data for all processes
|
|---|
| 113 | :: sysmvdm MVDM data for all VDM and the kernel resident heap
|
|---|
| 114 | :: syspg Physical and Page Memory management records (PF, VP, PTE, PDE)
|
|---|
| 115 | :: syssem SEM data for all blocked threads in system
|
|---|
| 116 | :: syssumm Summary for all threads
|
|---|
| 117 | :: systk Task Management related data for all processes
|
|---|
| 118 | :: sysvm Virtual Memory data for all processes
|
|---|
| 119 |
|
|---|
| 120 | iff "%T" == "a" then
|
|---|
| 121 | :: All physical memory
|
|---|
| 122 | echo on
|
|---|
| 123 | pdumpusr paddr(all)
|
|---|
| 124 | @echo off
|
|---|
| 125 | endiff
|
|---|
| 126 |
|
|---|
| 127 | iff "%T" == "f" then
|
|---|
| 128 | :: Full
|
|---|
| 129 | echo on
|
|---|
| 130 | pdumpusr summ,sysfs,sysldr,private,instance,syssem,sysio
|
|---|
| 131 | @echo off
|
|---|
| 132 | endiff
|
|---|
| 133 |
|
|---|
| 134 | iff "%T" == "x" then
|
|---|
| 135 | :: Extended
|
|---|
| 136 | echo on
|
|---|
| 137 | pdumpusr summ,sysfs,sysldr,private,instance,syssem,sysio
|
|---|
| 138 | pdumpusr shared,update
|
|---|
| 139 | @echo off
|
|---|
| 140 | endiff
|
|---|
| 141 |
|
|---|
| 142 | echo on
|
|---|
| 143 | procdump query
|
|---|
| 144 | @echo off
|
|---|
| 145 |
|
|---|
| 146 | :: Check forced dump request using current settings
|
|---|
| 147 | iff %M=a then
|
|---|
| 148 | procdump query
|
|---|
| 149 | iff "%P" != "" then
|
|---|
| 150 | echo Dumping PID %P
|
|---|
| 151 | procdump force /pid:%P
|
|---|
| 152 | else
|
|---|
| 153 | echo Dumping process %N
|
|---|
| 154 | procdump force /proc:%N
|
|---|
| 155 | endiff
|
|---|
| 156 | procdump off
|
|---|
| 157 | procdump query
|
|---|
| 158 | quit
|
|---|
| 159 | endiff
|
|---|
| 160 |
|
|---|
| 161 | :: Interactive
|
|---|
| 162 |
|
|---|
| 163 | do forever
|
|---|
| 164 | iff "%P" != "" then
|
|---|
| 165 | :: echo.
|
|---|
| 166 | echo PID %P selected
|
|---|
| 167 | echo.
|
|---|
| 168 | elseiff "%N" != "" then
|
|---|
| 169 | :: echo.
|
|---|
| 170 | echo Process %N selected
|
|---|
| 171 | echo.
|
|---|
| 172 | endiff
|
|---|
| 173 | inkey /k"adfhorsvq!?[Esc][Enter]" `D)ump F)ull S)hared A)ll R)eset V)iew O)ff H)elp Q)uit ? ` %%Z
|
|---|
| 174 | echo.
|
|---|
| 175 | iff "%Z" == "q" .or. "%Z" == "" then
|
|---|
| 176 | leave
|
|---|
| 177 | elseiff "%Z" == "@28" then
|
|---|
| 178 | iterate
|
|---|
| 179 | elseiff %Z == a then
|
|---|
| 180 | :: All physical memory
|
|---|
| 181 | echo on
|
|---|
| 182 | pdumpusr reset
|
|---|
| 183 | pdumpusr paddr(all)
|
|---|
| 184 | pdumpusr query
|
|---|
| 185 | @echo off
|
|---|
| 186 | elseiff %Z == d then
|
|---|
| 187 | :: Force dump now
|
|---|
| 188 | iff "%P" != "" then
|
|---|
| 189 | echo Dumping PID %P
|
|---|
| 190 | echo on
|
|---|
| 191 | procdump force /pid:%P
|
|---|
| 192 | @echo off
|
|---|
| 193 | elseiff "%N" != "" then
|
|---|
| 194 | echo Dumping process %N
|
|---|
| 195 | echo on
|
|---|
| 196 | procdump force /proc:%N
|
|---|
| 197 | @echo off
|
|---|
| 198 | else
|
|---|
| 199 | echo No process/pid selected
|
|---|
| 200 | endiff
|
|---|
| 201 | elseiff %Z == f then
|
|---|
| 202 | :: Full
|
|---|
| 203 | echo on
|
|---|
| 204 | :: pdumpusr reset
|
|---|
| 205 | pdumpusr summ,sysfs,private,instance,syssem,sysio,sysldr,sysvm,update
|
|---|
| 206 | pdumpusr query
|
|---|
| 207 | @echo off
|
|---|
| 208 | elseiff %Z == o then
|
|---|
| 209 | :: Off
|
|---|
| 210 | echo on
|
|---|
| 211 | procdump off
|
|---|
| 212 | @echo off
|
|---|
| 213 | elseiff %Z == r then
|
|---|
| 214 | :: Reset to default
|
|---|
| 215 | echo on
|
|---|
| 216 | procdump reset /pid:all
|
|---|
| 217 | procdump on /l:%D
|
|---|
| 218 | pdumpusr reset
|
|---|
| 219 | procdump query
|
|---|
| 220 | @echo off
|
|---|
| 221 | elseiff %Z == v then
|
|---|
| 222 | :: Status
|
|---|
| 223 | echo on
|
|---|
| 224 | procdump query
|
|---|
| 225 | @echo off
|
|---|
| 226 | elseiff %Z == s then
|
|---|
| 227 | :: Add shared
|
|---|
| 228 | echo on
|
|---|
| 229 | pdumpusr shared,update
|
|---|
| 230 | pdumpusr query
|
|---|
| 231 | @echo off
|
|---|
| 232 | elseiff "%Z" == "!" then
|
|---|
| 233 | :: Shell
|
|---|
| 234 | echo.
|
|---|
| 235 | %comspec
|
|---|
| 236 | elseiff "%Z" == "h" .or. "%Z" == "?" then
|
|---|
| 237 | :: Help
|
|---|
| 238 | echo D - Force dump using current settings
|
|---|
| 239 | echo F - Set up for full dump - adds summ,sysfs,sysldr,private,instance,syssem,sysio
|
|---|
| 240 | echo S - Add shared code/data to current settings
|
|---|
| 241 | echo A - Set up to dump all physical memory with paddr(all) - resets other settings
|
|---|
| 242 | echo V - View current settings
|
|---|
| 243 | echo O - Turn off dump facility
|
|---|
| 244 | echo R - Reset to default settings
|
|---|
| 245 | echo H - Display this screen
|
|---|
| 246 | echo Q - Quit
|
|---|
| 247 | echo ? - Display this screen
|
|---|
| 248 | echo ! - Shell
|
|---|
| 249 | else
|
|---|
| 250 | pause Unexpected %Z
|
|---|
| 251 | cancel
|
|---|
| 252 | endiff
|
|---|
| 253 | enddo
|
|---|
| 254 |
|
|---|
| 255 | :: Show exit state
|
|---|
| 256 | echo on
|
|---|
| 257 | procdump query
|
|---|
| 258 | @echo off
|
|---|
| 259 |
|
|---|
| 260 | quit
|
|---|
| 261 |
|
|---|
| 262 | ::=== Usage: Report usage error ===
|
|---|
| 263 |
|
|---|
| 264 | :Usage
|
|---|
| 265 | beep
|
|---|
| 266 | echo Usage: %@lower[%0] `[-?] [-f] [-i] [-x] [procname|hex-pid|dec-pid]`
|
|---|
| 267 | cancel
|
|---|
| 268 |
|
|---|
| 269 | ::=== Help: Show usage help ===
|
|---|
| 270 |
|
|---|
| 271 | :Help
|
|---|
| 272 | echo.
|
|---|
| 273 | echo Usage: %@lower[%0] `[-?] [-f] [-i] [-x] [procname|hex-pid|dec-pid]`
|
|---|
| 274 | echo.
|
|---|
| 275 | echo ` -? This message`
|
|---|
| 276 | echo ` -f Full (default=normal)`
|
|---|
| 277 | echo ` -i Interactive (default=force dump and exit)`
|
|---|
| 278 | echo ` -x Extended, full plus shared (default=normal)`
|
|---|
| 279 | echo.
|
|---|
| 280 | echo ` hex-pid hex pid, optionally prefix 0x`
|
|---|
| 281 | echo ` dec-pid decimal pid, prefix with 0n`
|
|---|
| 282 | echo ` procname Process name, quote if name lots like number`
|
|---|
| 283 | cancel
|
|---|
| 284 |
|
|---|
| 285 | :end
|
|---|