Tracing Palm OS programs
One of the standard debugging techniques is to add debug output to a program to dump internal state, then look at that to find out when things went wrong. To implement this on the Palm, you have three main methods.
DbgMessage
The oldest way is to use the DbgMessage call. This system API, declared in DebugMgr.h, sends a string to the current debugger for display.
This doesn't work too well for a few reasons. First, the debugger protocol doesn't include an acknowledgement of the message, so it is easy for these message packets to be dropped or corrupted. You can see this in the CodeWarrior debugger if you try to call it too often.
Second, if you leave these calls in your release program, you can fail on different devices. This will disrupt serial communications, and it can hang Visor devices by making them wait on non-existant USB connections.
HostControl.h
The header file HostControl.h was added in the 3.5 and 4.0 SDKs, but the most current version comes as part of the Palm OS Emulator distribution. This header introduces various calls that POSE intercepts and uses to allow your Palm OS program to modify things on the host hardware. You can use these calls to open and write to log files on the host machine.
There is a class of calls here that start with HostTrace. These control program tracing — there is an initialization function and a bunch of formatted output functions, supporting both text and binary output. POSE uses an external program, the Palm Reporter, to take this trace output and display it in a form you can use. This is my favorite trace mechanism, but it only works when running in the Palm OS Emulator.
DlkSetLogEntry
A final option is for tracing on the device for later review. The desktop link system has a log function that is used to add entries to the HotSync log. Normally, this holds things like the time of the last HotSync and the status of the conduits. However, it can also be used to store arbitrary strings. To do this, include the DLServer.h header in your program, and make calls to DlkSetLogEntry. The log entries you create can be viewed by going to the HotSync application and hitting the "Log" button at the bottom of the screen.
Send feedback to combee@techwood.org
Copyright © 2004 Benjamin L. Combee
Palm OS is a registered trademark of PalmSource, Inc.
Metrowerks and CodeWarrior are registered trademarks of Metrowerks Inc.
The views expressed on this website/weblog are those of mine alone and do not necessarily reflect the views of PalmSource or Metrowerks.

qwertYAK / frobnovich
|