Help ! :-)
I'm not convinced that alignment by the compiler is the issue. Test
program attached. This produces output such as this :
Addr of __local_argv is 2613F9C4
2613F9B0 DC 12 01 00 44 90 01 00 00 00 00 00 FB FF FF FF
2613F9C0 FF 00 00 00 30 00 14 26 C0 F9 13 26 0C 00 00 00
2613F9D0 14 FA 13 26 F0 F9 13 26 AC 10 01 00 D4 10 01 00
2613F9E0 00 90 01 00 EF BE AD DE 18 2D 44 54 FB 21 09 40
2613F9F0 44 00 00 00 90 00 14 00 01 00 00 00 18 2D 44 54
__local_argv is 26140030
26140020 00 00 00 00 5C E4 C0 83 00 00 00 00 00 00 00 00
26140030 38 01 14 26 30 00 14 26 A0 0F 00 00 78 01 14 26
26140040 00 00 14 26 00 00 00 00 00 00 00 00 00 00 00 00
26140050 00 00 00 00 00 00 00 00 10 00 00 00 30 00 14 26
Foo DEADBEEF 0.000000 68
Note that 0xdeadbeef is at 0x2613f9e4, the float value is right behind
it. I've assigned M_PI to it so it comes out as garbage above, when
assigning 0.0 you can observe all 00 bytes on addresses 0x2613f9e8..ef.
This is nicely aligned on an 8 byte boundary, as it should.
I think the debug session below proves that the value of M_PI still
shows up in __pformat_float, but not in __pformat_cvt .
Does anyone have a clue ?
Danny
pavilion: {472} arm-mingw32ce-gdb stack.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show
copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu
--target=arm-mingw32ce"...
(gdb) target remote ipaq:9999
Remote debugging using ipaq:9999
[New Thread -470998174]
Error while mapping shared library sections:
coredll.dll.0409.mui: No such file or directory.
Error while mapping shared library sections:
coredll.dll: No such file or directory.
Symbol file not found for coredll.dll.0409.mui
Symbol file not found for coredll.dll
WinMainCRTStartup (hInst=0xe7c8cdc6, hPrevInst=0x0,
lpCmdLine=0x2613fed8, nCmdShow=5)
at /home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/crt3.c:35
35 {
(gdb) l __mingw_pformat
1787 }
1788 }
1789 }
1790
1791 int __pformat( int flags, void *dest, int max, const char *fmt,
va_list argv )
1792 {
1793 int c;
1794
1795 __pformat_t stream =
1796 {
(gdb) break 2085
Breakpoint 1 at 0x12e80:
file
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c,
line 2085.
(gdb) c
Continuing.
Breakpoint 1, __mingw_pformat (flags=<value optimized out>, dest=<value
optimized out>,
max=<value optimized out>, fmt=0x1900b " %d\n", argv=<value
optimized out>)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:2089
2089 __pformat_float( va_arg( argv, long double ),
&stream );
(gdb) p stream.flags
$1 = 12320
(gdb) p argv
$2 = <value optimized out>
(gdb) p stream
$3 = {dest = 0x140100, flags = 12320, width = -1, precision = -1, count
= 13, quota = 0,
expmin = 3}
(gdb) s
__pformat_float (x=3.1415926535897931, stream=0x2613f950)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:1232
1232 if( stream->precision < 0 )
(gdb) l
1227 int sign, intlen; char *value;
1228
1229 /* Establish the precision for the displayed value, defaulting
to six
1230 * digits following the decimal point, if not explicitly
specified.
1231 */
1232 if( stream->precision < 0 )
1233 stream->precision = 6;
1234
1235 /* Encode the input value as ASCII, for display...
1236 */
(gdb) s
1220 {
(gdb) s
1232 if( stream->precision < 0 )
(gdb) s
1233 stream->precision = 6;
(gdb) s
808 return __pformat_cvt( 3, z, precision, dp, sign );
(gdb) p z
No symbol "z" in current context.
(gdb) bt
#0 __pformat_float (x=3.1415926535897931, stream=0x2613f950)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:808
#1 0x00012e8c in __mingw_pformat (flags=<value optimized out>,
dest=<value optimized out>,
max=<value optimized out>, fmt=0x1900b " %d\n", argv=<value
optimized out>)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:2089
#2 0x00011864 in __mingw_vprintf (fmt=0x19000 "Foo %08X %f %d\n",
argv=0x2613f9e4)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/vprintf.c:61
#3 0x000112a8 in my_printf (__format=0x44 <Address 0x44 out of bounds>)
at stack.c:41
#4 0x000110ac in main (argc=1, argv=0x140090) at stack.c:51
(gdb) s
807 __pformat_fpreg_t z; z.__pformat_fpreg_ldouble_t = x;
(gdb) s
1220 {
(gdb) s
808 return __pformat_cvt( 3, z, precision, dp, sign );
(gdb) p z
No symbol "z" in current context.
(gdb) s
__pformat_cvt (mode=3, x=
{__pformat_fpreg_double_t = 1.3047604810952043e-313,
__pformat_fpreg_ldouble_t = 1.3047604810952043e-313,
{__pformat_fpreg_mantissa = 26408646140, __pformat_fpreg_exponent =
-1736}, __pformat_fpreg_bitmap = {62972, 9747, 6, 0, 63800},
__pformat_fpreg_bits = 638842364}, nd=1413754136,
dp=0x400921fb, sign=0x50001)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:740
740 {
(gdb) s
750 if( (k = __fpclassifyl( x.__pformat_fpreg_ldouble_t )) &
FP_NAN )
(gdb) bt
#0 __pformat_cvt (mode=3, x=
{__pformat_fpreg_double_t = 1.3047604810952043e-313,
__pformat_fpreg_ldouble_t = 1.3047604810952043e-313,
{__pformat_fpreg_mantissa = 26408646140, __pformat_fpreg_exponent =
-1736}, __pformat_fpreg_bitmap = {62972, 9747, 6, 0, 63800},
__pformat_fpreg_bits = 638842364}, nd=1413754136,
dp=0x400921fb, sign=0x50001)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:750
#1 0x00012210 in __pformat_float (x=<value optimized out>,
stream=0x2613f950)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:808
#2 0x00012e8c in __mingw_pformat (flags=<value optimized out>,
dest=<value optimized out>,
max=<value optimized out>, fmt=0x1900b " %d\n", argv=<value
optimized out>)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/pformat.c:2089
#3 0x00011864 in __mingw_vprintf (fmt=0x19000 "Foo %08X %f %d\n",
argv=0x2613f9e4)
at
/home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/mingw/mingwex/stdio/vprintf.c:61
#4 0x000112a8 in my_printf (__format=0x44 <Address 0x44 out of bounds>)
at stack.c:41
#5 0x000110ac in main (argc=1, argv=0x140090) at stack.c:51
(gdb)
On Tue, 2009-04-21 at 21:31 +0200, Danny Backx wrote:
> I don't think it's a printf issue.
>
> The statement
> fprintf(f, "foo %d %f %d\n", 34, 12.0, 67);
>
> prints
> foo 34 0.000000 1076363264
>
> so I'm inclined to think that the varargs handling is off after a %f.
> Don't know what could cause this though.
>
> Does anyone have a clue ?
>
> Danny
>
>
>
> On Mon, 2009-04-20 at 22:54 +0000, Pierre Ynard wrote:
> >
> >
> > > But it works well if you leave out the -D__USE_MINGW_ANSI_STDIO=1 flag.
> > >
> > > So why are you trying to do this ?
> >
> > Without this flag, this program is dynamically linked against MSVCRT *printf
> > functions, and those present a number of bugs, shortcomings (like, no
> > support
> > of %z modifiers) and weird, non-compliant behaviors (wrong return value,
> > etc...),
> > that we cannot fix. So the %f may work then, but a lot of other things (not
> > shown in this test program) break.
> >
> > We tried patching the format string on the fly, but that's too much of a
> > mess,
> > or reimplementing compliant *printf functions, but mingw does just that for
> > us.
> > There is just this %f bug on WinCE.
> >
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
#include <stdio.h>
#include <windows.h>
main(int argc, char *argv[])
{
double d = 12.0;
printf("Foo %d %f %d\n", 34, d, 67);
exit (0);
}
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel