2012-08-02 60 views
3

如何在當前線程的clrstack中打印所有System.String對象的字符串值?WinDbg,SOS,如何轉儲堆棧上的所有字符串

的僞碼我想做的事:

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 

謝謝!

回答

3

最新的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 [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. 

所以!mdso /t:System.String命令應該工作。

+0

謝謝,這很好,因爲mdso已經打印了字符串內容 – 2012-08-03 08:28:33

1

我的想法是在堆棧的地址中查找字符串對象引用。例如,我們知道堆棧底部地址(0x000000001821CEF0)和堆棧頂部地址(000000001821E3F0)。我們可以遍歷這個範圍內的所有地址(w/8個字節步)並輸出對象的詳細信息。

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

「!dso」命令沒有'-type'(也不是'-short')標誌。 – 2012-08-02 14:40:31

+0

謝謝,但這並不真正奏效。正如布賴恩所說,沒有類型的標誌(也不是一個短標誌,我認爲) – 2012-08-02 14:44:46

+0

是的,剛剛發現,現在將尋找另一個解決方案 – 2012-08-02 14:44:49

1

使用!sosex.strings。該命令將允許您查看所有字符串的值,或按大小,內容或GC代進行過濾。

+0

謝謝。但是,這會失去與我感興趣的特定堆棧的關係。我有時會發現查看callstack中的前N個字符串很有用,所以我想要一個只是簡單地轉儲這些字符串的命令。 – 2012-08-02 15:31:37

+0

我很抱歉。我錯誤地把你的問題看成堆,而不是堆疊。 – 2012-08-02 21:56:41

+0

看起來你的sosex仍然是一個非常好的解決方案!mdso /t:System.String由jcopenha建議 – 2012-08-03 08:30:56