Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 4개 있습니다.)

WinDbg Preview 버전부터 닷넷 코어 3.0 이후의 메모리 덤프에 대해 sos.dll 자동 로드

.NET 2.0까지 있었던 sos.dll 파일이 3.0 이후의 배포 디렉터리(예를 들어, C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.7)에서 사라졌습니다. 대신, 다음의 내용만을 포함하고 있는 SOS_README.md 파일이 있는데,

SOS and other diagnostic tools now ship of band and work with any version of the .NET Core runtime.

SOS has moved to the diagnostics repo here: https://github.com/dotnet/diagnostics.git.

Instructions to install SOS: https://github.com/dotnet/diagnostics#installing-sos.

내용을 쭉 읽다 보면 반가운 소식을 접하게 됩니다. ^^

Installing SOS on Windows
; https://github.com/dotnet/diagnostics/blob/master/documentation/installing-sos-windows-instructions.md

간단하게 정리하면, 이제부터는 10.0.18317.1001 이후 버전의 windbg인 경우 coreclr.dll에 따른 sos.dll을 자동으로 로드할 수 있게 되었다는 것입니다. 하지만 실제로 해보면, Windows SDK로부터 배포하는 windbg의 경우 10.0.19041.1 버전인데도 자동 로드를 하지 않았습니다. 반면, Windows 10의 Store App으로 배포되는 "WinDbg Preview"에서는 자동 로드가 되었습니다.

제가 가지고 있는 WinDbg Preview 버전이 10.0.20153.1000인데, 단순히 .NET Core 응용 프로그램의 덤프를 로드하기만 하면,

0:008> .chain
Extension DLL search Path:
    C:\Program Files\WindowsApps\...[생략]...
Extension DLL chain:
    sos: image 3.0.52901+0adfc0301b6e07c7124b277d4a8e7da6b8cb6784, API 2.0.0, built Wed Oct 30 01:50:33 2019
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\winext\sos\sos.dll]
    dbghelp: image 10.0.19528.1000, API 10.0.6, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\dbghelp.dll]
    ext: image 10.0.19528.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\winext\ext.dll]
    exts: image 10.0.19528.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\WINXP\exts.dll]
    uext: image 10.0.19528.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\winext\uext.dll]
    ntsdexts: image 10.0.19528.1000, API 1.0.0, 
        [path: C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\WINXP\ntsdexts.dll]

보는 바와 같이 sos 로드 관련해 어떤 명령도 수행한 적이 없는데도 저렇게 sos.dll이 올라온 것을 .chain으로 확인할 수 있습니다.




만약 Store App이 아닌 기존의 windbg에서도 로드하고 싶다면 그냥 자동으로 내려받았던 그 sos.dll을,

C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2001.2001.0_neutral__8wekyb3d8bbwe\amd64\winext\sos\sos.dll

그대로 복사해,

c:\temp> robocopy "C:\Program Files\WindowsApps\Microsoft.WinDbg_1.2007.6001.0_neutral__8wekyb3d8bbwe\amd64\winext\sos" "c:\temp" sos.dll

기존처럼 로드하면 됩니다.

0:009> .load c:\temp\sos.dll




그나저나, sos.dll과 함께 로드되어야 했던 mscordaccore.dll은 여전히 .NET Core의 배포 디렉터리에 존재합니다. 하지만, WinDbg는 sos.dll을 자동으로 가져온 것처럼, mscordaccore.dll도 현재 시스템에 없다면 자동으로 심벌 서버에서 내려받아 로드를 합니다.

0:000> .cordll -ve -u -l
CLRDLL: Unable to get version info for 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.3\mscordaccore.dll', Win32 error 0n87
CLRDLL: Loaded DLL e:\symbols\mscordaccore_AMD64_AMD64_4.700.20.11803.dll\5E4C618556b000\mscordaccore_AMD64_AMD64_4.700.20.11803.dll
Automatically loaded SOS Extension
CLR DLL status: Loaded DLL e:\symbols\mscordaccore_AMD64_AMD64_4.700.20.11803.dll\5E4C618556b000\mscordaccore_AMD64_AMD64_4.700.20.11803.dll

그러니까, 이제부터는 순수하게 메모리 덤프 파일만 가져오면 분석하는데 아무런 문제가 없게 된 것입니다.




참고로, WinDbg Preview가 설치되지 않은 경우라면 "dotnet tool install" 명령어를 이용해 sos.dll을 직접 다운로드하는 것도 가능합니다.

c:\temp> dotnet tool install -g dotnet-sos
You can invoke the tool using the following command: dotnet-sos
Tool 'dotnet-sos' (version '3.1.141901') was successfully installed.

c:\temp> dotnet-sos install
Installing SOS to C:\Users\testusr\.dotnet\sos from C:\Users\testusr\.dotnet\tools\.store\dotnet-sos\3.1.141901\dotnet-sos\3.1.141901\tools\netcoreapp2.1\any\win-x64
Creating installation directory...
Copying files...
Execute '.load C:\Users\testusr\.dotnet\sos\sos.dll' to load SOS in your Windows debugger.
SOS install succeeded

이렇게 내려받은 sos.dll을 기존의 Windbg에서 로드해 사용할 수 있습니다.

0:000> .load C:\Users\testusr\.dotnet\sos\sos.dll
0:000> .cordll -ve -u -l
CLRDLL: Unable to get version info for 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.3\mscordaccore.dll', Win32 error 0n87
CLRDLL: Loaded DLL e:\symbols\mscordaccore_AMD64_AMD64_4.700.20.11803.dll\5E4C618556b000\mscordaccore_AMD64_AMD64_4.700.20.11803.dll
Automatically loaded SOS Extension
CLR DLL status: Loaded DLL e:\symbols\mscordaccore_AMD64_AMD64_4.700.20.11803.dll\5E4C618556b000\mscordaccore_AMD64_AMD64_4.700.20.11803.dll




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 5/18/2021]

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

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...
NoWriterDateCnt.TitleFile(s)
11823정성태2/21/201913511오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201911646오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201912100오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201915242오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201913914Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201912839VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/20199991오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201912496Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201911386오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/201910206오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
11813정성태2/12/201911812.NET Framework: 809. C# - ("Save File Dialog" 등의) 대화 창에 확장 속성을 보이는 방법
11812정성태2/11/20199632오류 유형: 511. Windows Server 2003 VM 부팅 후 로그인 시점에 0xC0000005 BSOD 발생
11811정성태2/11/201913423오류 유형: 510. 서버 운영체제에 NVIDIA GeForce Experience 실행 시 wlanapi.dll 누락 문제
11810정성태2/11/201911488.NET Framework: 808. .NET Profiler - GAC 모듈에서 GAC 비-등록 모듈을 참조하는 경우의 문제
11809정성태2/11/201912998.NET Framework: 807. ClrMD를 이용해 메모리 덤프 파일로부터 특정 인스턴스를 참조하고 있는 소유자 확인
11808정성태2/8/201914053디버깅 기술: 123. windbg - 닷넷 응용 프로그램의 메모리 누수 분석
11807정성태1/29/201912360Windows: 156. 가상 디스크의 용량을 복구 파티션으로 인해 늘리지 못하는 경우 [4]
11806정성태1/29/201912116디버깅 기술: 122. windbg - 덤프 파일로부터 PID와 환경 변수 등의 정보를 구하는 방법
11805정성태1/28/201913960.NET Framework: 806. C# - int []와 object []의 차이로 이해하는 제네릭의 필요성 [4]파일 다운로드1
11804정성태1/24/201912013Windows: 155. diskpart - remove letter 이후 재부팅 시 다시 드라이브 문자가 할당되는 경우
11803정성태1/10/201911489디버깅 기술: 121. windbg - 닷넷 Finalizer 스레드가 멈춰있는 현상
11802정성태1/7/201912878.NET Framework: 805. 두 개의 윈도우를 각각 실행하는 방법(Windows Forms, WPF)파일 다운로드1
11801정성태1/1/201913913개발 환경 구성: 427. Netsh의 네트워크 모니터링 기능 [3]
11800정성태12/28/201813196오류 유형: 509. WCF 호출 오류 메시지 - System.ServiceModel.CommunicationException: Internal Server Error
11799정성태12/19/201813995.NET Framework: 804. WPF(또는 WinForm)에서 UWP UI 구성 요소 사용하는 방법 [3]파일 다운로드1
11798정성태12/19/201813234개발 환경 구성: 426. vcpkg - "Building vcpkg.exe failed. Please ensure you have installed Visual Studio with the Desktop C++ workload and the Windows SDK for Desktop C++"
... 61  62  63  64  65  66  67  68  69  70  71  72  [73]  74  75  ...