Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print value of __m128 datatype in gdb debugger

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.

like image 979
Patrick Avatar asked Nov 24 '13 18:11

Patrick


People also ask

What is __ 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.

What is print command in gdb?

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).

Which command in gdb is used to find the type of variable?

The ptype [ARG] command will print the type. Show activity on this post.

How do I change a variable value in gdb?

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.

What are the different settings of GDB for debugging?

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.

How does GDB print a value?

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.

Why does GDB stop printing after printing a large array?

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.

What is output output format in gdb?

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.


Video Answer


1 Answers

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

like image 72
Paul R Avatar answered Oct 03 '22 00:10

Paul R