I am trying to understand how I can see elements hold in an OwnedArray.
I explain:
when digging into let's say, member OwnedArray<AudioPluginFormat> formats (in class AudioPluginFormatManager), I can see that member numUsed = 3. There are 3 elements into the array and I need to see what they are.
So I expand the object into VS Watch section, I can see member data, then elements, then data again, etc etc etc, and I never get to the elements themselves. (see attached picture)
I surely miss something, thanks for your kind help.
will show the arrays contents but is in most cases useless as one often wants to have a look at some members of the element. The following will work in this case but is a bit more cumbersome as you can't easily search through the array:
[code]
ownedArray.data.elements.data[0]->member
ownedArray.data.elements.data[1]->member
[/code]
As a related question: Is it possible to look into Arrays, HeapBlocks and so on in XCode without having to decrypt the memory view?
will show the arrays contents but is in most cases useless as one often wants to have a look at some members of the element. The following will work in this case but is a bit more cumbersome as you can’t easily search through the array:
You could create your own debugger extension for VS using autoexp.dat -> https://blogs.msdn.microsoft.com/vcblog/2012/07/12/debugger-type-visualizers-for-c-in-visual-studio-2012/
Maybe this is something that could be added to JUCE package?
Sorry to drag this 8 year old subject back to life.
I’ve been using OwnedArray quite a lot recently, and it would be really useful to easily see the individual array elements whilst debugging.
Did anyone make a suitable visualiser script for doing this in Visual Studio?
I can’t make sense of the MS pages on natvis files. Can anyone help please?
Oh man, I still can’t get that to work, even with the the standard juce:Array.
I’ve tried adding the file via ‘add existing’, and add new natvis file options. I’ve also added it to the two directories given here:
I can’t believe such a basic idea as debugging container contents would be so weirdly complicated. It should be the primary thing a C++ debugger would do.
Yeah, I’ve tried adding it to the sources. I see you’ve clicked off the Binary Resource checkbox as well. No joy yet, but thanks for the help. edit I’ve also tried debugging Array and std::vector
If it’s of any help for you, juce.natvis seems to work for me. I have it in two locations
%USERPROFILE%\Documents\Visual Studio 2022\Visualizers
and
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Packages\Debugger\Visualizers
Don’t know which one of those is the active one. They are the same file anyway.
I can send you my actual file if it for any reason is different than yours
Not sure it would help, but you can turn natvis diagnostic output on/off from the Debugging/Output Window section of Options. Maybe it’s finding the file, but having issues using it?
I don’t get the error now, when I open an Array called ‘gather’ which can contain many objects, in the debugger the output lists this:
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(6,6): Successfully parsed expression 'values.numUsed == 0' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(6,75): Successfully parsed expression 'values.numAllocated' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(7,32): Successfully parsed expression 'values.numUsed' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(7,47): Successfully parsed expression 'values.numAllocated' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(9,32): Successfully parsed expression 'values.numUsed' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(11,19): Successfully parsed expression 'values.numUsed' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(12,27): Successfully parsed expression 'values.elements.data' in type context 'juce::Array<Wall *,juce::DummyCriticalSection,0>'.
BUT it still doesn’t display anything different in either the debugger or the watch window.
The verbose natvis output says values.numUsed == 0’:
I don’t know if that’s significant.
Natvis: C:\Users\daveh\Documents\Visual Studio 2022\Visualizers\juce.natvis(4,6): Successfully parsed expression 'values.numUsed == 0' in type context 'juce::Array<int,juce::DummyCriticalSection,0>'.