Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!ncar!ames!lll-tis!oodis01!uplherc!esunix!jsnow From: jsnow@esunix.UUCP (John Snow) Newsgroups: comp.sys.apple Subject: Re: APW C debugging question Message-ID: <831@esunix.UUCP> Date: 10 May 88 13:37:07 GMT References: <791@trwcsed.trwrb.UUCP> Organization: Evans & Sutherland, Salt Lake City, Utah Lines: 34 From article <791@trwcsed.trwrb.UUCP>, by arenberg@trwrb.UUCP (Jeff Arenberg): > > Regretfully you are quite accurate in your assessment. For C code, the > debugger is practically useless. (No, you didn't miss anything in the > documentation :-( ) A big part of the problem is all of the startup code > that is inserted when you link in 2/start. If you can find the end of > that code, and the beginning of yours, and insert a break at that point, > then you have a better chance of tracing your code. About the only way I > know of doing this is to look for Toolbox traps. I look for the calls to > Init each toolbox and assume I'm close. Of course this approach is > useless if you aren't using toolbox calls, like when converting Unix > source code. > > If anyone knows a better way, *PLEASE* say something. > There is a much easier way to find the beginning of the main() segment of code. When you link the program, use the linker option that creates a listing of the linkmap (I think it is -L, but I can't remember). I usually always print this listing to the printer by redirecting the output of the linker to the printer. This listing shows the relative starting position of every subroutine in the program. Just look for the main() routines relative starting position and add that to the starting address that the program gets loaded into (the debugger automatically sets the program counter to the starting address of the program when you load the code). The link map listing use very useful for determining the starting address of any subroutines called by main(), also. -- ----------------------------------------------------------------------------- John F. Snow UUCP: {ihnp4,decvax}!decwrl!esunix!jsnow Evans & Sutherland Computer Corp. Compuserve: 71550,1152 BIX: johnfsnow Salt Lake City, Utah