RE: debugging

new topic     » goto parent     » topic index » view thread      » older message » newer message

tone skoda wrote:

>is there a way i can tell interperer which routine should it call when 
>[the] program crashes?

First, I hope this complies with the Euphoria source license:

  You can publicly discuss the algorithms used by our source
  code in open forums, and you can mention the names of C
  routines, variables and other identifiers in the code, but
  you must not reveal actual lines of source code.


Anyway, if you had the interpreter source, I'd guess it would not be too 
difficult to add in. The external definition might look like:

   global sub set_crash_routine( int id )
      machine_proc( M_CRASH_ROUTINE, call_back(id) )
   end sub

Define M_CRASH_ROUTINE in execute.h, and add it to the case statement in 
machine.c. It would just have to assign the value to some global variable, 
crash_routine.

Look in rterror.c for CleanUpError, which handles most of the errors. Before 
handling crash_message, add something like this:

   /* did the user set a crash routine? */
   if (crash_routine != NULL && crash_called == 0) {

      /* clear flag - love that name! */
      gameover = 0;

      /* prevent from being called multiple times */
      crash_called++;

      /* call the function pointer */
      (void crash_routine)(void);

      /* restore flag */
      gameover = 1;
   }

Something like that, anyway. No doubt, there's bound to be a nasty 
side-effect here I didn't take into account...

If I figure out the correct cast for the function pointer, I might give it a 
try.

-- David Cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu