Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

c - Configure gdb in order to debug floating point calculations

What I am doing: I am writing a program in C that makes extern calls to assembly programs. I use SSE instructions and initially want to use only xmm registers. In order to effectively debug the program I have to keep an eye on the floating point calculations, and I am facing problems doing that in gdb.

What is my setup: after setting the breakpoints for assembly calls in gdb I run the program. In gdb I start tui and set the layout as follows:

layout regs
focus regs
tui reg all

This allows me to track all the registers and the assembly code.

What are my problems:

  1. The information about the ymm registers is cut at the end of the screen: enter image description here I am not able to view the whole information. I have searched through the documentation and I have not found any instruction that tells gdb to wrap lines in the register group windows after a certain amount of characters. Is there a way to force the line breaking?

  2. In this certain program I pass a float value -0.2 into the assembly function. According to the calling conventions this value should be stored in xmm0. With p $xmm0 and p $ymm0 I can look at these registers in the command line: enter image description here At this point I am expecting to see -0.2 in the lowest part of the xmm0 register, but this is actually printed as if it were in the highest part of the register. Why does it happen?

  3. As you can see in these both pictures, the register window shows me that my ymm0 register is empty, but printing it with p $ymm0 reveals that it has -0.200000003 in one of its part. Why these displayed values are different?

Result: I cannot debug the floating point calculations. Would you have any suggestions about how to configure the gdb for tracking these calculations?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...