반응형


http://tudul2box.tistory.com/317


윈도우를 사용하다보면 이유없이 실행창이 꺼지는 현상을 많이 경험해 보았을 것이다.

이때 오류 분석파일(덤프)을 생성할 수 있는 프로그램을 사용하여 오류를 분석하는데,

마이크로 소프트사에서 제공해주는 Debug Diagnostic Tool을 이용하면 된다.

 

windbg 프로그램과 다른 점은 windbg는 직접 실행하고 프로세스가 끝날때마다 설정을 해주어야 하지만,

이 프로그램을 서비스로 실행되어 충돌(crash)가 발생하면 자동으로 지정 폴더에 저장해준다.



http://www.microsoft.com/en-us/download/details.aspx?id=26798







http://byung.egloos.com/4743470

[Troubleshooting Tool] Debug Diagnostic Tool Windows debugging

Debug Diagnostics Tool AD+ 와 같이 특정한 문제에 대해서 Memory Dump를 수집할 수 있는 기능을 제공한다여기서 특정한 문제라는 것은 Hang/Performance 문제/Memory 누수/Virtual Memory 조각화 및 다양한 Crash Issue이다뿐만 아니라 Crash Memory 관련 문제에 대해서 분석 report를 제공한다는 점에 있어서 유용하다.

 

먼저, Crash Rule에서 보면따로 설정하지 않은 1st Chance Exception에 대한 설정을 할 수 있다아래의 그림과 같이 Action Type으로 Log를 남기거나 Mini Dump  Full Dump를 수집할 수 있도록 설정가능하며, dump 생성의 수를 제한할 수 도 있다. (만일, 0라고 설정하면 제한하지 않는 다는 의미이다.) Performance를 고려하여 대부분 None이거나 간혹 Log 정도를 남기게 된다.

그리고임의의 1st Exception에 대한 Dump 수집을 설정할 수 있다. (이 말은 기본적으로 아무 설정을 하지 않았을 때, 2nd chance exception에 대한 Crash Dump가 기본적으로 수집된다이는 상위 그림의 Advances Settings Exceptions 버튼을Click하여 설정한다.

상위의 그림은 좌측의 Exception Code AV Click 하여 1st Chance AV가 발생했을 때 자료를 어떻게 수집할 지 설정하는 방법이다앞서서 설명한 것처럼 Action Type Log Mini  Full User Dump를 수집할 수 있도록 설정할 수 있다특이한 경우는 CLR Exception의 경우이다.

보면, .NET Exception Type 이라는 부분이 존재한다여기에 Exception 정보를 추가하면해당하는 Exception 에 대해서 Full User Dump를 수집하도록 설정된다.

 

Advanced Settings에 또 한가지는 Break point 를 설정하여 Dump를 수집할 수 있다는 것이다다음의 그림을 보자.

기본적으로 list Kernel32!ExitProcess나 몇 가지가 추가되어 있다일반적으로 2nd Chance Exception으로 인하여 Process terminated 되는 경우에 Crash Dump를 수집하므로, Kernel32!ExitProcess list에서 선택하고 Action Type Full user Dump로 설정하여 Crash Rule 을 완성한다하지만외에 원하는 부분에 BP를 설정하고 Dump를 수집하거나 Log를 남기고 싶을 경우에는 상위의 그림과 같이 Breakpoint Expression 부분에 원하는 address를 설정하여 추가시킬 수도 있다.

 

그리고, Heap Corruption되는 증상에 대해서 일반적으로 Pageheap Enabled 하고 Crash Dump를 수집하게 되는 데, Debug Diagnostic Tool에서는 Advanced Settings PageHeap Flags 라는 부분에서 PageHeap을 설정할 수 있다.

Debug Diagnostic Tool Process Memory Leak 현상을 Detection 하기 위해서 Leaktrack.dll injection 시켜서 Leak tracking 할 수 있는 기능이 존재한다.

Processes Tab을 확인해 보면, Process ID에 따른 Process list 정보를 알 수 있는 데, Leak으로 의심이 되는 Process를 선택하여 오른쪽 마우스를 Click 하면, Monitor For Leaks 라는 Menu를 확인할 수 있다이는 앞서서 설명한 Leaktrack.dll을 해당 Process Injection 시키는 역할을 한다이후에 Private Bytes의 증가를 유심히 확인하여 충분히 메모리가 지속적으로 증가하는 패턴이 확인되면, Create Full Userdump menu 를 통해 메모리 dump를 수집할 수 있다간혹 Memory Leak으로 인하여 Out Of Memory Exception이나 Crash를 동반하는 경우가 있으므로, Crash Rule Kernal32!ExitProcess  Full user dump와 함께 leaktrack을 걸어 놓는 것도 좋을 듯 하다.

 

** 메모리 Leak?

Return 되지 않는 resource 로 인하여 process가 점유하고 있는 메모리가 지속적으로 증가하는 현상을 말한다. Logic에 따라서 Application이 메모리를 보유하고 사용할 수도 있으므로이와는 구분 되어야 한다이 경우시스템 resource가 부족하여 시스템의 전반적인 performance에 영향을 줄 수 있으며간혹 Hang 증상이 발생할 수 있다메모리 Leak을 판단하기 위해서는 메모리의 증가하는 패턴이 꾸준히 발생하기 때문에 성능로그의 Private Bytes  Virtual Bytes 그리고, Working Set의 데이터 패턴을 보고 Leak 여부를 판단해야만 한다.

*******

 

Debug Diagnostic Tool은 다음과 같은 메모리 할당에 대한 Tracking이 가능하다.

1)    NT Heap allocator

1.     HeapAlloc

2.     LocalAlloc

3.     GlobalAlloc

2)    Virtual Memory allocator

1.     VirtualAlloc

3)    C Run time memory allocator

1.     malloc

2.     calloc

3.     operator new

4)    BSTR allocator

1.     SysAllocString

5)    OLE/COM allocator

1.     CoTaskMemAlloc, IMalloc interface

 

Debug Diagnostic Tool이 제공하는 기능 중에 Crash Dump  Memory Dump 분석하여 reporting을 출력해주는 기능을 가지고 있다.

그림에서처럼 Advanced Analysis Tab에는 Crash memory analysis를 선택할 수 있다분석에 앞서서 Symbol을 정확하게 맞춰주는 것이 필요한데, tools menu의 Options and Settings  를 통해서 설정할 수 있다.

Symbol Search path For analysis 에는 default Microsoft Public Symbol이(http://msdl.microsoft.com/download/symbols, 그리고, C:\symcache directory를 local machine의 symbol cache로 사용하도록 ) 설정되어 있다그리고필요한 symbol path Symbol Search Path for Debugging에 위치시켜야만 Symbol이 맞지 않아서 잘못된 reporting이 출력되는 것을 방지할 수 있다.

 

Debug Diag는 다음과 같은 Memory leak 관련 report 를 출력한다.

보면, Analysis summary에서 눈에 띄게 Memory를 보유하고 있는 Function Call Check할 수 있다상위 report에서는 asp.dll VBScript.dll 과 관련한 Callstack에서 메모리를 보유하고 있음을 보여주고 있는 데해당 Function Click 하면, 어떤 Callstack에 메모리 할당이 이뤄졌는지 다음과 같이 reporting 하고 있음을 확인할 수 있다. 그림에서는 안 나타나 있지만, sample callstack 정보와 더불어 단위 Allocation size와 Allocation Count에 따른 unfreed memory에 대한 Top 10 list of allocations 정보를 출력해 줌으로써 Allocation pattern을 알 수 있다.

그리고다음은 Application에서 사용하고 있는 Virtual Memory에 대한 정보이다. 아래 그림에서도 알 수 있지만, Application 전반적으로 Reserved/Commited 그리고 Free 영역에 대한 사용정도를 알 수 있다. 그리고, Virtual Memory Details에서는 Application 에서 VirtualAlloc이 얼마나 되는 지, Threads가 사용한 Memory 또는 Native Heap으로 사용된 메모리가 많은 지에 대한 정보를 제공한다. 

Heap Memory의 경우는 다음과 같이 따로 정보를 제공한다. 각 Heap의 종류에 따라(예를 들어, Application에서 필요에 따라 Heap을 따로 관리하는 경우가 많은 데, default Heap 외에 crt heap이나 odbc나 oledb가 사용하는 mpheap 등이 존재할 수 있다.) 어느정도의 memory가 reserved 되어 있는 지, commit 되어 있는 지 보고해주며, 또한 Heap block에 따른 Address 정보나 세부적으로 memory의 할당여부를 확인할 수 있다. 이러한 Heap block의 정보를 가지고 의심이 나는 Heap 영역에 어떤 Data가 존재하는 지를 Memory Dump에서 Windbg를 통해 확인해 볼 수 있기 때문에 유용하다.  

위의 그림에서도 나타나 있지만, Virtual Memory나 Heap Memory에 대한 Allocation 정보에서의 Top 10 List of allocations 보다 직관적으로 unfree된 pattern을 알 수 있는 유용한 정보이다. 그러므로, 이러한 Heap이나 Virtual Memory에 대한 정보는 Application의 메모리 누수인지 아닌지에 대한 판단 및 누수일 때의 원인을 찾는 데 도움을 줄 수 있다

그리고, 추가적으로 Handle count에 대한 정보를 출력해줌으로써 Handle leaks에 대한 tracking도 가능하고, IIS Hang과 같은 Issue를 위해 HTTP Ping을 주기적으로 설정하는 기능도 존재한다.






http://www.microsoft.com/en-us/download/details.aspx?id=26798



The Debug Diagnostic Tool (DebugDiag) is designed to assist in troubleshootingissues such as hangs, slow performance, memory leaks or fragmentation, and crashes in any user-mode process. The tool includes additional debugging scripts focused on Internet Information Services (IIS) applications, web data access components, COM+ and related Microsoft technologies.

Quick details

Version:1.2Date published:7/14/2011
Language:English

Files in this download

The links in this section correspond to files available for this download. Download the files appropriate for you.

File nameSize
DebugDiagx64.msi16.1 MBDOWNLOAD
DebugDiagx86.msi11.7 MBDOWNLOAD

Overview

The Debug Diagnostic Tool (DebugDiag) is designed to assist in troubleshooting issues such as hangs, slow performance, memory leaks or memory fragmentation, and crashes in any user-mode process. The tool includes additional debugging scripts focused on Internet Information Services (IIS) applications, web data access components, COM+ and COM+ related Microsoft technologies, Sharepoint, and .NET framework.

  • DebugDiag 1.0 was released as part of the IIS Diagnostic Toolkit and as a standalone tool (x86 only).
  • DebugDiag 1.1 was released as a standalone tool only (x86 and limited x64 support).
  • DebugDiag 1.2 is currently available as a standalone tool only (x86 and full x64 support).
DebugDiag provides an extensible object model in the form of COM objects and provides a script host with a built-in reporting framework. 

It is composed of the following 3 components: a debugging service, a debugger host, and the user interface.

The Debugging Service The debugger service (DbgSvc.exe) performs the following tasks:
  • Attach/Detach the host to processes
  • Collect performance monitor data
  • Implement HTTP ping to detect hangs
  • Inject leak monitor into running processes
  • Collect debugging session state information
  • Shows the state of each rule defined
The Debugger Host The Debugger Host (DbgHost.exe) hosts the Windows Symbolic Debugger Engine (dbgeng.dll) to attach to processes and generate memory dumps. It also hosts the main analyzer module to analyze memory dumps. Dbghost.exe has no dependency on the service “DbgSvc.exe” and can be used separately. The User Interface The user interfaces (DebugDiag.exe and DebugDiagAnalysisOnly.exe) present an interface to analyze memory dumps, automate the creation of control scripts and to show the status of running processes, including services. It is composed of 3 views: 

  • Rules: Creates control script for the debugger host through a wizard. The script is located under the directory \scripts.
  • Advanced Analysis: Runs a selected “Analysis Script” against one or more memory dumps.
  • Processes: Shows status of running processes/services.
Note: DebugDiagAnalysisOnly.exe does not require privilege elevation on operating systems beginning with Windows Vista, so it only contains the Advanced Analysis view.

Top of pageTop of page

System requirements

Supported operating systems: Windows 7

• Windows 2003-Windows XP • Windows 2008-Windows Vista • Windows 2008 R2- Windows7

Top of pageTop of page

Instructions

Please visit Microsoft KB 2580960 for detailed instruction on how to use Debugdiag 1.2.

Debugdiag 1.2 introduced many new features that proved to be of great value:

Analysis:

  • .Net 2.0 and higher analysis integrated to the Crash Hang analysis.
  • SharePoint Analysis Script.
  • Performance Analysis Script.
  • .NET memory analysis script (beta).
  • Native heap analysis for all supported operating systems
Collection:
  • Generate series of Userdumps.
  • Performance Rule.
  • IIS ETW hang detection.
  • .NET CLR 4.0 support.
  • Managed Breakpoint Support.
  • Report Userdump generation to the Event log.
Deployment
  • Import/Export of rules and configuration, including 'Direct Push' to remote servers.
  • Enterprise deployment support using XCopy and Register.bat.

Please direct any questions, comments or feedback to dbgdiag@microsoft.com




반응형

+ Recent posts