From: Pedro A. <ped...@po...> - 2006-08-29 21:06:35
|
Pedro Alves wrote: > > > I've started looking at this, and this is what I see that shouldn't be > happening: > > Breakpoint 3, _initstdio () > at > /cygdrive/d/cegccsf/cegcc/cegcc/src/gcc/newlib/libc/sys/wince/io.c:133 > 133 { > (gdb) b _initstdio > Note: breakpoint 3 also set at pc 0xdc9274. > Breakpoint 4 at 0xdc9274: file > /cygdrive/d/cegccsf/cegcc/cegcc/src/gcc/newlib/libc/sys/wince/io.c, line > 133. > (gdb) p __StdioInited > $2 = 0 > (gdb) n > 134 if(!__StdioInited) > (gdb) > 136 __StdioInited = 1; > (gdb) > 134 if(!__StdioInited) > (gdb) p __StdioInited > $3 = 0 > (gdb) n > 136 __StdioInited = 1; > (gdb) p __StdioInited > $4 = 0 > (gdb) n > 137 _initstdfd(stdin, 0, > (HANDLE)_fileno(_getstdfilex(0)), __SRD); > (gdb) p __StdioInited > $5 = 0 > (gdb) n > warning: 0005D091:E7B5E67A: _initstdfd: fd 0 hnd c6ad931e > 138 _initstdfd(stdout, 1, > (HANDLE)_fileno(_getstdfilex(1)), __SWR); > (gdb) p __StdioInited > $6 = 0 > (gdb) > > > That __StdioInited = 1 assignment on line 136, isn't really > writing anything! The value reads always 0. > This is what I was talking about. We have to understand why > __StdioInited ends up with 0, and not 1. > From this, it looks like we have bad code generation. > Will have to look into the assembly. Or perhaps somehow > the section where __StdioInited ended up is not writable, although > I would expect a kernel exception in that case. > Scratch that. The variable is being set to 1 here, but gdb isn't reading the value correctly. What's funny is that the test doesn't fail for me! I always get fd = 3 in both app and dll, and the files are always written ok. Please find attached a new test case. It relies on having gdb around. Danny, could you run it and post the results? Below are my full results, and here is a resume: warning: 000AAC7F:27852A96: open(/My Documents/testfile_app.txt, 601, 6000010) warning: 000AAD0A:27852A96: _assignfd returns 3 warning: app: fp = 3, errno = 0, __StdioInited = 1 warning: 000AAE06:27852A96: write(3, 9, a6b48fae) warning: written: 9 warning: 000AAF62:27852A96: open(/My Documents/testfile_dll.txt, 601, 6000010) warning: 000AAFF8:27852A96: _assignfd returns 3 warning: dll: fp = 3, errno = 0, __StdioInited = 1 warning: 000AB0B3:27852A96: write(3, 9, 26b48fae) warning: written: 9 And the contents of both files: [/cygdrive/d/cegccsf/cegcc/cegcc/src/dlltest]>cat testfile_app.txt test app [Administrador@mamas-laptop][21:50:24] [/cygdrive/d/cegccsf/cegcc/cegcc/src/dlltest]>cat testfile_dll.txt test dll [Administrador@mamas-laptop][21:50:27] Hummm, could it be because we are using different binutils releases? You are still using the 2.17 release, and I am using current cvs+patches. There may have been something fixed in the cvs version. Both binutils and gdb share the bfd library, and the gdb we are using, has an older copy of bfd. Could be the reason I can't read the value of __StdioInited in gdb. Anyway, I'll work on commiting the binutils patches to our trunk, so you can try it. Cheers, Pedro Alves [/cygdrive/d/cegccsf/cegcc/cegcc/src/dllcrt]>make debug arm-wince-pe-gdb.exe \ --exec=usedemo.exe \ --symbols=usedemo.exe \ --command=gdb-commands.txt 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 "--host=i686-pc-cygwin --target=arm-wince-pe"... Prefix for loading absolute shared library symbol files is "/cygdrive/d/cegccsf/cegcc/cegcc/src/cegcc". The search path for loading non-absolute shared library symbol files is /cygdrive/d/cegccsf/cegcc/cegcc/src/cegcc/libstdc++:/cygdrive/d/cegccsf/cegcc/cegcc/src/cegcc/cegccdll:/cygdrive/d/cegccsf/cegcc/cegcc/src/cegcc/cegccthrd. (gdb) r Starting program: /cygdrive/d/cegccsf/cegcc/cegcc/src/dlltest/usedemo.exe Starting on device: "\gdb\wince-stub.exe \gdb\wince-stub.exe" Waiting for connection... Connected Uploading to remote device: \gdb\usedemo.exe .................... Process Created Error while mapping shared library sections: iphlpapi.dll: No such file or directory. Error while mapping shared library sections: ws2.dll: No such file or directory. 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. warning: __init_c__: initted = 0 warning: __init_c__: calling __init_ce_reent warning: 000AA483:27852A96: in __init_c__() warning: 000AA4D4:27852A96: __argc = 1 warning: 000AA50F:27852A96: __argv[0] = /gdb/usedemo.exe warning: 000AA564:27852A96: initres = 1 warning: parsing: "WCETRACE":"" warning: no more tokens warning: parsing: "WCETRACE_DEBUGGER":"all:-malloc" warning: option token "all" warning: checking option warning: valid option found. warning: option token "-malloc" warning: neg option warning: checking option warning: valid option found. warning: no more tokens warning: 000AA8D7:27852A96: inherit_parent: unattached warning: 000AA91D:27852A96: chdir: path "\gdb" warning: 000AA94F:27852A96: chdir: success, cwd is "/gdb" warning: 000AA99D:27852A96: ioctl(0, 0x5406 0x2611fe78) warning: 000AA9E5:27852A96: Invalid file handle: 0 warning: 000AAB37:27852A96: _initstdfd: fd 0 hnd 6b8f9e6 warning: 000AAB78:27852A96: _initstdfd: fd 1 hnd c7f9af76 warning: 000AABC6:27852A96: _initstdfd: fd 2 hnd 796dfc6 warning: 000AAC02:27852A96: _startup_: calling main warning: 000AAC41:27852A96: _startup_: calling _main warning: 000AAC7F:27852A96: open(/My Documents/testfile_app.txt, 601, 6000010) warning: 000AACC5:27852A96: _assignfd(a6b48fae) warning: 000AAD0A:27852A96: _assignfd returns 3 warning: 000AAD49:27852A96: open returns 3 fd 3 cxt 0x8408aba0 (hnd a6b48fae) warning: app: fp = 3, errno = 0, __StdioInited = 1 warning: 000AAE06:27852A96: write(3, 9, a6b48fae) warning: written: 9 warning: 000AAE94:27852A96: close(3) warning: 000AAED4:27852A96: close: fd 3 type 1 flags 0 hnd 0xa6b48fae cxt 0x0 warning: 000AAF26:27852A96: ch: 0xa6b48fae 1 warning: 000AAF62:27852A96: open(/My Documents/testfile_dll.txt, 601, 6000010) warning: 000AAFAA:27852A96: _assignfd(26b48fae) warning: 000AAFF8:27852A96: _assignfd returns 3 warning: 000AB02C:27852A96: open returns 3 fd 3 cxt 0x63006f (hnd 26b48fae) warning: dll: fp = 3, errno = 0, __StdioInited = 1 warning: 000AB0B3:27852A96: write(3, 9, 26b48fae) warning: written: 9 warning: 000AB14B:27852A96: close(3) warning: 000AB18C:27852A96: close: fd 3 type 1 flags 0 hnd 0x26b48fae cxt 0x0 warning: 000AB1D1:27852A96: ch: 0x26b48fae 1 warning: 000AB21A:27852A96: _startup: calling registered atexit() functions warning: 000AB255:27852A96: _exit: 0 warning: 000AB29F:27852A96: _startup: going to terminate with exitcode: 0 warning: _DllMainCRTStartup: reason 0 warning: DLL_PROCESS_DETACH: warning: \gdb\demodll.dll warning: _DllMainCRTStartup: calling DllMain warning: _DllMainCRTStartup: reason 0 warning: DLL_PROCESS_DETACH: warning: \Windows\cegcc.dll warning: _DllMainCRTStartup: calling DllMain Process Exited Program exited normally. (gdb) |