-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetPathAlias.bat
More file actions
178 lines (157 loc) · 6.08 KB
/
setPathAlias.bat
File metadata and controls
178 lines (157 loc) · 6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
@if {"%_Echo%"}=={"1"} ( @echo on ) else ( @echo off )
echo calling %~f0
rem set _Debug=1
if defined _Debug (
cd /d "%~dp0"
rem copy test context to below file to simple the test procedure.
rem type D:\work\shenxiaolong\core\shell_script\batch_env\Windbg\script\test\tt.xt | clip
echo.
powershell Get-Clipboard
echo.
)
set dbgFile=%temp%\%~n0.dbg
echo set windbg path alais : %dbgFile%
call :parseClip
call :processNatvisPath
call :checkTargetPath
call :checkUserCustomized
echo.
type "%dbgFile%" | find /i "aS "
echo.
goto :END
:checkTargetPath
rem for live-debug, there is not target path ourput for windbg command "||"
if defined targetFullPath goto :eof
if defined exeFolderPath call :processLine.target.add "%exeFolderPath%\%exeModuleName%.exe"
if defined targetFullPath goto :eof
if defined dumpFolderPath call :processLine.target.add "%dumpFolderPath%\%dumpModuleName%"
if defined _Debug echo targetFullPath=%targetFolderPath%
goto :eof
:checkUserCustomized
:: startCmds_user and endCmds_user will be used in startCmds.dbg
if defined startCmds_user call :addWindbgVariable startCmds_user
if defined endCmds_user call :addWindbgVariable endCmds_user
:: userRepo will be used in LoadSrc.dbg
if defined userRepo call :addWindbgVariable userRepo
:: vsVer will be used in LoadSrc_VS.dbg
if defined vsVer call :addWindbgVariable vsVer
if defined SpecVars call :checkUserCustomized.SpecVars %SpecVars:;= %
goto :eof
:checkUserCustomized.SpecVars
if defined %~1 call :addWindbgVariable %~1
if defined %~2 call :addWindbgVariable %~2
if defined %~3 call :addWindbgVariable %~3
if defined %~4 call :addWindbgVariable %~4
if defined %~5 call :addWindbgVariable %~5
if defined %~6 call :addWindbgVariable %~6
if defined %~7 call :addWindbgVariable %~7
if defined %~8 call :addWindbgVariable %~8
if defined %~9 call :addWindbgVariable %~9
goto :eof
:processNatvisPath
call "%~dps0..\..\tools_vs.bat" vsInstallPath newest newestVsPath
if defined _Debug echo newestVsPath=%newestVsPath%
if defined newestVsPath call :processNatvisPath.add "%newestVsPath%\Common7\Packages\Debugger\Visualizers"
goto :eof
:processNatvisPath.add
if defined natvisPath goto :eof
set natvisPath=%~fs1
call :addWindbgVariable natvisPath
@goto :eof
:parseClip
echo .echo [%date% %time%] loading alais from '%dbgFile%' > "%dbgFile%"
for /f "tokens=*" %%i in ('powershell Get-Clipboard ^| find /i "examine name:"') do call :processLine.image "%%i"
for /f "tokens=*" %%i in ('powershell Get-Clipboard ^| find /i "attach name:"') do call :processLine.image "%%i"
for /f "tokens=*" %%i in ('powershell Get-Clipboard ^| find /i "dump: "') do call :processLine.target "%%i"
for /f "tokens=*" %%i in ('powershell Get-Clipboard ^| find /i "command line: "') do call :processLine.commandLine %%i
::for /f delims^=^"^ tokens^=^2^,^4^,^6 %%i in ('powershell Get-Clipboard ^| find /i "command line: "') do call :processLine.commandLine "%%~i" "%%~j" "%%~k"
goto :eof
:processLine.image
set "_line=%~1"
set "_line=%_line:*name: =%"
if defined _Debug echo %0 : _line="%_line%"
call :processLine.image.add "%_line%"
goto :eof
:processLine.image.add
if defined exePathDefined goto :eof
@set "tmpDir=%~dps1"
set exeFolderPath=%tmpDir:~0,-1%
call :addWindbgVariable exeFolderPath
set exeModuleName=%~n1
call :addWindbgVariable exeModuleName
set "exePathDefined=%~f1"
@goto :eof
:processLine.target
if defined targetModuleName goto :eof
set "_line=%~1"
set "_line=%_line:*: =%"
if defined _Debug echo %0 : _line=%_line%
call :processLine.target.add "%_line%"
goto :eof
:processLine.target.add
if defined targetFolderPath goto :eof
set "targetFullPath=%~f1"
call :addWindbgVariable targetFullPath
@set "tmpDir=%~dp1"
set targetFolderPath=%tmpDir:~0,-1%
call :addWindbgVariable targetFolderPath
set targetModuleName=%~nx1
call :addWindbgVariable targetModuleName
@goto :eof
:processLine.commandLine
if defined _Debug echo %0 : %*
set windbgCmdLine=%*
call :processLine.commandLine.onePath "%windbgCmdLine:"=" & call :processLine.commandLine.onePath "%"
goto :eof
:processLine.commandLine.onePath
if not exist "%~1" goto :eof
rem echo %0 : %*
set "lowerFileName=%~nx1"
set "lowerExtName=%~x1"
call :toLower lowerFileName
call :toLower lowerExtName
set "fileFolder=%~dp1"
set "fileFolder=%fileFolder:~0,-1%"
set "fileName=%~nx1"
if {"%lowerFileName%"}=={"windbg.exe"} call :processLine.commandLine.add.windbgPath "%fileFolder%" "%fileName%"
if {"%lowerExtName%"}=={".log"} call :processLine.commandLine.add.logFullPath "%fileFolder%" "%fileName%"
if {"%lowerExtName%"}=={".dmp"} call :processLine.commandLine.add.dumpPath "%fileFolder%" "%fileName%"
if {"%lowerExtName%"}=={".exe"} if not {"%lowerFileName%"}=={"windbg.exe"} call :processLine.image.add "%fileFolder%\%fileName%"
goto :eof
:processLine.commandLine.add.windbgPath
if defined windbgFolderPath goto :eof
set windbgFolderPath=%~s1
call :addWindbgVariable windbgFolderPath
set windbgExeMode=%~n1
call :addWindbgVariable windbgExeMode
@goto :eof
:processLine.commandLine.add.dumpPath
if defined dumpFolderPath goto :eof
set dumpFolderPath=%~s1
call :addWindbgVariable dumpFolderPath
set dumpModuleName=%~n2
call :addWindbgVariable dumpModuleName
@goto :eof
:processLine.commandLine.add.logFullPath
if defined logFullPath goto :eof
set logFullPath=%~sf1\%~2
call :addWindbgVariable logFullPath
@goto :eof
::*************************************************************************
:addWindbgVariable
call set varVal=%%%~1%%
(
@set /p =aS ${/v:%~1} %varVal%;<nul
@echo.
) >> "%dbgFile%"
@goto :eof
:toLower
for %%a in ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i"
"J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r"
"S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z" "?=?"
"?=?" "จน=จน") do (
call set %~1=%%%~1:%%~a%%
)
goto :eof
:END
echo leave %~f0