EreTIk's Box » Заметки о WinDbg » WinDbg 10.0.10075 получил поддержку .NatVis-файлов


Наряду с поддержкой ethernet-отладки Windows 10 10074, в WinDbg 10.0.10075 наконец-то появилась поддержка .NatVis-файлов. Если кто вдруг кто не знает, то это файлы для custom-представления переменных сложных типов.


Набросаем и соберем в Visual Studio 2013 простой тест:


int _tmain(int argc, _TCHAR* argv[]) { std::string TestString; TestString = "test!"; std::vector<int> TestVector(2); TestVector[0] = 0; TestVector[1] = -100000; __debugbreak(); return 0; }

В директории WinDbg (C:\Program Files (x86)\Windows Kits\10\Debuggers\x64) создаем символическую ссылку Visualizers на директорию Visualizers в Visual Studio 2013. Результат должен быть таким:


C:\Program Files (x86)\Windows Kits\10\Debuggers\x64>fsutil reparsepoint query Visualizers Reparse Tag Value : 0xa0000003 Tag value: Microsoft Tag value: Name Surrogate Tag value: Mount Point Substitue Name offset: 0 Substitue Name length: 186 Print Name offset: 188 Print Name Length: 178 Substitute Name: \??\C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers Print Name: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers

Запускам тест в WinDbg, ждем отладочное исключение в wmain. Наслаждаемся:


0:000> dv argc = 1 argv = 0x00000000`00336e90 TestString = "test!" TestVector = { size=2 }

Кликаем по TestString:


0:000> dx -r1 ((natvis_test!std::basic_string<char,std::char_traits<char>,std::allocator<char> > *)0x18f778) ((natvis_test!std::basic_string<char,std::char_traits<char>,std::allocator<char> > *)0x18f778) : 0x18f778 : "test!" : [Type: std::basic_string<char,std::char_traits<char>,std::allocator<char> > *] "test!"[Type: std::basic_string<char,std::char_traits<char>,std::allocator<char> >] [<Raw View>] [size] : 5 [capacity] : 15

Кликаем по TestVector:


0:000> dx -r1 ((natvis_test!std::vector<int,std::allocator<int> > *)0x18f7b8) ((natvis_test!std::vector<int,std::allocator<int> > *)0x18f7b8) : 0x18f7b8 : { size=2 } : [Type: std::vector<int,std::allocator<int> > *] { size=2 }[Type: std::vector<int,std::allocator<int> >] [<Raw View>] [size] : 2 [capacity] : 2 [0] : 0 [1] : -100000

Как видно выше, используется новая команда dx. В лучших традициях эта команда не описана в приложенной к отладчику справке. Но разработчики не поленились и добавили обработку соответствующего параметра командной строки:


0:000> dx /? DX [-r[#]] <expr> - display C++ expression using extension model (e.g.: NatVis) DX [-r[#]] <expr>[,<FormatSpecifier>] - display C++ expression using extension model (e.g.: NatVis) in a specified format -e *TEMPORARY* -- Revert back to the C++ (??) expression evaluator for <expr>. -? Show this help. -h Show help for displayed items. -n Show raw/native information only (e.g.: No NatVis) -r[l] Recursively dump the subtypes (fields) upto l levels. -v Verbose output (includes methods and other non-typical objects) Format Specifiers: ,x Display ordinals in hexidecimal ,d Display ordinals in decimal ,o Display ordinals in octal ,b Display ordinals in binary ,en Display enums by name only (no value) ,c Display as single character (not a string) ,s Display 8-bit strings as ASCII quoted ,sb Display 8-bit strings as ASCII unquoted ,s8 Display 8-bit strings as UTF-8 quoted ,s8b Display 8-bit strings as UTF-8 unquoted ,su Display 16-bit strings as UTF-16 quoted ,sub Display 16-bit strings as UTF-16 unqouted ,! Display objects in raw mode only (e.g.: no NatVis) ,# Specify length of pointer/array/container as the literal value # (replace with numeric) ,[<expression>] Specify length of pointer/array/container as the expression <expression> ,nd Do not find the derived (runtype) type of the object. Display static value only

Updated (11.11.2015)


После выпуска релизной версии отладчика (10.0) поддержка NatVis'ов задокументирована


ΞρεΤΙκ