microsoft / GSL

Guidelines Support Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GSL.natvis file does not work in VS 2019 16.11.9

ZbigniewRA opened this issue · comments

GSL.natvis file does not work in VS 2019 16.11.9 (and 16.11.7). Not sure about other versions.

Visualizer for gsl::span<> shows an error: extent_type<-1> does not have member size_.
In fact the member size_ does not appear in the debugger either.
So while this seems to be a bug in the debugger (or compiler), it is possible to work around it in the GSL.natvis file like this:

	<Type Name="gsl::span&lt;*, -1&gt;">
		<DisplayString>{{ extent = {*(size_t*)(&amp;storage_)} }}</DisplayString>
		<Expand>
			<ArrayItems>
				<Size>*(size_t*)(&amp;storage_)</Size>
				<ValuePointer>storage_.data_</ValuePointer>
			</ArrayItems>
		</Expand>
	</Type>

	<Type Name="gsl::span&lt;*, *&gt;">
		<DisplayString>{{ extent = {$T2} }}</DisplayString>
		<Expand>
			<ArrayItems>
				<Size>$T2</Size>
				<ValuePointer>storage_.data_</ValuePointer>
			</ArrayItems>
		</Expand>
	</Type>

Hi @ZbigniewRA,

It looks like this issue was fixed in GSL 3.1.0. If you're already using that version, feel free to re-open this issue and I'll take another look.

Thanks,
Dmitry

This issue was not fixed in the commit you pointed out.
It might have worked in the past, but doesn't currently work (and yes, I am using release 3.1.0).
(Also I can't reopen this issue. Should I create another one?)

Hi @ZbigniewRA,
Could you please share a code snippet for which you are getting the natvis error? I'm trying to reproduce this on 3.1.0 as well, on VS 2019 16.11.9, and I'm not getting any natvis issues with span. My natvis output successfully logs that it can read the size_ member: Successfully parsed expression 'storage_.size_' in type context 'gsl::span<int,-1>'
span viz

I have discovered that in one CMake project, where I have 2 executables, I get this error on one executable, but not on the other:

Error: class "gsl::span<__int64 const ,-1>::storage_type<gsl::details::extent_type<-1> >" has no member "size_"
    Error while evaluating 'storage_.size_' in the context of type 'indexer.exe!gsl::span<__int64 const ,-1>'.
Ignoring visualizer for type 'gsl::span<__int64 const ,-1>' labeled as 'gsl::span<*, *>' because one or more sub-expressions was invalid.

The CMake files for both projects are identical. The exact same compilation options and libraries are used.
The only thing that changes is the complexity of the C++ code.

I will try to find a repro case though.

I can't find a small repro case, but it seems that the issue is with the debugger (or debugging symbols), as the debugger didn't see the storage_.size_ field either.
But since the natvis file does correctly work in simpler cases shows that it is in fact correct.