home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
- From: d88-jwa@dront.nada.kth.se (Jon WΣtte)
- Subject: Re: Help for a new programmer (CDEF's & Debuging Resource Code)
- Message-ID: <1993Jan6.145605.28930@kth.se>
- Keywords: CDEF,Debug,Controls,Resource
- Sender: usenet@kth.se (Usenet)
- Nntp-Posting-Host: dront.nada.kth.se
- Organization: Royal Institute of Technology, Stockholm, Sweden
- References: <1993Jan6.045539.29232@engr.LaTech.edu>
- Date: Wed, 6 Jan 1993 14:56:05 GMT
- Lines: 52
-
- > How to debug CDEF in Think C
-
- Well, you could try and create a CDEF that's only 6 bytes,
- load it in, make it contain a JMP instruction and the
- address of a function in your application, and flush the
- cache (after locking the resource)
-
- Something like:
-
- typedef struct cdef {
-
- unsigned short jmp ;
- short * ( addr ) ( ) ;
-
- } cdefStub ;
-
-
- pascal short
- MyRealCDEF ( whatever )
- {
- Do the stuff
- }
-
-
- /* DO this before creating any controls */
-
- cdefStub stub ;
- Handle h = GetReosurce ( 'CDEF' , 4711 ) ;
-
- stub . jmp = 0x4000 ; /* Have to look this up, JMP Immediate */
- stub . addr = MyRealCDEF ;
-
- HLockHi ( h ) ; /* Top of heap to avoid fragmentation */
-
- * ( cdefStub * ) * h = stub ;
-
- if ( TrapAvailable ( _HWTrap ) ) {
-
-
- FlushInstructionCache ( ) ;
- }
-
-
- Now anything going to CDEF 4711 in your program will go to
- the function MyRealCDEF, and you can use the source debugger
- on it, and reference globals even! Cool!
-
-
- --
- -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
-
- Cookie Jar: Vanilla Yoghurt with Crushed Oreos.
-