.net WinDbg,SOS,如何转储堆栈上的所有字符串

.net WinDbg,SOS,如何转储堆栈上的所有字符串,.net,debugging,windbg,sos,.net,Debugging,Windbg,Sos,如何打印当前线程clrstack上所有System.string对象的字符串值 我想做的事情的伪代码: foreach ($string in !dso -type System.String) !do $string 或者更好 foreach ($string in !dso -type System.String) !printstring $string foreach (distinct $string in !dso -type System.String) !printstrin

如何打印当前线程clrstack上所有System.string对象的字符串值

我想做的事情的伪代码:

foreach ($string in !dso -type System.String) !do $string
或者更好

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

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

谢谢

我的想法是在堆栈地址中查找字符串对象引用。例如,我们知道堆栈底部地址(0x000000001821CEF0)和堆栈顶部地址(00000000 1821E3F0)。我们可以循环遍历该范围内的所有地址(w/8字节步长)并输出对象详细信息

.for (r $t0=0x000000001821CEF0;@$t0<000000001821E3F0;r $t0=@$t0+0x8){ !do poi(@$t0) }

.for(r$t0=0x000000001821CEF0;@$t0使用!sosex.strings。此命令将允许您查看所有字符串的值,或按大小、内容或GC生成对其进行筛选。

最新的sosex扩展名(v4)具有
!mdso
命令,该命令具有类型筛选选项
/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.

因此,
!mdso/t:System.String
的命令应该可以工作。

对于
!dso
命令,没有
-type
(也没有
-short
)标志。谢谢,但这实际上不起作用。正如Brian所说,没有类型标志(我认为也没有-short标志)。如果我可以的话。foreach(ico{!dso-short}){!do ico}然后我可以对所有字符串进行grep,但是如果没有-short标志,这一点都不好用…谢谢,第二个建议非常好用,如果输出到文本文件,然后对“String:”进行grep:@BenSchwehn我希望有一种方法可以使用.if语句按类型筛选对象。不幸的是,如果堆栈上的地址错误,我会遇到问题。一旦找到合适的解决方案,我会更新答案。谢谢。但是,这会失去与我感兴趣的特定堆栈的关系。我有时发现查看堆栈中的前N个字符串很有用callstack,所以我希望有一个只转储这些内容的命令。很抱歉,我将您的问题误读为heap,而不是stack。看起来您的sosex仍然是一个非常好的解决方案,使用!mdso/t:System.String正如jcopenhaThanks所建议的,它可以很好地工作,因为mdso已经打印了字符串内容