WinDbg, SOS, how to dump all strings on stack
Question
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 sjjohnson@pobox.com
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.
OTHER TIPS
Use !sosex.strings. This command will allow you to view the values of all strings, or to filter them by size, content or GC generation.
My idea is to look for string objects references among addresses of the stack. For example, we know stack bottom address(0x000000001821CEF0), and stack top address (000000001821E3F0). We can loop through all addresses in this range (w/ 8 bytes step) and output object details.
.for (r $t0=0x000000001821CEF0;@$t0<000000001821E3F0;r $t0=@$t0+0x8){ !do poi(@$t0) }