SlideShare a Scribd company logo
1 of 30
Introduction To Debugging ASP.NET applications with
WinDBG and Dump Analysis

             AHMET MİTHAT BOSTANCI
                MICROSOFT, GTSC
         IIS/WEB DEVELOPMENT SUPPORT
        AHMET.BOSTANCI@MICROSOFT.COM
SCOPE

 This is NOT a full dump analysis workshop.
 The goal is to introduce the dump analysis as one of
 the ASP.NET 2.0 web application debugging technics
 and introduce the tools that help to achieve this task.
AGENDA

 ASP.NET Debugging Technics
 What is WinDBG
 When are WinDBG and dump analysis useful?
 What are dump files?
 How to collect dump?
 Basic commands
 Toolbox & References
ASP.NET Debugging

 Old School Debugging
   Using Response.Write
   Mostly not useful in production
   Not useful in hang scenario
   Usful in development
   Useful in production if there is a repro
   Looks easy but not useful

 Debugging in VS.NET
   Good for debugging in development
   Useful in production with remote debugging / attaching to w3wp.exe
   Not useful in most production env. issues.

 Debugging with WinDBG
   Live debugging / attaching to w3wp.exe
   Offline debugging: Collecting dumps of w3wp.exe and analysing in
    WinDBG
What is WinDBG

 A GUI Debugger with commands.
 Part of Debugging Tools For Windows
 User mode and kernel mode debugging.
 Its commands are mainly useful in unmanaged
  debugging.
 Extensions are sets of commands to ease debugging.
 SOS and PSSCOR2 extensions for .NET debugging.
Debugging with WinDBG

 Offline debugging
   Collecting dump files with specific tools for different scenarios

   Analysing in WinDBG.

 Live debugging
   Attaching a process

   Using breakpoints, catching exceptions, dumping the process
    out to a file, etc... when necessary.
Debugging Scenarios

 Slow performance
   Web site is responsive but slow.

 Hang
   Web site is unresponsive.

 Crash
     Exceptions
Exceptions and ASP.NET

Exceptions are important objects in debugging.
 First Chance exceptions
     Too many exceptions may cause high CPU.
 Second Chance
   Exceptions which are not handled

   Causes crash.

 First chance exceptions may cause w3wp.exe
  crashes, if it is thrown in a background thread, such
  as finalizer threads.
When do we need WinDBG?

Hang / Performance Problems – Manuel
 Web site is running slow / performance issues.
 Web site is leaking memory - ends with performance
  problems, hang or crash.
 Web site is running with high memory but not not
  leaking.
 Web site is running with 100% CPU.
 Web site is running with high CPU or CPU usage spikes.
 Web site is completely hung - Does not response any
  (dynamic) requests.
When do we need WinDBG?

Crash
 Web site or a specific page / method is throwing
  exceptions but not crashing the w3wp.exe process,
  first chance exceptions.
 Web site is crashing - w3wp.exe is crashing. Second
  chance exceptions.
When do we NOT need WinDBG?

 When there is an easier way for debugging, such as a
  specific page / method is not functioning as expected
     In this case, debugging in VS.NET with a repro code might be
      easier.
 «Page cannot be displayed» type issues.
   In this case, troubleshooting IIS or network side is the correct
    approach.
Dump

A dump is a snapshot of a process (user mode) or a
snapshot of all of the memory in kernel mode.
 Usermode dump: Process specific, such as w3wp.exe
 Kernel mode dump: Snapshot of the kernel memory
 Complete memory dump: Snapshot of the whole
  memory including kernel and user mode.
Types of Dump

 Minidump
   Contains only selected parts of the memory used by the
    process.
 Fulldump
   Contains the full copy of the process memory. Size of the
    fulldump is somewhat equal to the virtual memory used by the
    process.
   This is the dump type we are interested in most of the times.
What a dump contains

 All the things in the memory of the process.
 Information about the objects in heaps, threads,
  information about the callstack, stack memory, etc...
 Limited information about the dead objects which
  are not garbage collected yet.
What a dump does NOT contain

 Other processes' information.
 What was the CPU or memory usage in time. It is
  only a snapshot.
 Also: Minidump is the smallest in size and does not
  contain some useful information such as stack
  objects, local variables, etc...
Tools for collecting dumps

 ADPlus
   Part of Debugging Tools For Windows
   Command line
   adplus -hang -pn w3wp.exe
   adplus -crash –iis

 Debug Diagnostic Tool
   GUI based
   Easy to configure and use

 ProcDump
   Command line
   Specific for high CPU usage but can be used for collecting manuel dumps as well
   procdump.exe -c 80 -s 30 -n 5 -ma NNNN >procdump.log

 Task manager
   Can be used to collect manuel dump
   Right click and create userdump
   Only on Win 7 and Win 2008
32bit vs 64bit

 If the process is 32bit then the dump should be taken
  by the 32bit version of the related tools. The dump
  should be opened with the WinDBG’s 32bit version.
 Same rule applies to 64bit process.
Which dump in which scenario?

 Web site is crashing / throwing exceptions
   Crash rule with Debug Diagnostic Tool, ADPlus

 Web site is slow, hanging, using high memory
   Manuel dump(s) with Debug Diagnostic Tool, ADPlus.

 Web site is using high CPU or CPU is spiking
   Manuel dump(s) with Debug Diagnostic Tool, ADPlus.
   ProcDump for CPU spikes

 Web site is leaking memory
   Manuel hang dumps.
   Memory leak rule created in Debug Diagnostic Tool.

 Full IIS dumps
   Manuel dump
   Collects dumps for all of w3wp.exe, all of dllhost.exe and inetinfo.exe
    process.
How many dump files should I collect?

 Dump is a snapshot of the memory and does not
  contain the process history.
 Most of the crash scenarios
     One crash dump is enough to start debugging and find the
      reason of the crash.
 Performance, hang
   Consecutive dump files of the same process.

   For example taking three dumps of w3wp.exe, each are taken
    one minute apart.
Symbol Files

 Footprint information of functions in EXE or DLL
  files
 Necessary to see useful information in dumps, such
  as callstacks or variables.
Private vs Public symbols

 Private symbols contain local variables, structure
  type information, functions, source line no., etc...
 Public symbols are the stripped version of the private
  symbols.
Symbols and WinDBG

 Symbol server
   http://msdl.microsoft.com/download/symbols

 Setting symbol server in WinDBG
   srv*c:symbolspublic*http://msdl.microsoft.com/download/
    symbols
 Symbols are downloaded to the local folder when
  needed.
Commands in WinDBG

 WinDBG commands
   Mostly used in unmanaged debugging.

 Extensions
   DLL files

   Command sets for specific debugging requirements
Extensions

 Copied to the WinDBG installation directory
 .NET related extensions
   SOS
        Comes with .NET framework
    PSSCOR2
      Superset of SOS
      .NET 2.0 specific extension
      http://www.microsoft.com/downloads/details.aspx?FamilyID=5c
       068e9f-ebfe-48a5-8b2f-0ad6ab454ad4&displayLang=en
      Extract and copy to the WinDBG installation folder.
      Load from WinDBG:
         .load psscor2
WinDBG and ASP.NET 2.0 dump analysis

 Open dump file
 Check and set symbol server
 Load the PSSCOR2 extenstion
   .load psscor2
Some WinDBG commands

 Vertarget
     Shows information about the system on which you are debugging
 Lm
     Displays loaded module information
 ~
     Lists all OS threads
 ~Ns
     Switch to thread #N
 K
     Shows unmanaged call stack of the thread switched.
 .hh
     Opens help file
 .reload /f
     Forces to reload the symbols.
 !runaway
     Shows the thread’s CPU time
Some PSSCOR2 commands

   !DumpAllExceptions (!dae)
       Shows managed exceptions thrown.
   !DumpDataTables
       Shows data tables objects in memory. Useful when debugging memory issues.
   !DumpColumnNames (!dcn)
       Prints out the column names for a data table given.
   !ASPXPages
       Shows ASPX pages running on all threads.
   !threadpool
       Shows ASP.NET thread pool information including the requests in the queue and the current CPU usage of OS.
   !FindDebugTrue
       Shows the web applications running in debug mode.
   !FindDebugModules
       Shows the modules built in debug mode.
   !SaveAllModules (!sam)
       Saves the all modules in the process. Useful when using the reflector to get the code from dump file.
   !eeversion
       Prints the .NET framework version. Useful when checking the fixes or service packs installed.
   !help
   !help <command>
Toolbox

 Debugging Tools For Windows (WinDBG and ADPlus)
    http://www.microsoft.com/whdc/DevTools/Debugging/default.msp
     x
 Debug Diagnostic Tool v1.1
    http://www.microsoft.com/downloads/details.aspx?FamilyID=28B
     D5941-C458-46F1-B24D-F60151D875A3&displaylang=en
 ProcDump
    http://technet.microsoft.com/en-us/sysinternals/dd996900.aspx
 PSSCOR2
    http://www.microsoft.com/downloads/details.aspx?familyid=5C068
     E9F-EBFE-48A5-8B2F-0AD6AB454AD4&displaylang=en
Refernces

 http://blogs.msdn.com/tess/ (İngilizce)
 http://blogs.msdn.com/amb/
 http://blogs.msdn.com/farukceliktr/
 http://blogs.msdn.com/cenkiscan/
 http://www.codeproject.com/KB/debug/windbg_pa
  rt1.aspx
 http://www.cengizhan.com/
Q&A




?

More Related Content

What's hot

Who’s afraid of WinDbg
Who’s afraid of WinDbgWho’s afraid of WinDbg
Who’s afraid of WinDbgDror Helper
 
Os Leventhal
Os LeventhalOs Leventhal
Os Leventhaloscon2007
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
 
Cloud forensics putting the bits back together
Cloud forensics putting the bits back togetherCloud forensics putting the bits back together
Cloud forensics putting the bits back togetherShakacon
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 
Multithreaded XML Import (San Francisco Magento Meetup)
Multithreaded XML Import (San Francisco Magento Meetup)Multithreaded XML Import (San Francisco Magento Meetup)
Multithreaded XML Import (San Francisco Magento Meetup)AOE
 
Kernel Recipes 2019 - Kernel hacking behind closed doors
Kernel Recipes 2019 - Kernel hacking behind closed doorsKernel Recipes 2019 - Kernel hacking behind closed doors
Kernel Recipes 2019 - Kernel hacking behind closed doorsAnne Nicolas
 
DCSF 19 eBPF Superpowers
DCSF 19 eBPF SuperpowersDCSF 19 eBPF Superpowers
DCSF 19 eBPF SuperpowersDocker, Inc.
 
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureKernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureAnne Nicolas
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL John Anderson
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with dockerJohan Janssen
 
OffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with XenOffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with XenTamas K Lengyel
 
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit FrameworkUnmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Frameworkegypt
 

What's hot (20)

Android Internals
Android InternalsAndroid Internals
Android Internals
 
Who’s afraid of WinDbg
Who’s afraid of WinDbgWho’s afraid of WinDbg
Who’s afraid of WinDbg
 
Os Leventhal
Os LeventhalOs Leventhal
Os Leventhal
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
Cloud forensics putting the bits back together
Cloud forensics putting the bits back togetherCloud forensics putting the bits back together
Cloud forensics putting the bits back together
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Multithreaded XML Import (San Francisco Magento Meetup)
Multithreaded XML Import (San Francisco Magento Meetup)Multithreaded XML Import (San Francisco Magento Meetup)
Multithreaded XML Import (San Francisco Magento Meetup)
 
Debugging ZFS: From Illumos to Linux
Debugging ZFS: From Illumos to LinuxDebugging ZFS: From Illumos to Linux
Debugging ZFS: From Illumos to Linux
 
Kernel Recipes 2019 - Kernel hacking behind closed doors
Kernel Recipes 2019 - Kernel hacking behind closed doorsKernel Recipes 2019 - Kernel hacking behind closed doors
Kernel Recipes 2019 - Kernel hacking behind closed doors
 
DCSF 19 eBPF Superpowers
DCSF 19 eBPF SuperpowersDCSF 19 eBPF Superpowers
DCSF 19 eBPF Superpowers
 
Kernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and futureKernel Recipes 2019 - Kernel documentation: past, present, and future
Kernel Recipes 2019 - Kernel documentation: past, present, and future
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
SystemV vs systemd
SystemV vs systemdSystemV vs systemd
SystemV vs systemd
 
Systemd cheatsheet
Systemd cheatsheetSystemd cheatsheet
Systemd cheatsheet
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
OffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with XenOffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with Xen
 
.Net debugging 2017
.Net debugging   2017.Net debugging   2017
.Net debugging 2017
 
Memory Dump
Memory DumpMemory Dump
Memory Dump
 
Logging system of Android
Logging system of AndroidLogging system of Android
Logging system of Android
 
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit FrameworkUnmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
Unmanned Aerial Vehicles: Exploit Automation with the Metasploit Framework
 

Viewers also liked

Debugging tricks you wish you knew - Tamir Dresher
Debugging tricks you wish you knew  - Tamir DresherDebugging tricks you wish you knew  - Tamir Dresher
Debugging tricks you wish you knew - Tamir DresherTamir Dresher
 
Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...
Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...
Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...Shanmuga KS
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharingJames Hsieh
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applicationsIdo Flatow
 
Windows Debugging with WinDbg
Windows Debugging with WinDbgWindows Debugging with WinDbg
Windows Debugging with WinDbgArno Huetter
 

Viewers also liked (6)

Debugging tricks you wish you knew - Tamir Dresher
Debugging tricks you wish you knew  - Tamir DresherDebugging tricks you wish you knew  - Tamir Dresher
Debugging tricks you wish you knew - Tamir Dresher
 
Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...
Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...
Crash (or) Hang dump analysis using WinDbg in Windows platform by K.S.Shanmug...
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
 
Windows Debugging with WinDbg
Windows Debugging with WinDbgWindows Debugging with WinDbg
Windows Debugging with WinDbg
 
Windows Crash Dump Analysis
Windows Crash Dump AnalysisWindows Crash Dump Analysis
Windows Crash Dump Analysis
 

Similar to Introductiontoasp netwindbgdebugging-100506045407-phpapp01

.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and TechniquesBala Subra
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging TechniquesBala Subra
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyBrian Lyttle
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Valeriy Kravchuk
 
Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013MattKilner
 
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)Valeriy Kravchuk
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginnersEnoch Joshua
 
Dot Net Application Monitoring
Dot Net Application MonitoringDot Net Application Monitoring
Dot Net Application MonitoringRavi Okade
 
Accelerated Windows Memory Dump Analysis
Accelerated Windows Memory Dump AnalysisAccelerated Windows Memory Dump Analysis
Accelerated Windows Memory Dump AnalysisDmitry Vostokov
 
Ibm bpm problem determination
Ibm bpm problem determinationIbm bpm problem determination
Ibm bpm problem determinationLong Nguyen
 
Process control daemon
Process control daemonProcess control daemon
Process control daemonhaish
 
Let’s talk virtualization
Let’s talk virtualizationLet’s talk virtualization
Let’s talk virtualizationEtienne Tremblay
 
Антон Наумович, Система автоматической крэш-аналитики своими средствами
Антон Наумович, Система автоматической крэш-аналитики своими средствамиАнтон Наумович, Система автоматической крэш-аналитики своими средствами
Антон Наумович, Система автоматической крэш-аналитики своими средствамиSergey Platonov
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Androidnatdefreitas
 

Similar to Introductiontoasp netwindbgdebugging-100506045407-phpapp01 (20)

.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
 
Spug pt session2 - debuggingl
Spug pt session2 - debugginglSpug pt session2 - debuggingl
Spug pt session2 - debuggingl
 
Vxcon 2016
Vxcon 2016Vxcon 2016
Vxcon 2016
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
 
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013Windows Debugging Tools - JavaOne 2013
Windows Debugging Tools - JavaOne 2013
 
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Dot Net Application Monitoring
Dot Net Application MonitoringDot Net Application Monitoring
Dot Net Application Monitoring
 
Accelerated Windows Memory Dump Analysis
Accelerated Windows Memory Dump AnalysisAccelerated Windows Memory Dump Analysis
Accelerated Windows Memory Dump Analysis
 
Backtrack Manual Part4
Backtrack Manual Part4Backtrack Manual Part4
Backtrack Manual Part4
 
Ibm bpm problem determination
Ibm bpm problem determinationIbm bpm problem determination
Ibm bpm problem determination
 
Process control daemon
Process control daemonProcess control daemon
Process control daemon
 
Let’s talk virtualization
Let’s talk virtualizationLet’s talk virtualization
Let’s talk virtualization
 
Server Core2
Server Core2Server Core2
Server Core2
 
Антон Наумович, Система автоматической крэш-аналитики своими средствами
Антон Наумович, Система автоматической крэш-аналитики своими средствамиАнтон Наумович, Система автоматической крэш-аналитики своими средствами
Антон Наумович, Система автоматической крэш-аналитики своими средствами
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Introductiontoasp netwindbgdebugging-100506045407-phpapp01

  • 1. Introduction To Debugging ASP.NET applications with WinDBG and Dump Analysis AHMET MİTHAT BOSTANCI MICROSOFT, GTSC IIS/WEB DEVELOPMENT SUPPORT AHMET.BOSTANCI@MICROSOFT.COM
  • 2. SCOPE  This is NOT a full dump analysis workshop.  The goal is to introduce the dump analysis as one of the ASP.NET 2.0 web application debugging technics and introduce the tools that help to achieve this task.
  • 3. AGENDA  ASP.NET Debugging Technics  What is WinDBG  When are WinDBG and dump analysis useful?  What are dump files?  How to collect dump?  Basic commands  Toolbox & References
  • 4. ASP.NET Debugging  Old School Debugging  Using Response.Write  Mostly not useful in production  Not useful in hang scenario  Usful in development  Useful in production if there is a repro  Looks easy but not useful  Debugging in VS.NET  Good for debugging in development  Useful in production with remote debugging / attaching to w3wp.exe  Not useful in most production env. issues.  Debugging with WinDBG  Live debugging / attaching to w3wp.exe  Offline debugging: Collecting dumps of w3wp.exe and analysing in WinDBG
  • 5. What is WinDBG  A GUI Debugger with commands.  Part of Debugging Tools For Windows  User mode and kernel mode debugging.  Its commands are mainly useful in unmanaged debugging.  Extensions are sets of commands to ease debugging.  SOS and PSSCOR2 extensions for .NET debugging.
  • 6. Debugging with WinDBG  Offline debugging  Collecting dump files with specific tools for different scenarios  Analysing in WinDBG.  Live debugging  Attaching a process  Using breakpoints, catching exceptions, dumping the process out to a file, etc... when necessary.
  • 7. Debugging Scenarios  Slow performance  Web site is responsive but slow.  Hang  Web site is unresponsive.  Crash  Exceptions
  • 8. Exceptions and ASP.NET Exceptions are important objects in debugging.  First Chance exceptions  Too many exceptions may cause high CPU.  Second Chance  Exceptions which are not handled  Causes crash.  First chance exceptions may cause w3wp.exe crashes, if it is thrown in a background thread, such as finalizer threads.
  • 9. When do we need WinDBG? Hang / Performance Problems – Manuel  Web site is running slow / performance issues.  Web site is leaking memory - ends with performance problems, hang or crash.  Web site is running with high memory but not not leaking.  Web site is running with 100% CPU.  Web site is running with high CPU or CPU usage spikes.  Web site is completely hung - Does not response any (dynamic) requests.
  • 10. When do we need WinDBG? Crash  Web site or a specific page / method is throwing exceptions but not crashing the w3wp.exe process, first chance exceptions.  Web site is crashing - w3wp.exe is crashing. Second chance exceptions.
  • 11. When do we NOT need WinDBG?  When there is an easier way for debugging, such as a specific page / method is not functioning as expected  In this case, debugging in VS.NET with a repro code might be easier.  «Page cannot be displayed» type issues.  In this case, troubleshooting IIS or network side is the correct approach.
  • 12. Dump A dump is a snapshot of a process (user mode) or a snapshot of all of the memory in kernel mode.  Usermode dump: Process specific, such as w3wp.exe  Kernel mode dump: Snapshot of the kernel memory  Complete memory dump: Snapshot of the whole memory including kernel and user mode.
  • 13. Types of Dump  Minidump  Contains only selected parts of the memory used by the process.  Fulldump  Contains the full copy of the process memory. Size of the fulldump is somewhat equal to the virtual memory used by the process.  This is the dump type we are interested in most of the times.
  • 14. What a dump contains  All the things in the memory of the process.  Information about the objects in heaps, threads, information about the callstack, stack memory, etc...  Limited information about the dead objects which are not garbage collected yet.
  • 15. What a dump does NOT contain  Other processes' information.  What was the CPU or memory usage in time. It is only a snapshot.  Also: Minidump is the smallest in size and does not contain some useful information such as stack objects, local variables, etc...
  • 16. Tools for collecting dumps  ADPlus  Part of Debugging Tools For Windows  Command line  adplus -hang -pn w3wp.exe  adplus -crash –iis  Debug Diagnostic Tool  GUI based  Easy to configure and use  ProcDump  Command line  Specific for high CPU usage but can be used for collecting manuel dumps as well  procdump.exe -c 80 -s 30 -n 5 -ma NNNN >procdump.log  Task manager  Can be used to collect manuel dump  Right click and create userdump  Only on Win 7 and Win 2008
  • 17. 32bit vs 64bit  If the process is 32bit then the dump should be taken by the 32bit version of the related tools. The dump should be opened with the WinDBG’s 32bit version.  Same rule applies to 64bit process.
  • 18. Which dump in which scenario?  Web site is crashing / throwing exceptions  Crash rule with Debug Diagnostic Tool, ADPlus  Web site is slow, hanging, using high memory  Manuel dump(s) with Debug Diagnostic Tool, ADPlus.  Web site is using high CPU or CPU is spiking  Manuel dump(s) with Debug Diagnostic Tool, ADPlus.  ProcDump for CPU spikes  Web site is leaking memory  Manuel hang dumps.  Memory leak rule created in Debug Diagnostic Tool.  Full IIS dumps  Manuel dump  Collects dumps for all of w3wp.exe, all of dllhost.exe and inetinfo.exe process.
  • 19. How many dump files should I collect?  Dump is a snapshot of the memory and does not contain the process history.  Most of the crash scenarios  One crash dump is enough to start debugging and find the reason of the crash.  Performance, hang  Consecutive dump files of the same process.  For example taking three dumps of w3wp.exe, each are taken one minute apart.
  • 20. Symbol Files  Footprint information of functions in EXE or DLL files  Necessary to see useful information in dumps, such as callstacks or variables.
  • 21. Private vs Public symbols  Private symbols contain local variables, structure type information, functions, source line no., etc...  Public symbols are the stripped version of the private symbols.
  • 22. Symbols and WinDBG  Symbol server  http://msdl.microsoft.com/download/symbols  Setting symbol server in WinDBG  srv*c:symbolspublic*http://msdl.microsoft.com/download/ symbols  Symbols are downloaded to the local folder when needed.
  • 23. Commands in WinDBG  WinDBG commands  Mostly used in unmanaged debugging.  Extensions  DLL files  Command sets for specific debugging requirements
  • 24. Extensions  Copied to the WinDBG installation directory  .NET related extensions  SOS  Comes with .NET framework  PSSCOR2  Superset of SOS  .NET 2.0 specific extension  http://www.microsoft.com/downloads/details.aspx?FamilyID=5c 068e9f-ebfe-48a5-8b2f-0ad6ab454ad4&displayLang=en  Extract and copy to the WinDBG installation folder.  Load from WinDBG:  .load psscor2
  • 25. WinDBG and ASP.NET 2.0 dump analysis  Open dump file  Check and set symbol server  Load the PSSCOR2 extenstion  .load psscor2
  • 26. Some WinDBG commands  Vertarget  Shows information about the system on which you are debugging  Lm  Displays loaded module information  ~  Lists all OS threads  ~Ns  Switch to thread #N  K  Shows unmanaged call stack of the thread switched.  .hh  Opens help file  .reload /f  Forces to reload the symbols.  !runaway  Shows the thread’s CPU time
  • 27. Some PSSCOR2 commands  !DumpAllExceptions (!dae)  Shows managed exceptions thrown.  !DumpDataTables  Shows data tables objects in memory. Useful when debugging memory issues.  !DumpColumnNames (!dcn)  Prints out the column names for a data table given.  !ASPXPages  Shows ASPX pages running on all threads.  !threadpool  Shows ASP.NET thread pool information including the requests in the queue and the current CPU usage of OS.  !FindDebugTrue  Shows the web applications running in debug mode.  !FindDebugModules  Shows the modules built in debug mode.  !SaveAllModules (!sam)  Saves the all modules in the process. Useful when using the reflector to get the code from dump file.  !eeversion  Prints the .NET framework version. Useful when checking the fixes or service packs installed.  !help  !help <command>
  • 28. Toolbox  Debugging Tools For Windows (WinDBG and ADPlus)  http://www.microsoft.com/whdc/DevTools/Debugging/default.msp x  Debug Diagnostic Tool v1.1  http://www.microsoft.com/downloads/details.aspx?FamilyID=28B D5941-C458-46F1-B24D-F60151D875A3&displaylang=en  ProcDump  http://technet.microsoft.com/en-us/sysinternals/dd996900.aspx  PSSCOR2  http://www.microsoft.com/downloads/details.aspx?familyid=5C068 E9F-EBFE-48A5-8B2F-0AD6AB454AD4&displaylang=en
  • 29. Refernces  http://blogs.msdn.com/tess/ (İngilizce)  http://blogs.msdn.com/amb/  http://blogs.msdn.com/farukceliktr/  http://blogs.msdn.com/cenkiscan/  http://www.codeproject.com/KB/debug/windbg_pa rt1.aspx  http://www.cengizhan.com/
  • 30. Q&A ?