home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / amiga / programm / 17356 < prev    next >
Encoding:
Text File  |  1992-12-14  |  4.0 KB  |  127 lines

  1. Path: sparky!uunet!mcsun!sunic!corax.udac.uu.se!Minsk.docs.uu.se!tomme
  2. From: tomme@Minsk.docs.uu.se (Thomas Holmstr|m)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: InputHandler debugging (long)
  5. Date: 14 Dec 92 20:31:18 GMT
  6. Organization: Uppsala University
  7. Lines: 116
  8. Message-ID: <tomme.724365078@Minsk>
  9. NNTP-Posting-Host: minsk.docs.uu.se
  10.  
  11.  
  12.  
  13.  
  14. I am having some trouble with a piece of code which will be hooked into
  15. the input handler list. The program always crash on the Signal() (1*) in the
  16. handler routine when I push a key. It works fine if I comment out the
  17. Signal() (ie. it doesn't do *anything* until I break it). I can send the
  18. task the signal from Xoper and that works fine.
  19.     Part of the problem is that I cannot find a good way of debugging
  20. interrupts. I don't have any streams to write info to, do I? I've looked
  21. at similar code hooking into the input handler list and I think I do
  22. that the right way. Sorry for the somewhat log posting, I don't think
  23. I could make it any shorter and still keep the relevant parts in.
  24.     I'm using Dice, the registered version, and since it supports
  25. registered arguments I really would like to use that instead of an
  26. assembler routine, but when I declare the function as __regargs the reference
  27. at (2*) uses _InputHandler (or _C_InputHandler) when it should be
  28. @InputHandler. I've tried to redefined the Interrupt struct as
  29. > struct Interrupt {
  30. >    struct  Node is_Node;
  31. >    APTR    is_Data;
  32. >    VOID    (__regargs)(*is_Code)();}
  33. or something like that (I'm not at my computer right now). How to do this?
  34.  
  35.  
  36. Thanks in advance for any comments and/or suggestions.
  37.  
  38.  
  39. The program:
  40. /************************* Global declarations ***************************/
  41. struct HandlerData {
  42.   struct MsgPort *parentport;
  43.   struct Task *parenttask;
  44.   ULONG unblanksig;
  45. } handlerdata;
  46. struct Process *process;
  47. ULONG handlersig, timersig, unblanksig;
  48.  
  49. /*********************** Main function ************************/
  50. void main(void) {
  51.   init();
  52.   while(locked) {
  53.     ULONG wsigs = handlersig | timersig | unblanksig | SIGBREAKF_CTRL_C;
  54.     signals = Wait(wsigs);
  55.     if(signals & SIGBREAKF_CTRL_C) {
  56.     /* Cleanup and exit */
  57.     }
  58.     if(signals & handlersig) {
  59.     /* Handle message */
  60.     }
  61.     if(signals & timersig) blank();
  62.     if(signals & unblanksig) unblank();
  63.   }
  64.   cleanup();
  65. }
  66.  
  67. /*********************** Init code **************************/
  68. [...]
  69.   if(!(process = (struct Process *)FindTask(NULL))) {
  70.     /* Error */
  71.   }
  72. [...]
  73.   if(!(handlerport = CreatePort(HPORT_NAME, HPORT_PRI))) {
  74.     /* Error */
  75.   }
  76.   handlersig = (1 << (handlerport->mp_SigBit));
  77. [...]
  78.   if((usignr = AllocSignal(-1)) == -1) {
  79.     /* Error */
  80.   }
  81.   unblanksig = (1 << usignr);
  82. [...]
  83.   inputreq->io_Command = IND_ADDHANDLER;
  84.   inputreq->io_Data = &interrupt;
  85.   interrupt.is_Node.ln_Pri = HANDLER_PRI;    /* #defined as 10 */
  86.   handlerdata.parentport = handlerport;
  87.   handlerdata.parenttask = &(process->pr_Task);
  88.   handlerdata.unblanksig = unblanksig;
  89.   interrupt.is_Data = &handlerdata;
  90.   interrupt.is_Code = InputHandler; /* InputHandler calls C_InputHandler (2*) */
  91.   if(DoIO(inputreq)) {
  92.     /* Error */
  93.   }
  94.  
  95. /*********** Input handler, called with stack-arguments ***************/
  96. struct InputEvent *
  97.     C_InputHandler(struct InputEvent *ev, struct HandlerData *data) {
  98.   struct InputEvent *currev, *retev, *procev, *tmpev;
  99.   currev = ev; retev = procev = NULL;
  100.   while(currev) {
  101.     tmpev = currev->ie_NextEvent;
  102.     switch(currev->ie_Class) {
  103.       case IECLASS_RAWKEY :
  104.       case IECLASS_RAWMOUSE :
  105.     Signal(data->parenttask, data->unblanksig);  /* Crash here!! (1*) */
  106.     break;
  107.       default :
  108.     }
  109.     currev = tmpev;
  110.   }
  111.   return ev;
  112. }
  113.  
  114. /*********** _InputHandler called with register arguments *************/
  115.         xref    _C_InputHandler
  116.         xdef    _InputHandler
  117. _InputHandler:    movem.l    A0/A1,-(A7)
  118.         jsr     _C_InputHandler
  119.         addq.l    #8,A7
  120.         rts
  121.         end
  122. --
  123. _/_/_/_/_/   _/    _/         Thomas  Holmstr|m
  124.    _/       _/_/_/_/        tomme@Student.docs.uu.se
  125.   _/       _/    _/            +46 18 261628
  126.  _/       _/    _/   DVL, University of Uppsala, Sweden
  127.