Dumping STL strings with WinDbg
I can't dump STL strings with WinDbg anymore - I used to be able to dump an STL string using the command: dt -r (MSVCP90!string) address
, or for wide strings, dt -r (MSVCP90!wstring) address
. Unfortunately I can't do this anymore - I have a symbol path, and when I list modules it shows that symbols are loaded for MSVCP90:
74110000 7419e000 MSVCP90 (pdb symbols) x开发者_JAVA技巧:\symbols\msvcp90.i386.pdb\A23D796E66BB430B891568A6EF0C750C1\msvcp90.i386.pdb
When I execute the command, the output I get is this:
0:025> dt -r (MSVCP90!string)
*************************************************************************
*** ***
*** ***
*** Your debugger is not using the correct symbols ***
*** ***
*** In order for this command to work properly, your symbol path ***
*** must point to .pdb files that have full type information. ***
*** ***
*** Certain .pdb files (such as the public OS symbols) do not ***
*** contain the required information. Contact the group that ***
*** provided you with these symbols if you need this command to ***
*** work. ***
*** ***
*** Type referenced: MSVCP90!string ***
*** ***
*************************************************************************
Symbol MSVCP90!string not found.
My symbol path is set like so:
0:025> .sympath
Symbol search path is: srv*X:\Symbols*http://msdl.microsoft.com/download/symbols
Expanded Symbol search path is: srv*x:\symbols*http://msdl.microsoft.com/download/symbols
I have found the SDbgExt extension, but from what I read it was for the 7.0 version of the runtime - this is 9.0.
Does anyone have an idea on why this feature has ceased to work? I really can't live without it!
Thanks!
EDIT: For good measure, I also tried enabling noisy symbol mode. I got this output:
0:025> .reload /f MSVCP90.dll
DBGHELP: MSVCP90 - public symbols
x:\symbols\msvcp90.i386.pdb\A23D796E66BB430B891568A6EF0C750C1\msvcp90.i386.pdb
So it really looks like my symbols are fine.
You can also use
!stl <name>
From the docs:
The
!stl
extension displays some of the known Standard Template Library (STL) templates. This extension currently supports STL templates of the following types:string
,wstring
,vector<string>
,vector<wstring>
,list<string>
,list<wstring>
, and pointers to any of the preceding types.
If it is just for STL strings, than you can dump the string manually. It is very easy. The only slight complication is due to the fact that STL string could keep short strings inside the structure (and longer are always in the heap). STL string starts with either the sting itself (very short one) or pointer to the string. These two commands will dump the single-byte string:
da <address>
da poi <address>
Remember that only one of the commands will actually show the string -- you can usually figure out by the output. If unsure, dd <address> + 0x10 l1
is the lenght of the string.
Similarly for wide character strings:
du <address>
du poi <address>
Public symbols have no type information. You need to find "private" symbols for the DLL. You can also use your executable / DLL for the type definition.
Try 'dx' command, shows std::string content very well for me
I think 'dx' is new in Windows 10
dx (Display NatVis Expression) https://msdn.microsoft.com/en-us/library/windows/hardware/dn936815(v=vs.85).aspx
create script mystr.txt
$$ save to file myStr.txt .if(@@C++(${$arg1}->_Mypair._Myval2._Mysize)<16) { da @@C++(${$arg1}->_Mypair._Myval2._Bx._Buf) } .else { da @@C++(${$arg1}->_Mypair._Myval2._Bx._Ptr) }
2. call script with parameter e.g.
$$>a<c:\mystr.txt strVarName
- see the stl string content.
精彩评论