inspect heap allocated array or matrix while debugging c++

Viewed 76

I'm using vscode to debug some c++ code, however I cannot inspect any (heap allocated) objects. Like in this example:

float arrayStack[10];  
for (size_t i = 0; i < 10; i++)
{
    arrayStack[i] = -42.3;
}

float *arrayHeap  = new float[10];
for (size_t i = 0; i < 10; i++)
{
    arrayHeap[i] = 84.6;
}

Values of "arrayStack" can be inspected during debugging whereas I can only see the first value of "arrayHeap" but not all elements. Vs-Code allows me to open a "memory.bin" file for "arrayHeap", but it's not really comparable to inspecting "arrayStack". In reality I'm trying to inspect an Eigen::Matrix after initialization and in contrast to my simple example it's really hard to see whats going on there.

  • are all values correctly initialized?
  • is the memory contiguous, i.e. is it save to assume that every 4th "hex-element" corresponds to a float value of my matrix or could the matrix / array be stored accross different patches in the memory?

I've heard about .natvis files for vscode, but I'm not sure if that is helping / best practice for my problem

0 Answers
Related