Is there any way to print the value of a variable of datatype __m128
(used for Intel SSE intrinsics) directly in GDB? The command print $myVariable
works fine for int
and float
but not for __m128
.
__m128d is a data type that the compiler will hopefully store in a XMM 128 bit register when optimizing (if not optimizing it away as @PeterCordes commented). It's not inherently different from an int or long , which the compiler will hopefully store in integer registers when optimizing.
The usual way to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the value of an expression of the language your program is written in (see section Using GDB with Different Languages).
The ptype [ARG] command will print the type. Show activity on this post.
Use the set variable (gdb) and the assign (dbx) commands to change the value associated with a variable, memory address, or expression that is accessible according to the scope and visibility rules of the language. The expression can be any expression that is valid in the current context.
These settings are useful for debugging programs in any language: set print address set print address on GDB prints memory addresses showing the location of stack traces, structure values, pointer values, breakpoints, and so forth, even when it also displays the contents of those addresses.
By default, GDB prints a value according to its data type. Sometimes this is not what you want. For example, you might want to print a number in hex, or a pointer in decimal.
If GDB is printing a large array, it stops printing after it has printed the number of elements set by the set print elementscommand. This limit also applies to the display of strings. Setting the number of elements to zero means that the printing is unlimited.
Output formats By default, GDB prints a value according to its data type. Sometimes this is not what you want. For example, you might want to print a number in hex, or a pointer in decimal. Or you might want to view data in memory at a certain address as a character string or as an instruction.
It's a pain, but I usually do it like this:
gdb> p *(float *)&v@4
This is assuming that v
is __m128
. You can apply the same principle for e.g. an __m128i
vector of unsigned char
:
gdb> p /x *(unsigned char *)&v@16
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With