I didn't know what to expect from a cross-debugging session so I figure there must be others like me. Here's a transcript of a debugging session I did with the cross-debugger that's part of the 0.02 binary pre-release of cegcc.
I've annotated it slightly. My input is in green italic, my notes are in red bold, all the rest is output.
dannypc: {47} arm-wince-cegcc-gdb fibo.exe Start the debugging session 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-linux-gnu --target=arm-wince-cegcc"... (gdb) l 35 30 wcstombs(s, ws, len+1); 31 fprintf(f, "param [%s]\r\n", s); 32 33 for (i=1; i<20; i++) { 34 r = fibo(i); 35 fprintf(f, "fibo(%d) = %d\r\n", i, r); 36 } 37 fclose(f); 38 // exit(0); 39 } (gdb) break 35 Add a breakpoint right before the fprintf statement Breakpoint 1 at 0x111dc: file fibo.c, line 35. (gdb) condition 1 (i == 15) Set it to trigger only when we've done some iteration (gdb) r Run the program Starting program: /home/danny/tmp/arm/test/fibo.exe [CeCreateFile:40] begin [CeCreateFile:40] begin Uploading to remote device: \gdb\wince-stub.exe We're using RAPI to download the debugging stub to the PDA. This currently happens every time, for that to change we need a RAPI call that the SynCE project doesn't support yet. [CeWriteFile:115] begin [CeWriteFile:115] begin A lot of these lines show up, they're debugging output of the SynCE RAPI library. .[CeWriteFile:115] begin [CeWriteFile:115] begin .[CeWriteFile:115] begin [CeWriteFile:115] begin . Starting on device: "\gdb\wince-stub.exe \gdb\wince-stub.exe" This appears wrong but trust me ... [CeCreateProcess:39] last_error = 183 Don't know what this means, might be from a previous session [CeCreateProcess:41] result = 1 Looks like this went well. Waiting for connection... The stub is trying to connect to arm-wince-cegcc-gdb on the linux system over a TCP/IP connection. Connected Ok, the connection was created. [CeCreateFile:40] begin [CeCreateFile:40] begin Uploading to remote device: \gdb\fibo.exe Once more, we're using RAPI to load the program to test onto the PDA. [CeWriteFile:115] begin [CeWriteFile:115] begin And these show up in this case as well, sigh. [CeWriteFile:115] begin [CeWriteFile:115] begin . [tcsetpgrp failed in terminal_inferior: Operation not permitted] I don't know what this means. Process Created The program to debug is getting started. Error while mapping shared library sections: winsock.dll: No such file or directory. Don't know what this means Error while mapping shared library sections: ws2.dll: No such file or directory. Don't know what this means Error while mapping shared library sections: coredll.dll: No such file or directory. Don't know what this means warning: __init_c__: initted = 0 warning: __init_c__: calling __init_ce_reent Some of the messages here are from debugging code in newlib warning: 00013A26:C5F7F486: in __init_c__() Ditto warning: 00013C88:C5F7F486: __argc = 1 warning: 00013EE1:C5F7F486: __argv[0] = fibo.exe Ditto, this is our program's command line. warning: 00014146:C5F7F486: initres = 1 warning: S not found in registry warning: S not found in registry Don't know what this means. warning: 00014859:C5F7F486: inherit_parent: unattached warning: 00014AB7:C5F7F486: chdir: path "\gdb" warning: 00014D13:C5F7F486: chdir: success, cwd is "/gdb" Fake notion of current directory. This directory is used between the arm-wince-cegcc-gdb and the debugging stub, its purpose is to store the stub and the program to debug. warning: 00014F71:C5F7F486: ioctl(0, 0x5406 0x1e1afe78) warning: 000151CE:C5F7F486: Invalid file handle: 0 warning: 0001546E:C5F7F486: _initstdfd: fd 0 hnd ffffffff warning: 000156CA:C5F7F486: _initstdfd: fd 1 hnd ffffffff Messages from newlib warning: 00015929:C5F7F486: _initstdfd: fd 2 hnd ffffffff warning: 00015B47:C5F7F486: _startup_: calling main Messages from newlib warning: 00015DA5:C5F7F486: _startup_: calling _main warning: 0001600A:C5F7F486: open(/storage card/devel/fibo.txt, 20601, 666) Messages from newlib, this one shows that our application is opening a file. warning: 00016284:C5F7F486: _assignfd(459d47ae) warning: 000164C1:C5F7F486: _assignfd returns 3 warning: 0001671F:C5F7F486: open returns 3 fd 3 cxt 0x1e1ae6be (hnd 459d47ae) warning: 0001697D:C5F7F486: fstat(3) The file is open, we've got a file descriptor. Breakpoint 1, WinMain (a=0xc59751ba, b=0x0, c=0x1e1afed8, d=5) at fibo.c:35 After a looong time, we're hitting the breakpoint 35 fprintf(f, "fibo(%d) = %d\r\n", i, r); (gdb) n Let it process this fprintf statement too. 33 for (i=1; i<20; i++) { (gdb) p f $1 = (FILE *) 0x1e04e4 (gdb) p *f We can look in the newlib stdio structure $2 = {_p = 0x1e0750 "", _r = 0, _w = 776, _flags = 1160, _file = 3, _bf = { _base = 0x1e0658 "Command [\\gdb\\fibo.exe] param []\r\nfibo(1) = 1\r\nfibo(2) = 1\r\nfibo(3) = 2\r\nfibo(4) = 3\r\nfibo(5) = 5\r\nfibo(6) = 8\r\nfibo(7) = 13\r\nfibo(8) = 21\r\nfibo(9) = 34\r\nfibo(10) = 55\r\nfibo(11) = 89\r\nfibo(12) = 144\r\n"..., _size = 1024}, _lbfsize = 0, The _base field shows part of the text we've already printed. _cookie = 0x1e04e4, _read = 0x16190 <_sread>, _write = 0x1613c <_swrite>, _seek = 0x160f4 <_sseek>, _close = 0x160dc <_sclose>, _ub = {_base = 0x0, _size = 0}, _up = 0x0, _ur = 0, _ubuf = "\000\000", _nbuf = "", _lb = {_base = 0x0, _size = 0}, _blksize = 1024, _offset = 0, _data = 0x0, _lock = 0} (gdb) c Continue debugging Continuing. warning: 00045DCA:C5F7F486: write(3, 315, 459d47ae) warning: 00046160:C5F7F486: close(3) warning: 000462F0:C5F7F486: close: fd 3 type 1 flags 0 hnd 0x459d47ae cxt 0x0 warning: 00046581:C5F7F486: _startup: calling registered atexit() functions The application is terminating warning: 000467AA:C5F7F486: close(0) warning: 00046A07:C5F7F486: close: fd 0 type 3 flags 0 hnd 0xffffffff cxt 0x0 warning: 00046C66:C5F7F486: close(1) warning: 00046EC2:C5F7F486: close: fd 1 type 3 flags 0 hnd 0xffffffff cxt 0x0 warning: 00047122:C5F7F486: close(2) warning: 00047380:C5F7F486: close: fd 2 type 3 flags 0 hnd 0xffffffff cxt 0x0 warning: 000475DE:C5F7F486: _exit: 0 warning: 0004783B:C5F7F486: _startup: going to terminate with exitcode: 0 Process Exited Program exited normally. (gdb) q Stop the debugging session, we're done. dannypc: {48}
Here's a transcript of just about the first debugging session I did with the cross-debugger that's part of the binary pre-release 0.01 of cegcc.
dannypc: {26} arm-wince-cegcc-gcc -g -o fg.exe fibo.c Compile it fibo.c:16: warning: '__stdcall__' attribute directive ignored dannypc: {27} arm-wince-cegcc-gdb fg.exe 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-linux-gnu --target=arm-wince-cegcc". (gdb) l 1 #define _WINSOCKAPI_ 2 #include <windows.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 #define FN "/storage card/devel/fibo.txt" 7 8 int fibo(int n) 9 { 10 if (n < 3) (gdb) 11 return 1; 12 return fibo(n-1) + fibo(n-2); 13 } 14 15 int APIENTRY WinMain(HINSTANCE a,HINSTANCE b,LPWSTR c,int d) 16 { 17 FILE *f; 18 int i, r; 19 20 f = fopen(FN, "w"); (gdb) break WinMain Breakpoint 1 at 0x110dc: file fibo.c, line 20. (gdb) r Starting program: /home/danny/tmp/arm/test/fg.exe win32_create_inferior(/home/danny/tmp/arm/test/fg.exe) Waiting for connection...In this version, there's no RAPI so the developer has to start the stub manually on the PDA. Connected Error creating process \Application Data\gdb\fg.exe, (error 2).Oops, forgot to download fg.exe (gdb) q dannypc: {28} pcp fg.exe ":/application data/gdb/fg.exe" File copy of 686455 bytes took 0 minutes and 6 seconds, that's 114409 bytes/s. dannypc: {29} arm-wince-cegcc-gdb fg.exe 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-linux-gnu --target=arm-wince-cegcc". (gdb) break WinMain Breakpoint 1 at 0x110dc: file fibo.c, line 20. (gdb) r Starting program: /home/danny/tmp/arm/test/fg.exe win32_create_inferior(/home/danny/tmp/arm/test/fg.exe) Waiting for connection... Connected [tcsetpgrp failed in terminal_inferior: Operation not permitted]Don't know what this means or whether it's important. Process Created Error while mapping shared library sections:Don't know what this means or whether it's important. winsock.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: No such file or directory. warning: __init_c__: initted = 0 warning: __init_c__: calling __init_ce_reent warning: 091C5D8F:E3D13566: in __init_c__() warning: 091C5FEC:E3D13566: command line: "\Application Data\gdb\fg.exe " warning: 091C6244:E3D13566: __argc = 3 warning: 091C64A3:E3D13566: __argv[0] = fg.exe warning: 091C6703:E3D13566: __argv[1] = \Application warning: 091C6960:E3D13566: __argv[2] = Data\gdb\fg.exe warning: 091C6BC7:E3D13566: m: 14 0x1e0410Don't know what this means. warning: 091C6E1D:E3D13566: m: 8 0x1e0428 warning: 091C7077:E3D13566: m: 14 0x1e0438 warning: 091C72D5:E3D13566: f: 0x1e0410Don't know what this means. warning: 091C7535:E3D13566: m: 18 0x1e0410 warning: 091C7791:E3D13566: r: 12 0x1e0428Don't know what this means. warning: 091C79F1:E3D13566: m: 18 0x1e0450 warning: 091C7C4D:E3D13566: f: 0x1e0410 warning: 091C7EAE:E3D13566: m: 19 0x1e0410 warning: 091C810B:E3D13566: r: 16 0x1e0468 warning: 091C8369:E3D13566: m: 19 0x1e0480 warning: 091C85C7:E3D13566: f: 0x1e0410 warning: 091C8827:E3D13566: m: 10 0x1e0428 warning: 091C8A84:E3D13566: r: 20 0x1e0468 warning: 091C8CE2:E3D13566: m: 10 0x1e0498 warning: 091C8F41:E3D13566: f: 0x1e0428 warning: 091C919F:E3D13566: initres = 1Don't know what this means. warning: S not found in registryDon't know what this means. warning: S not found in registry warning: 091C98B7:E3D13566: inherit_parent: unattached warning: 091C9B15:E3D13566: chdir: path "\Application Data\gdb" warning: 091C9D73:E3D13566: chdir: success, cwd is "/Application Data/gdb" warning: 091C9FD0:E3D13566: m: 26 0x1e04a8 warning: 091CA22D:E3D13566: r: 24 0x1e04c8 warning: 091CA48D:E3D13566: m: 26 0x1e04e8 warning: 091CA6EA:E3D13566: f: 0x1e04a8 warning: 091CA947:E3D13566: m: 18 0x1e0468 warning: 091CABA5:E3D13566: f: 0x1e0468 warning: 091CAE03:E3D13566: ioctl(0, 0x5406 0x201afe48) warning: 091CB065:E3D13566: Invalid file handle: 0 warning: 091CB301:E3D13566: _initstdfd: fd 0 hnd ffffffff warning: 091CB55F:E3D13566: _initstdfd: fd 1 hnd ffffffff warning: 091CB7BF:E3D13566: _initstdfd: fd 2 hnd ffffffff warning: 091CB9DC:E3D13566: _startup_: calling main warning: 091CBC3A:E3D13566: _startup_: calling _main Breakpoint 1, WinMain (a=0xe5130bfa, b=0x0, c=0x201afea0, d=5) at fibo.c:20 20 f = fopen(FN, "w"); (gdb) n warning: 091CFE1E:E3D13566: m: 380 0x1e0508 warning: 091D007C:E3D13566: open(/storage card/devel/fibo.txt, 20601, 666) warning: 091D0326:E3D13566: _assignfd(43678aca) warning: 091D0538:E3D13566: _assignfd returns 3 warning: 091D0796:E3D13566: open returns 3 fd 3 cxt 0x34 (hnd 43678aca) 22 for (i=1; i<20; i++) { (gdb) p f $1 = (FILE *) 0x1e0514 (gdb) p *f $2 = {_p = 0x0, _r = 0, _w = 0, _flags = 8, _file = 3, _bf = {_base = 0x0, _size = 0}, _lbfsize = 0, _cookie = 0x1e0514, _read = 0x13f38 <_sread>, _write = 0x13ee4 <_swrite>, _seek = 0x13e9c <_sseek>, _close = 0x13e84 <_sclose>, _ub = {_base = 0x0, _size = 0}, _up = 0x0, _ur = 0, _ubuf = "\000\000", _nbuf = "", _lb = {_base = 0x0, _size = 0}, _blksize = 0, _offset = 0, _data = 0x0, _lock = 0} (gdb) l 17 FILE *f; 18 int i, r; 19 20 f = fopen(FN, "w"); 21 22 for (i=1; i<20; i++) { 23 r = fibo(i); 24 fprintf(f, "fibo(%d) = %d\r\n", i, r); 25 } 26 fclose(f); (gdb) break 25 Breakpoint 2 at 0x11138: file fibo.c, line 25. (gdb) c Continuing. warning: 091D98C4:E3D13566: fstat(3) warning: 091D9B2B:E3D13566: m: 1024 0x1e0688 Breakpoint 2, WinMain (a=0xe5130bfa, b=0x0, c=0x201afea0, d=5) at fibo.c:26 26 fclose(f); (gdb) p i $3 = 20 (gdb) p f $4 = (FILE *) 0x1e0514 (gdb) p *f $5 = {_p = 0x1e07a1 "", _r = 0, _w = 743, _flags = 1160, _file = 3, _bf = { _base = 0x1e0688 "fibo(1) = 1\r\nfibo(2) = 1\r\nfibo(3) = 2\r\nfibo(4) = 3\r\nfibo(5) = 5\r\nfibo(6) = 8\r\nfibo(7) = 13\r\nfibo(8) = 21\r\nfibo(9) = 34\r\nfibo(10) = 55\r\nfibo(11) = 89\r\nfibo(12) = 144\r\nfibo(13) = 233\r\nfibo(14) = 377\r\nfi"..., _size = 1024}, _lbfsize = 0, _cookie = 0x1e0514, _read = 0x13f38 <_sread>, _write = 0x13ee4 <_swrite>, _seek = 0x13e9c <_sseek>, _close = 0x13e84 <_sclose>, _ub = {_base = 0x0, _size = 0}, _up = 0x0, _ur = 0, _ubuf = "\000\000", _nbuf = "", _lb = {_base = 0x0, _size = 0}, _blksize = 1024, _offset = 0, _data = 0x0, _lock = 0} (gdb) c Continuing. warning: 091E233D:E3D13566: write(3, 281, 43678aca) warning: 091E25C2:E3D13566: close(3) warning: 091E27F6:E3D13566: close: fd 3 type 1 flags 0 hnd 0x43678aca cxt 0x0 warning: 091E2A7B:E3D13566: ch: 0x43678aca 1 warning: 091E2CB4:E3D13566: f: 0x1e0688 warning: 091E2F12:E3D13566: _startup: calling registered atexit() functions warning: 091E310A:E3D13566: close(0) warning: 091E336A:E3D13566: close: fd 0 type 3 flags 0 hnd 0xffffffff cxt 0x0 warning: 091E35C8:E3D13566: close(1) warning: 091E3828:E3D13566: close: fd 1 type 3 flags 0 hnd 0xffffffff cxt 0x0 warning: 091E3A87:E3D13566: close(2) warning: 091E3CE5:E3D13566: close: fd 2 type 3 flags 0 hnd 0xffffffff cxt 0x0 warning: 091E3F43:E3D13566: _exit: 0 warning: 091E41A1:E3D13566: _startup: going to terminate with exitcode: 0 Process Exited Program exited normally. (gdb) q dannypc: {30}