How to debug the SSE assembler files (float_dotprod_sse.S)

Hi All,

I am writing some new optimized SSE assembler routines.

I am trying to debug them with gdb but are having the following
problems.

For some reason gdb doesn’t find the source right, or shows the wrong
source.

When I set a breakpoint on float_dotprod_sse it thinks it is in file
…/…/…/…/…/gnuradio-core/src/lib/general/gr_remez.cc, line 864.
While in fact it is in file
…/…/…/…/…/gnuradio-core/src/lib/filter/float_dotprod_sse.S

I added -Wa,–gdwarf2 to CCASFLAGS to enable debugging assembler files.

Also when I step in the assembler routine, it only shows me line line
864 of gr_remez.cc as it thinks this is the current sourcefile.
And when I say list float_dotprod_sse it also shows gr_remez.cc

Since I created a segfault in the assembler routine I would really like
to step through it.

Any ideas what goes wrong here, and how to solve it?

Greetings and thanks,
Martin Dudok van Heel

$ cd trunk
$ mkdir build
$ cd build
$ export CFLAGS="-g -O2 -march=pentium-m -mfpmath=sse -msse -msse2"
$ export CXXFLAGS="-g -O2 -march=pentium-m -mfpmath=sse -msse -msse2"
$ export CCASFLAGS=" -g -O2 -march=pentium-m -mfpmath=sse -msse -msse2
-Wall -Wa,–gdwarf2"
$
$ …/configure 2>&1 | tee configure.log
$ make 2>&1 | tee make.log
$ sudo make install 2>&1 | tee make_install.log
$ cd …/gnuradio-core/src/test/.libs

$ gdb test_filter
GNU gdb 6.4.90-debian
Copyright © 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for
details.
This GDB was configured as “i486-linux-gnu”…Using host libthread_db
library “/lib/tls/i686/cmov/libthread_db.so.1”.

(gdb) break main
Breakpoint 1 at 0x8048870: file
…/…/…/…/gnuradio-core/src/tests/test_filter.cc, line 27.
(gdb) list
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23 #include <cppunit/TextTestRunner.h>
24 #include <qa_filter.h>
25
26 int
27 main (int argc, char **argv)
(gdb) break float_dotprod_sse
Function “float_dotprod_sse” not defined.
Make breakpoint pending on future shared library load? (y or [n]) y

Breakpoint 2 (float_dotprod_sse) pending.
(gdb) run
Starting program:
/pub/projects/intel_LPIA/svn/trunk/build_q1_sse/gnuradio-core/src/tests/.libs/test_filter
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
[New Thread -1214613824 (LWP 15638)]
Breakpoint 3 at 0xb7e42ce5: file
…/…/…/…/…/gnuradio-core/src/lib/general/gr_remez.cc, line 864.
Pending breakpoint “float_dotprod_sse” resolved
[Switching to Thread -1214613824 (LWP 15638)]

Breakpoint 1, main () at
…/…/…/…/gnuradio-core/src/tests/test_filter.cc:27
27 main (int argc, char **argv)

(gdb) break float_dotprod_sse
Note: breakpoint 3 also set at pc 0xb7e42ce5.
Breakpoint 4 at 0xb7e42ce5: file
…/…/…/…/…/gnuradio-core/src/lib/general/gr_remez.cc, line 864.

(gdb) list
859 punt (“gr_remez: insufficient extremals – cannot
continue”);
860
861 if (err == -3)
862 punt (“gr_remez: too many extremals – cannot continue”);
863
864 return std::vector (&coeff[0], &coeff[numtaps]);
865 }
866
867
868
(gdb) list float_dotprod_sse
859 punt (“gr_remez: insufficient extremals – cannot
continue”);
860
861 if (err == -3)
862 punt (“gr_remez: too many extremals – cannot continue”);
863
864 return std::vector (&coeff[0], &coeff[numtaps]);
865 }
866
867
868

On Wed, Oct 10, 2007 at 11:02:52PM +0200, Martin D. wrote:

Martin Dudok van Heel
Try make installing the code first, otherwise you have to use libtool to
run gdb to get it happy. After installing, you can use gdb without
magic.

FWIW, I think the way to run it via libtool is

$ libtool --mode=execute gdb test_filter

However, I much prefer to run gdb from within emacs.
Thus, my preference for “make install” :wink:

Eric

Eric B. wrote:

While in fact it is in file …/…/…/…/…/gnuradio-core/src/lib/filter/float_dotprod_sse.S
Greetings and thanks,
Martin Dudok van Heel

Try make installing the code first, otherwise you have to use libtool to
run gdb to get it happy. After installing, you can use gdb without
magic.
I already found that out.
I did first install the code.
But still it takes the wrong sourcefile.

Any other ideas?

I am now trying without O2. (although I am not sure the SSE code likes
this. The function calls with floating point parameters change. (with
O2,
they are put right into the xmm0 register))

FWIW, I think the way to run it via libtool is

$ libtool --mode=execute gdb test_filter
Haven’t tried this.

However, I much prefer to run gdb from within emacs.
Thus, my preference for “make install” :wink:
With make install, you shouldn’t have to think about it.

Greetings,
Martin

On Wed, Oct 10, 2007 at 11:46:41PM +0200, Martin D. wrote:

Any other ideas?

This worked for me. It seems to be somewhat confused about the
address to source line mapping, but setting the breakpoint using the
address [ b *0x… ] worked.

Eric

an tests]$ libtool --mode=execute gdb test_filter
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for
details.
This GDB was configured as “i586-suse-linux”…Using host libthread_db
library “/lib/libthread_db.so.1”.

(gdb) b main
Breakpoint 1 at 0x8048930: file test_filter.cc, line 27.
(gdb) r
Starting program:
/home/eb/gr/trunk/gnuradio-core/src/tests/.libs/lt-test_filter
[Thread debugging using libthread_db enabled]
[New Thread -1215183184 (LWP 31237)]
[Switching to Thread -1215183184 (LWP 31237)]

Breakpoint 1, main () at test_filter.cc:27
27 main (int argc, char **argv)
(gdb) p float_dotprod_sse
$1 = {<text variable, no debug info>} 0xb7d77ea0 <float_dotprod_sse>
(gdb) b *0xb7d77ea0
Breakpoint 2 at 0xb7d77ea0: file gr_remez.cc, line 864.
(gdb) c
Continuing.
.No 3DNow! support; not tested
.No 3DNow! support; not tested
.No 3DNow! support; not tested
.
Breakpoint 2, 0xb7d77ea0 in float_dotprod_sse () at gr_remez.cc:864
864 return std::vector (&coeff[0], &coeff[numtaps]);
(gdb) bt
#0 0xb7d77ea0 in float_dotprod_sse () at gr_remez.cc:864
#1 0xb7eb8896 in qa_float_dotprod_x86::t1_base (this=0x804b3a8,
float_dotprod=0xb7d77ea0 <float_dotprod_sse>) at
qa_float_dotprod_x86.cc:130
#2 0xb7eb9445 in qa_float_dotprod_x86::t1_sse (this=0x804b3a8)
at qa_float_dotprod_x86.cc:249
#3 0xb7eb3f3b in CppUnit::TestCaller<qa_float_dotprod_x86>::runTest
(this=0x804b140)
at /usr/include/cppunit/TestCaller.h:166
#4 0xb7c7eda7 in CppUnit::TestCaseMethodFunctor::operator() ()
from /usr/lib/libcppunit-1.10.so.2
#5 0xb7c725ae in CppUnit::DefaultProtector::protect ()
from /usr/lib/libcppunit-1.10.so.2
#6 0xb7c7aab3 in CppUnit::ProtectorChain::ProtectFunctor::operator() ()
from /usr/lib/libcppunit-1.10.so.2
#7 0xb7c7a7fd in CppUnit::ProtectorChain::protect () from
/usr/lib/libcppunit-1.10.so.2
#8 0xb7c873c1 in CppUnit::TestResult::protect () from
/usr/lib/libcppunit-1.10.so.2
#9 0xb7c7e718 in CppUnit::TestCase::run () from
/usr/lib/libcppunit-1.10.so.2
#10 0xb7c7f39f in CppUnit::TestComposite::doRunChildTests ()
from /usr/lib/libcppunit-1.10.so.2
#11 0xb7c7f2da in CppUnit::TestComposite::run () from
/usr/lib/libcppunit-1.10.so.2
#12 0xb7c7f39f in CppUnit::TestComposite::doRunChildTests ()
from /usr/lib/libcppunit-1.10.so.2
#13 0xb7c7f2da in CppUnit::TestComposite::run () from
/usr/lib/libcppunit-1.10.so.2
#14 0xb7c7f39f in CppUnit::TestComposite::doRunChildTests ()
from /usr/lib/libcppunit-1.10.so.2
#15 0xb7c7f2da in CppUnit::TestComposite::run () from
/usr/lib/libcppunit-1.10.so.2
#16 0xb7c89920 in CppUnit::TestRunner::WrappingSuite::run ()
from /usr/lib/libcppunit-1.10.so.2
#17 0xb7c8702a in CppUnit::TestResult::runTest () from
/usr/lib/libcppunit-1.10.so.2
#18 0xb7c89760 in CppUnit::TestRunner::run () from
/usr/lib/libcppunit-1.10.so.2
#19 0xb7c8cf85 in CppUnit::TextTestRunner::run () from
/usr/lib/libcppunit-1.10.so.2
#20 0x080489ae in main () at test_filter.cc:34
(gdb) x/20i $pc
0xb7d77ea0 <float_dotprod_sse>: push %ebp
0xb7d77ea1 <float_dotprod_sse+1>: mov %esp,%ebp
0xb7d77ea3 <float_dotprod_sse+3>: mov 0x8(%ebp),%edx
0xb7d77ea6 <float_dotprod_sse+6>: mov 0xc(%ebp),%eax
0xb7d77ea9 <float_dotprod_sse+9>: mov 0x10(%ebp),%ecx
0xb7d77eac <float_dotprod_sse+12>: xorps %xmm4,%xmm4
0xb7d77eaf <float_dotprod_sse+15>: xorps %xmm5,%xmm5
0xb7d77eb2 <float_dotprod_sse+18>: and $0x3,%ecx
0xb7d77eb5 <float_dotprod_sse+21>: jmp 0xb7d77ecf <.loop1+15>
0xb7d77eb7 <float_dotprod_sse+23>: mov %esi,%esi
0xb7d77eb9 <float_dotprod_sse+25>: lea 0x0(%edi),%edi
0xb7d77ec0 <.loop1>: movaps (%eax),%xmm0
0xb7d77ec3 <.loop1+3>: mulps (%edx),%xmm0
0xb7d77ec6 <.loop1+6>: add $0x10,%edx
0xb7d77ec9 <.loop1+9>: add $0x10,%eax
0xb7d77ecc <.loop1+12>: addps %xmm0,%xmm4
0xb7d77ecf <.loop1+15>: dec %ecx
0xb7d77ed0 <.loop1+16>: jge 0xb7d77ec0 <.loop1>
0xb7d77ed2 <.loop1+18>: mov 0x10(%ebp),%ecx
0xb7d77ed5 <.loop1+21>: movaps %xmm5,%xmm6
(gdb)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs