Microsoft MVP성태의 닷넷 이야기
디버깅 기술: 178. windbg - 디버그 시작 시 스크립트 실행 [링크 복사], [링크+제목 복사],
조회: 9752
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

windbg - 디버그 시작 시 스크립트 실행

windbg를 사용하다 보면 x86/x64 구분이 필요하게 되는 경우가 많습니다. 가령 pykd 확장만 해도,

windbg에서 python 스크립트 실행하는 방법 - pykd
; https://www.sysnet.pe.kr/2/0/11227

x86과 x64 DLL로 나뉘기 때문에 로컬에 다음과 같이 구분해서 저장하게 되는데,

  • c:\temp\x64\pykd.dll
  • c:\temp\x86\pykd.dll

이로 인해 해당 확장을 로드할 때마다 일일이 경로를 적어야 하는 불편함이 있습니다.

.load c:\temp\x64\pykd.dll

물론, 기본 확장 경로에 x64와 x86이 구분되는 경로가 있으므로 그곳을 활용하면 ".load pykd.dll"처럼 사용할 수 있지만 이게 좀 불편한 면이 있습니다. 가령 %PROGRAMFILES% 하위에 있는 경로는 관리자 권한이 필요해 복사가 좀 불편한 면이 있고, %PATH%의 경우는 x86/x64 구분이 없으므로 어느 한쪽 플랫폼으로 맞춰 놓으면 이후 다른 플랫폼을 위한 windbg 실행 시 마찬가지의 불편함이 생깁니다.

이런 문제를 해결하기 위해, windbg의 명령행 옵션 중 "-c"를 이용해 단축 아이콘을 만들어 사용할 수 있습니다.

// x64인 경우
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe" -c ".extpath+ c:\wext\x64"

// x86인 경우
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\windbg.exe" -c ".extpath+ c:\wext\x86"




그런데, 하다 보면 명령어를 더 실행하고 싶을 수 있습니다. 이럴 때 관리가 편한 스크립트 파일을 하나 만들어 두면 좋은데요, 다음과 같이 만들어 두고,

$$ c:\wext\dbgscript.x64.txt // windbg 스크립트에 주석은 '$$'로 시작

.extpath+ d:\wext\x64
.loadby sos clr

$$ c:\wext\dbgscript.x86.txt // windbg 스크립트에 주석은 '$$'로 시작

.extpath+ d:\wext\x86
.loadby sos clr

windbg 실행을 위한 단축 아이콘에 -c 옵션으로 지정할 수 있습니다.

// x64인 경우
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\windbg.exe" -c "$$>a< d:\\settings\\dbgscript.x64.txt"

// x86인 경우
"C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\windbg.exe" -c "$$>a< d:\\settings\\dbgscript.x86.txt"

$<, $><, $$<, $$><, $$ >a< (Run Script File)
; https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/-----------------------a---run-script-file-




그런데, 간혹 이런 스크립트 파일 내에 포함할 수 없는 windbg 명령어가 있습니다. 가령 ".cls" 같은 경우인데요,

0:000> .cls
          ^ Syntax error in '.cls'

분명히 windbg 내에서 실행하면 잘 동작하지만 스크립트 파일에 포함하면 "syntax error"가 발생합니다. 이에 대해 다음의 Q&A 글이 이유를 잘 설명하고 있는데요,

Syntax error with WinDBG command line -c ".cls;g"
; https://microsoft.public.windbg.narkive.com/c4O7ZlIy/syntax-error-with-windbg-command-line-c-cls-g

.cls is a WinDBG GUI command, not a debugger engine command. So, it's
stripped out by the GUI code and not passed along to DbgEng. The list of
other commands like this is here:

즉, 스크립트 파일의 실행 환경은 windbg에 국한되지 않은 (UI를 갖지 않는) 디버거 엔진이기 때문입니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 1/3/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  48  49  50  [51]  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12370정성태10/13/202011176Linux: 33. Linux - nmcli를 이용한 고정 IP 설정
12369정성태10/12/202013968Windows: 176. Raymond Chen이 한글날에 밝히는 윈도우의 한글 자모 분리 현상 [3]
12368정성태10/12/202010012오류 유형: 668. VSIX 확장 빌드 - The "GetDeploymentPathFromVsixManifest" task failed unexpectedly.
12367정성태10/12/202022807오류 유형: 667. Ubuntu - Temporary failure resolving 'kr.archive.ubuntu.com' [2]
12366정성태10/12/202011750.NET Framework: 950. C# 9.0 - (4) 원시 크기 정수(Native ints) [1]파일 다운로드1
12365정성태10/12/202010646.NET Framework: 949. C# 9.0 - (3) 람다 메서드의 매개 변수 무시(Lambda discard parameters)파일 다운로드1
12364정성태10/11/202011848.NET Framework: 948. C# 9.0 - (2) localsinit 플래그 내보내기 무시(Suppress emitting localsinit flag)파일 다운로드1
12363정성태10/11/202012782.NET Framework: 947. C# 9.0 - (1) 대상으로 형식화된 new 식(Target-typed new expressions) [2]파일 다운로드1
12362정성태10/11/20209581VS.NET IDE: 151. Visual Studio 2019에 .NET 5 rc/preview 적용하는 방법
12361정성태10/11/202011213.NET Framework: 946. C# 9.0을 위한 개발 환경 구성
12360정성태10/8/20208392오류 유형: 666. The type or namespace name '...' does not exist in the namespace 'Microsoft.VisualStudio.TestTools' (are you missing an assembly reference?)
12359정성태10/7/20209918오류 유형: 665. Windows - 재부팅 후 iSCSI 연결이 끊기는 문제
12358정성태10/7/20209944오류 유형: 664. Web Deploy 설치 시 "A newer version of Microsoft Web Deploy 3.6 was found on this machine." 오류 [3]
12357정성태10/7/20208000오류 유형: 663. 이벤트 로그 - The storage optimizer couldn't complete retrim on New Volume
12356정성태10/7/202022939오류 유형: 662. ASP.NET Core와 500.19, 500.21 오류 (0x8007000d)
12355정성태10/3/20208074오류 유형: 661. Hyper-V Linux VM의 Internal 유형의 가상 Switch에 대한 IP 연결이 되지 않는 경우
12354정성태10/2/202021021오류 유형: 660. Web Deploy (msdeploy.axd) 실행 시 오류 기록 [1]
12353정성태10/2/202010824개발 환경 구성: 518. 비주얼 스튜디오에서 IIS 웹 서버로 "Web Deploy"를 이용해 배포하는 방법
12352정성태10/2/202011303개발 환경 구성: 517. Hyper-V Internal 네트워크에 NAT을 이용한 인터넷 연결 제공
12351정성태10/2/202010850오류 유형: 659. Nox 실행이 안 되는 경우 - Unable to bind to the underlying transport for ...
12350정성태9/25/202014346Windows: 175. 윈도우 환경에서 클라이언트 소켓의 최대 접속 수 [2]파일 다운로드1
12349정성태9/25/20209210Linux: 32. Ubuntu 20.04 - docker를 위한 tcp 바인딩 추가
12348정성태9/25/20209951오류 유형: 658. 리눅스 docker - Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
12347정성태9/25/202024143Windows: 174. WSL 2의 네트워크 통신 방법 [4]
12346정성태9/25/20209193오류 유형: 657. IIS - http://localhost 방문 시 Service Unavailable 503 오류 발생
12345정성태9/25/20208868오류 유형: 656. iisreset 실행 시 "Restart attempt failed." 오류가 발생하지만 웹 서비스는 정상적인 경우파일 다운로드1
... 46  47  48  49  50  [51]  52  53  54  55  56  57  58  59  60  ...