Debugging with GDB and Simulator
Debugging with GDB and PalmOS? Simulator
Before releasing your application for PalmOs5? you should test it on the PalmOSSimulator. Because of the different nature of Simulator, it takes a few extra steps to do so sucessfully.
Also read DebuggingWithGDBandPose.
For this example, let's say we're building a program called myprog.prc; the COFF version will be called myprog.
Preparing for Debugging
First you need to compile and link your program with the-g switch:
m68k-palmos-gcc -g -c myprog.c -o myprog.o
m68k-palmos-gcc -g myprog.o -o myprog
Note: If you have to segment your application (using Multigen), it is very likely that you won't be able to step through your code. In that case, use calls to ErrNonFatalDisplay to tell you about where in your code things might go wrong.
Configure Simulator by choosing the following options:
- Settings->Communication Ports: here you should see a line reading
"68K debugger TCP/IP localhost:2000". You can add a corresponding line or edit the existing one to make sure the port is bound to 2000 (it's the default for gdb). - Settings->Communication->Redirect NetLib calls to Host TCP/IP (make sure it is selected and has a checkmark)
Now, you need an extra program from the prc-tools sample package, gdbpanel.prc. Install it in Simulator, run it and check the "Enable stub" checkbox. Don't push the buttons here. I am not sure what the DEBUG button does (it does seem to just hang for me).
Next, load your PRC file into Simulator. Don't run it yet.
Now, load the COFF file up with the PRC-Tools version of GDB:
m68k-palmos-gdb myprog
Starting the Debugging Session
Now you need to tell GDB to hook up with Simulator. Type this command on the GDB command line: target palmos
This tells GDB to make a TCP connection to the Simulator on the default port 2000. At this point, GDB has told Simulator that it wants to debug your program, and it will wait patiently for Simulator to set this up.
Now, start your program in Simulator. Your program will break at the entrypoint, which is PilotMain. Now you are ready to set your breakpoints and trace through your code.
Summary
All steps in short:
- Configure Simulator to redirect NetLib calls to TCP/IP and to bind the 68K debugger to port 2000
- Get and install
gdbpanel.prconto Simulator - Load the PRC version of your program into Simulator
- Check the ENABLE STUB checkbox in GDB Panel on Simulator and return to the main menu
- Start up GDB with the COFF version of your program
- Tell GDB, "target palmos"
- Launch your program within Simulator
- On the GDB command line, set up any breakpoints and such
- Set breakpoints, trace etc.
-- SabineDinisBlochberger - 23 Jul 2004