[comp.sys.mac.hypercard] Debugging XCMDs

cliff@escher.soft.flab.fujitsu.co.jp (Cliff MILLER) (05/08/90)

I've started writing XCMDs and XFCNs using Lightspeed C v3.0 and have
been having a hard time finding a good way to debug them. The way I do
it now is to just right a plain old LS C program and throw in the code
from the XCMD that I want to test and debug it with the LS debugger. I
wish there was a better way. Is there?

I have a specific problem trying to use strcpy() with data type
Str255. It works fine with the plain LS programs, but when put it into
an XCMD and try to use it in conjunction with t he glue routine that
sends messages to a card in a stack, the string doesn't seem to get
copied. Here's an excerpt:

...

	Str255	msg;

	strcpy(msg, "put junk");
	ToPascalString(msg);	/* shift chars one to right */
 				/* and put length in first element */ 
	SendCardMessage(paramPtr, msg); 

...

("SendCardMessage" may not be the exact name of the glue routine;
it's the first glue listed by Apple)

I tested my ToPascalString() function and it works fine in non-XCMD 
programs as does the strcpy() function. It appears that in the 
XCMD, the strcpy is not copying the string and I can't tell why.

Please e-mail any ideas or help. Thank you.
 
--
		$@IY;NDL@n:j8&5f=j%=%U%H#18&(J
		Cliff Miller $@7*IY<BNI(J 
		(2-6353)
		cliff@escher.soft.flab.fujitsu.co.jp

mjm@eleazar.dartmouth.edu (Michael McClennen) (05/09/90)

cliff@escher.soft.flab.fujitsu.co.jp (Cliff MILLER) writes:

>I've started writing XCMDs and XFCNs using Lightspeed C v3.0 and have
>been having a hard time finding a good way to debug them. The way I do
>it now is to just right a plain old LS C program and throw in the code
>from the XCMD that I want to test and debug it with the LS debugger. I
>wish there was a better way. Is there?

I have found TMON by Icom Simulations, Inc. to be invaluable in debugging
XCMDs.  TMON is a low-level debugger, which means that all you see is
assembly language.  But with a little bit of practice and an M68000 reference
manual, it is not hard to work with.  Remember, however, that Hypercard does
not execute the XCMD resource directly.  It makes a copy of the code and
jumps to the copy.

Michael McClennen
Dartmouth College Academic Computing

(no connection with Icom Simulations except as a satisfied customer)