mguo wrote:
my program is having some crash which is caused by
accessing functions in segment 2 while globals are
not available.

I wonder, is there any good way to identify the
functions which can be called while globals are
not available, so that they must be in segment 1.
Any pragma or some other tools available?

Start at PilotMain().  Identify the launch codes that are handled.
Identify which launch codes will not have globals.  For example,
sysAppLaunchCmdNormalLaunch will have globals available when it
is sent, but others will not.  There is documentation about this.

Now, all you have to do is trace through and make a list of
functions when OTHER launch codes are handled.  In most programs,
most functions will only be called in response to a normal launch,
so the portion of the code covered by the non-global cases should
be pretty small.

I'm not sure if I can recall every using it, but I believ that
cscope (cscope.sourceforge.net) can show you a list of all the
functions that a function calls (but it only works on C source
code, not C++).  If that's the case, you could first make a list
of those functions which are called by PilotMain() which might
be called without globals, and then feed that list of functions
(one by one, probably) into cscope.

Alternatively, just go through it by hand.  It seems laborious, but
if you are methodical, it should not take that long.  I would go
about being methodical by keeping a queue of functions that still
need to be examined in a text editor window, and also keeping a
list of functions that have been found to be called without
globals in another text editor window.  All you're doing is
traversing the tree, so you can use the same logic you'd use if
you were writing code to traverse a tree, but do it manually.

A whole different approach is to just try to recreate the crash
while running under the debugger.  Then you know which one function
in particular is expecting globals when they aren't there.  This
is probably quicker, but it only eliminates one, whereas going
through all the code should theoretically allow you to catch all
such bugs.

  - Logan

--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to