Subject: Re: Floating point quirks
To: None <ragge@ludd.luth.se>
From: Jarkko Teppo <jarkko.teppo@er-grp.com>
List: port-vax
Date: 01/30/2004 10:59:36
On Fri, Jan 30, 2004 at 09:07:04AM +0100, ragge@ludd.luth.se wrote:
> > 
> > vax:~/Development/c/vax$ cc -O0 -g -o atan atan.c -lm
> > vax:~/Development/c/vax$ ./atan
> > Illegal instruction (core dumped)
> > 
> > 
> Run it under gdb, break at atan(), and single-step into the lib to see
> what is happening.  Obviously it is some weirdness with shared
> libraries here.
> 

Dynamically linked:

(gdb) set step-mode on
(gdb) break 7
Breakpoint 1 at 0x10741: file atan.c, line 7.
(gdb) r
Starting program: /usr/home/jarkko/Development/c/vax/atan 

Breakpoint 1, main (1, 2147482500, 2147482508) at atan.c:7
7       double x=0.5;
(gdb) step
8       printf("%f\n",atan(x));
(gdb) step
0x7f7c3bac in atan (16384, 0) from /usr/lib/libm.so.0
(gdb) step
Single stepping until exit from function atan, 
which has no line number information.
0x7f7c3d42 in atan2 (16384, 0, 16512, 0) from /usr/lib/libm.so.0
(gdb) step
Single stepping until exit from function atan2, 
which has no line number information.
Error accessing memory address 0x2: Invalid argument.
(gdb) r

Stepping into atan2 again and disassemble..

0x7f7c3ec1 <atan2+385>: movq r0,r10
0x7f7c3ec4 <atan2+388>: muld2 r0,r0
0x7f7c3ec7 <atan2+391>: polyd r0,$12,0x7f7c3f30 <atan2+496>
0x7f7c3ecc <atan2+396>: muld2 r10,r0
0x7f7c3ecf <atan2+399>: subd2 r0,r8

(gdb) break *0x7f7c3ec4
Breakpoint 2 at 0x7f7c3ec4
(gdb) s
Single stepping until exit from function atan2,
which has no line number information.

Breakpoint 2, 0x7f7c3ec4 in atan2 (16384, 0, 16512, 0) from /usr/lib/libm.so.0
(gdb) si
0x7f7c3ec7 in atan2 (16384, 0, 16512, 0) from /usr/lib/libm.so.0
(gdb) info regi
r0             0x0      0
r1             0x0      0
r2             0x4000   16384
r3             0x0      0
r4             0x4120   16672
r5             0x0      0
r6             0x63383fed       1664630765
r7             0xda7b2b0d       -629462259
r8             0xbf912295       -1081007467
r9             0xf0ea17b2       -253093966
r10            0x0      0
r11            0x0      0
ap             0x7ffffae4       2147482340
fp             0x7ffffaa0       2147482272
sp             0x7ffffa98       2147482264
pc             0x7f7c3ec7       2138848967
ps             0x3c00004        62914564
(gdb) si
Error accessing memory address 0x2: Invalid argument.
(gdb)

The same "Error accessing memory..." comes up when trying the same 
thing with the statically linked version.

polyd is emulated by the kernel ?

Thanks in advance,
-- 
jht