Search code examples
.netdebuggingwindbgsos

WinDbg, SOS, how to dump all strings on stack


How can I print the string value of all the System.String objects on the current thread's clrstack?

Pseudo code for what I want to do:

foreach ($string in !dso -type System.String) !do $string

or better yet

foreach ($string in !dso -type System.String) !printstring $string

even better yet

foreach (distinct $string in !dso -type System.String) !printstring $string

Thanks!


Solution

  • The latest SOSEX extension (v4) has the !mdso command which has the type filtering option /t.

    SOSEX - Copyright 2007-2012 by Steve Johnson - http://www.stevestechspot.com/
    To report bugs or offer feedback about SOSEX, please email [email protected]
    
    mdso
    Usage: !sosex.mdso [Options]
    
    Dumps object references on the stack and in CPU registers in the current context
    
    Options:
    
    /t:typeFilter - Limits the output to objects whose type name matches the filter expression specified by "typeFilter".
                     Cannot be combined with the /mt option.
    

    so a command of !mdso /t:System.String should work.