Path: utzoo!utgpu!attcan!uunet!portal!cup.portal.com!jwhitnell From: jwhitnell@cup.portal.com Newsgroups: comp.sys.mac.programmer Subject: Re: LSC debugger. How can you debug code resources/ drivers? Message-ID: <8142@cup.portal.com> Date: 15 Aug 88 01:07:06 GMT References: <1012@mtund.ATT.COM> <718@ttrdf.UUCP> Distribution: na Organization: The Portal System (TM) Lines: 42 XPortal-User-Id: 1.1001.3098 fjo@ttrdf.UUCP (Frank Owen ) writes... | I know that the manual specifically mentions that you cannot |debug code resource or driver projects, but I could swear I |read in some article somewhere that Michael Kahl has been |demonstrating some simple techniques to do this. | Does anybody out there know what these techniques are, or |am I just nuts? I can't comment on whether your nuts (on the other hand, you are a programmer :-), but it is possible to debug code resources and drivers (DAs at least) from LSD. For DAs, look at the files DA main.c and test DA.c that came on your master disks. This is a short description of how to debug DAs by embeding the code in an application and patching the code resource. For code resources, the tecnique is similar in that you make a dummy code resource and patch it with jump to the real code in your application. The code looks something like: typedef struct { short jump; long addr; } Patch; pascal long yourCDEF( args ); void InitCDEF() { Handle cdef; Patch *cdefCode; cdef = GetResource( 'CDEF', OwnedResourceID( 0 ) ); HNoPurge( cdef ); SetHandleSize( cdef, 6 ); cdefCode = (Patch *) *cdef; cdefCode->jump = 0x4ef9; /* Long JMP */ cdefCode->addr = (long) yourCDEF; } Jerry -- Jerry Whitnell jwhitnell@cup.portal.com ...!sun!cup.portal.com