Tag Archives: WinDbg

.NET [Core] Memory Internals – záznam, slides a dema [TechEd DevCon Praha 2019]

Záznam z přednášky pro konferenci TechEd DevCon Praha ze 16. května 2019.

.NET [Core] Internals – Garbage Collection – záznam, slides, dema [.NET Talks, 17.1.2019]

Záznam z mého vystoupení pro .NET Talks Praha ze 17. ledna 2019.

Slides a dema:

Dotčená témata:

  • Memory Architecture,
  • Simple Garbage Collection,
  • GC Roots,
  • GC Generations,
  • Large Object Heap,
  • Finalization, Unmanaged Resources.

Nahrávka je publikována na našem HAVIT YouTube Channelu.

Diagnostika aplikací v Azure AppService – záznam a dema [TechEd Praha 05/2018]

Dema z mé přednášky pro TechEd DevCon Praha z 16.5.2018:

Záznam z přednášky je publikován na našem HAVIT YouTube Channel.

Dotčená témata

Azure AppService, Storage, SQL – Tips, Tricks – záznam, slides a dema [ShowIT 2/2018]

Záznam z přednášky pro konferenci ShowIT Bratislava z 1.2.2018. Je publikován na našem HAVIT YouTube Channelu.

Dotčená témata

  • Azure AppService Deployment
  • Azure AppService Configuration
  • Azure AppService Diagnostics
    • Remote Debugging
    • Log Streaming
    • Profiling
    • KUDU, Memory Dumps
  • Azure SQL
    • Elastic Pool, DTU, eDTU
    • Performance Insights (Query Store, Automatic Tuning)
  • DateTime.Now, WEBSITE_TIME_ZONE

WinDbg: SOSEX Help – Command Reference

SOSEX je jedno z mála rozšíření Windows Debuggeru pro .NET (managed code). Přidává pár užitečných příkazů k základnímu SOS, není však snadné seznam podporovaných příkazů online najít.
Seznam příkazů se dá získat přes !sosex.help. Výstup se může hodit, pokud hledáte, která extension bude pro váš scénář diagnostiky nejpříhodnější.

0:000> !sosex.help
SOSEX - Copyright 2007-2015 by Steve Johnson - http://www.stevestechspot.com/
To report bugs or offer feedback about SOSEX, please email sjjohnson@pobox.com
Quick Ref:
--------------------------------------------------
bhi       [filename]                                     BuildHeapIndex - Builds an index file for heap objects.
bpsc      (Deprecated.  Use !mbp instead)
chi                                                      ClearHeapIndex - Frees all resources used by the heap index and removes it from memory.
dlk       [-d]                                           Displays deadlocks between SyncBlocks and/or ReaderWriterLocks
dumpfd    <FieldAddr>                                    Dumps the properties of a FieldDef structure
dumpgen   <GenNum> [-free] [-stat] [-type <TYPE_NAME>]   Dumps the contents of the specified generation
                   [-nostrings] [-live] [-dead] [-short]
finq      [GenNum] [-stat]                               Displays objects in the finalization queue
frq       [-stat]                                        Displays objects in the Freachable queue
gcgen     <ObjectAddr>                                   Displays the GC generation of the specified object
gch       [HandleType]... [-stat]                        Lists all GCHandles, optionally filtered by specified handle types
help      [CommandName]                                  Display this screen or details about the specified command
lhi       [filename]                                     LoadHeapIndex - load the heap index into memory.
mbc       <SOSEX breakpoint ID | *>                      Clears the specified or all managed breakpoints
mbd       <SOSEX breakpoint ID | *>                      Disables the specified or all managed breakpoints
mbe       <SOSEX breakpoint ID | *>                      Enables the specified or all managed breakpoints
mbl       [SOSEX breakpoint ID]                          Prints the specified or all managed breakpoints
mbm       <Type/MethodFilter> [ILOffset] [Options]       Sets a managed breakpoint on methods matching the specified filter
mbp       <SourceFile> <nLineNum> [ColNum] [Options]     Sets a managed breakpoint at the specified source code location
mdso      [Options]                                      Dumps object references on the stack and in CPU registers in the current context
mdt       [TypeName | VarName | MT] [ADDR] [Options]     Displays the fields of an object or type, optionally recursively
mdv       [nFrameNum]                                    Displays arguments and locals for a managed frame
mfrag     [-stat] [-mt:<MT>]                             Reports free blocks, the type of object following the free block, and fragmentation statistics
mframe    [nFrameNum]                                    Displays or sets the current managed frame for the !mdt and !mdv commands
mgu       // TODO: Document
mk        [FrameCount] [-l] [-p] [-a]                    Prints a stack trace of managed and unmanaged frames
mln       [expression]                                   Displays the type of managed data located at the specified address or the current instruction pointer
mlocks    [-d]                                           Lists all managed lock objects and CriticalSections and their owning threads
mroot     <ObjectAddr> [-all]                            Displays GC roots for the specified object
mt        (no parameters)                                Steps into the managed method at the current position
mu        [address] [-s] [-il] [-n]                      Displays a disassembly around the current instruction with interleaved source, IL and asm code
muf       [MD Address | Code Address] [-s] [-il] [-n]    Displays a disassembly with interleaved source, IL and asm code
mwaits    [-d | LockAddr]                                Lists all waiting threads and, if known, the locks they are waiting on
mx        <Filter String>                                Displays managed type/field/method names matching the specified filter string
rcw       [Object or SyncBlock Addr]                     Displays Runtime Callable Wrapper (RCW) COM interop data.
refs      <ObjectAddr> [-target|-source]                 Displays all references from and to the specified object
rwlock    [ObjectAddr | -d]                              Displays all RWLocks or, if provided a RWLock address, details of the specified lock
sosexhelp [CommandName]                                  Display this screen or details about the specified command
strings   [ModuleAddress] [Options]                      Search the managed heap or a module for strings matching the specified criteria

ListGcHandles - See gch

Use !help <command> or !sosexhelp <command> for more details about each command.
You can also use the /? (or -?) option on any command to get help for that command.

Azure App Service: Získání full memory dumpu při výskytu určité výjimky

Opakovaně si libuji, co všechno je na Azure App Service z hlediska diagnostiky a správy možné ve srovnání s tradičním webhostingem. Například získat full memory dump je snadné, díky Kudu a SysInternals, které jsou na AppService k dispozici.

…no a pokud ladím konkrétní problém a potřebuji memory dump v momentu výskytu určité výjimky, je to už jenom o správném použití ProcDump ze SysInternals (spustit z Debug Console, kde si aktuální adresář přepnete třeba na LogFiles:


d:\devtools\sysinternals\procdump -accepteula -ma -e 1 -f "FaultException" 9736

…poslední číslo je číslo procesu (získáte z Kudu z Process Exploreru nebo z portálu), v uvozovkách stačí libovolná část názvu typu výjimky (testuje se přes Contains).

Celá věc pak může vypadat třeba takhle:


Kudu Remote Execution Console
Type 'exit' then hit 'enter' to get a new CMD process.
Type 'cls' to clear the console

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

D:\home>
D:\home\LogFiles>d:\devtools\sysinternals\procdump -accepteula -ma -e 1 -f "FaultException" 9736

ProcDump v9.0 - Sysinternals process dump utility
Copyright (C) 2009-2017 Mark Russinovich and Andrew Richards
Sysinternals - www.sysinternals.com

Process: w3wp.exe (9736)
Process image: D:\Windows\SysWOW64\inetsrv\w3wp.exe
CPU threshold: n/a
Performance counter: n/a
Commit threshold: n/a
Threshold seconds: n/a
Hung window check: Disabled
Log debug strings: Disabled
Exception monitor: First Chance+Unhandled
Exception filter: [Includes]
*FaultException*
[Excludes]
Terminate monitor: Disabled
Cloning type: Disabled
Concurrent limit: n/a
Avoid outage: n/a
Number of dumps: 1
Dump folder: D:\home\LogFiles\
Dump filename/mask: PROCESSNAME_YYMMDD_HHMMSS
Queue to WER: Disabled
Kill after dump: Disabled

Press Ctrl-C to end monitoring without terminating the process.

CLR Version: v4.0.30319

[07:57:32] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:57:40] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:57:50] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:57:55] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:02] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:10] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:20] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:24] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:32] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:40] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:50] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:58:55] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:02] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:10] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:20] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:25] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:32] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:40] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:50] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:55] Exception: E0434F4D.System.Threading.ThreadAbortException ("Thread was being aborted.")
[07:59:59] Exception: E0434F4D.System.ServiceModel.FaultException ("The message with Action '' cannot be processed at the receive
r, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Acti
ons between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and recei
ver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).")
[07:59:59] Dump 1 initiated: D:\home\LogFiles\w3wp.exe_170829_075959.dmp
[08:00:04] Dump 1 writing: Estimated dump file size is 290 MB.
[08:00:11] Dump 1 complete: 290 MB written in 12.1 seconds
[08:00:12] Dump count reached.

D:\home\LogFiles>