gdb printing a __m256i as 8x 32-bit elements instead of the default 4x 64-bit?

Viewed 318

I use gdb to debug a program that uses AVX2 intrinsics via immintrin.h header.

With gdb, I can print out __m256 values without any issues, like so:

>>> print scl8
$4 = {[0] = 0.0078125, [1] = 0.0078125, [2] = 0.0078125, [3] = 0.0078125, [4] = 0.0078125, [5] = 0.0078125, [6] = 0.0078125, [7] = 0.0078125}

In this particular example, all 8 lanes contain the value 1/128. And note that gdb prints out all 8 lanes!

If I want to print out epi32 values of a __m256i value, things go wrong:

>>> print msk8
$6 = {[0] = 4294967297, [1] = 4294967297, [2] = 4294967297, [3] = 4294967297}

Why would gdb print 4 lanes (of what I assume are 64bit integers) for __m256i but 8 lanes of 32bit floats for __m256 values? Where is the consistency in here?

How can I print 8 epi32 values from a __m256i using gdb?

$ gdb --version
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
1 Answers

I have not found easier solution but you can cast your value to __v8si, i.e. (__v8si) ones will print 8 lanes.

So probably watch expression, debugger console, or leaving non-used variables (will be optimized in release build) can help with debugging.

I would like to see some attributes or comments I can put in debug build, which can affect GDB.

Related