code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

Helpers for build in c++ types

Open dzvancuks opened this issue 5 years ago • 3 comments

How can I see data for complex types such as std::ifstream? When I debug and hover on std::string it shows me string data in quotes(e.g. "text"). What can be done for other built in types?

Debugger usually shows <incomplete type> I've installed libstdc++6-5-dbg and now ifstream variable shows all excess template data like: {<std::basic_istream<char, std::char_traits<char> >> = {<std::basic_ios<char, std::char_traits<char> >> = {<std::ios_base> = {_vptr.ios_base = 0x7f3000 <vtable for std::basic_ifstream<char, std::char_traits<char> >@@GLIBCXX_3.4+64>, static boolalpha = std::_S_boolalpha, static dec = std::_S_dec, static fixed = std::_S_fixed, static hex = std::_S_hex, static internal = std::_S_internal, static left = std::_S_left, static oct = std::_S_oct, static right = std::_S_right, static scientific = std::_S_scientific, static showbase = std::_S_showbase, static showpoint = std::_S_showpoint, static showpos = std::_S_showpos, static skipws = std::_S_skipws, static unitbuf = std::_S_unitbuf, static uppercase = std::_S_uppercase, static adjustfield = std::_S_adjustfield, static basefield = std::_S_basefield, static floatfield = std::_S_floatfield, static badbit = std::_S_badbit, static eofbit = std::_S_eofbit, static failbit = std::_S_failbit, static goodbit = std::_S_goodbit, static app = std::_S_app, static ate = std::_S_ate, static binary = std::_S_bin, static in = std::_S_in, static out = std::_S_out, stat (etc. etc.)

dzvancuks avatar Dec 30 '19 14:12 dzvancuks

if your debugger supports special types, you can try changing valuesFormatting to other values.

Otherwise you might want Natvis support, which the C/C++ extension supports instead.

WebFreak001 avatar Dec 30 '19 15:12 WebFreak001

I'm using GDB 7.11.1 in VSCode over WSL

if your debugger supports special types, you can try changing valuesFormatting to other values.

I've changed to 'prettyPrinters'. Hovering over std::map seems fine: std::map with 2 elements = {[1] = 97 'a', [3] = 98 'b'} but Variable view is incorrect no matter what valuesFormatting is set to: disabled: var_1_m.private._M_t.protected._M_impl.public._M_header.public._M_color...(etc., stl view) parseText: <unknown> prettyPrinters: [0]:1 [1]:97 'a' [2]:3 [3]98 'b' (prints as vector, not map)

Is it Native Debug issue or VSC?

Otherwise you might want Natvis support, which the C/C++ extension supports instead.

is it supported by Native Debug?

All in all I think extending Pretty printing via Python is probably best option for GDB. Problem is in Variable view in VSC.

dzvancuks avatar Jan 02 '20 10:01 dzvancuks

no natvis is not supported by native debug and there is also not a lot of features specific to one language. (and probably also won't be in the future)

The map issue here can probably be fixed though without breaking any other languages and having generic better formatting of that type.

WebFreak001 avatar Jan 02 '20 10:01 WebFreak001