예제 #1
0
파일: exceptions.c 프로젝트: ChrisG0x20/gdb
int
catch_exceptions_with_msg (struct ui_out *func_uiout,
		  	   catch_exceptions_ftype *func,
		  	   void *func_args,
			   char **gdberrmsg,
		  	   return_mask mask)
{
  struct gdb_exception exception = exception_none;
  volatile int val = 0;
  struct ui_out *saved_uiout;

  /* Save and override the global ``struct ui_out'' builder.  */
  saved_uiout = current_uiout;
  current_uiout = func_uiout;

  TRY
    {
      val = (*func) (current_uiout, func_args);
    }
  CATCH (ex, RETURN_MASK_ALL)
    {
      exception = ex;
    }
  END_CATCH

  /* Restore the global builder.  */
  current_uiout = saved_uiout;

  if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
    {
      /* The caller didn't request that the event be caught.
	 Rethrow.  */
      throw_exception (exception);
    }

  exception_print (gdb_stderr, exception);
  gdb_assert (val >= 0);
  gdb_assert (exception.reason <= 0);
  if (exception.reason < 0)
    {
      /* If caller wants a copy of the low-level error message, make
	 one.  This is used in the case of a silent error whereby the
	 caller may optionally want to issue the message.  */
      if (gdberrmsg != NULL)
	{
	  if (exception.message != NULL)
	    *gdberrmsg = xstrdup (exception.message);
	  else
	    *gdberrmsg = NULL;
	}
      return exception.reason;
    }
  return val;
}
예제 #2
0
int
exceptions_state_mc_catch (struct gdb_exception *exception,
			   int mask)
{
  *exception = current_catcher->exception;
  catcher_pop ();

  if (exception->reason < 0)
    {
      if (mask & RETURN_MASK (exception->reason))
	{
	  /* Exit normally and let the caller handle the
	     exception.  */
	  return 1;
	}

      /* The caller didn't request that the event be caught, relay the
	 event to the next exception_catch/CATCH.  */
      throw_exception (*exception);
    }

  /* No exception was thrown.  */
  return 0;
}
예제 #3
0
파일: exceptions.c 프로젝트: ChrisG0x20/gdb
int
catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
	      return_mask mask)
{
  struct gdb_exception exception = exception_none;
  volatile int val = 0;
  struct ui_out *saved_uiout;

  /* Save the global ``struct ui_out'' builder.  */
  saved_uiout = current_uiout;

  TRY
    {
      val = func (func_args);
    }
  CATCH (ex, RETURN_MASK_ALL)
    {
      exception = ex;
    }
  END_CATCH

  /* Restore the global builder.  */
  current_uiout = saved_uiout;

  if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
    {
      /* The caller didn't request that the event be caught.
	 Rethrow.  */
      throw_exception (exception);
    }

  exception_fprintf (gdb_stderr, exception, "%s", errstring);
  if (exception.reason != 0)
    return 0;
  return val;
}
예제 #4
0
int
exceptions_state_mc_catch (struct gdb_exception *exception,
			   int mask)
{
  *exception = std::move (catchers.front ().exception);
  catchers.pop_front ();

  if (exception->reason < 0)
    {
      if (mask & RETURN_MASK (exception->reason))
	{
	  /* Exit normally and let the caller handle the
	     exception.  */
	  return 1;
	}

      /* The caller didn't request that the event be caught, relay the
	 event to the next exception_catch/CATCH_SJLJ.  */
      throw_exception_sjlj (*exception);
    }

  /* No exception was thrown.  */
  return 0;
}
예제 #5
0
파일: dor.c 프로젝트: mossblaser/spinn_time
void
setup_routing_tables(uint my_x, uint my_y, uint cores_per_chip)
{
	uint entry;
	
	uint xyz[3] = {
		XY_TO_MIN_X(my_x,my_y),
		XY_TO_MIN_Y(my_x,my_y),
		XY_TO_MIN_Z(my_x,my_y)
	};
	
	// Add entries to multicast out nearest-neighbour messages from this chip
	ADD_RTR_ENTRY( NEAREST_NEIGHBOUR_KEY(XY_TO_COLOUR(my_x,my_y), 0)
	             , NEAREST_NEIGHBOUR_KEY(0xFF, 0)
	             , EAST|NORTH|NORTH_EAST|WEST|SOUTH_WEST|SOUTH
	             );
	// Add entry to catch all incoming nearest neighbour messages (i.e. those with
	// a different colour
	for (int p = 1; p <= cores_per_chip; p++)
		ADD_RTR_ENTRY( NEAREST_NEIGHBOUR_KEY(0, p-1)
		             , NEAREST_NEIGHBOUR_KEY(0, 0xF)
		             , CORE(p)
		             );
	
	// Add entries to accept master<->slave packets destined for this core
	for (int p = 1; p <= cores_per_chip; p++)
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0],xyz[1],xyz[2], p-1,0)
		             , XYZPD_TO_KEY(  0xFF,  0xFF,  0xFF,0x0F,0)
		             , CORE(p)
		             );
	
	// Add entries to accept master<->slave packets destined for this core
	for (int p = 1; p <= cores_per_chip; p++)
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0],xyz[1],xyz[2], p-1,0)
		             , XYZPD_TO_KEY(  0xFF,  0xFF,  0xFF,0x0F,0)
		             , CORE(p)
		             );
	
	// Add entry to pick up return packets for the master
	if (my_x == 0 && my_y == 0)
		ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,0))
		             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0))
		             , CORE(1)
		             );
	
	// Add routes which allow dimension-order routing with any dimension order
	for (int dim_order = 0; dim_order < NUM_DIM_ORDERS; dim_order++) {
		if (my_x == 0 && my_y == 0) {
			// Start packets off on the right dimension from the master
			// If the first/second dimensions are zero, route in the third dimension
			ADD_RTR_ENTRY( XYZPD_TO_KEY(   0,   0,   0,   0, dim_order)
			             , XYZPD_TO_KEY(DX1F,DY1F,DZ1F,0x00, 0x07)
			             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][2]]
			             );
			// If the first dimension is zero, route in the second dimension
			ADD_RTR_ENTRY( XYZPD_TO_KEY(   0,   0,   0,   0, dim_order)
			             , XYZPD_TO_KEY(DX0F,DY0F,DZ0F,0x00, 0x07)
			             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][1]]
			             );
			// If no dimension is zero, route in the first dimension
			ADD_RTR_ENTRY( XYZPD_TO_KEY(   0,   0,   0,   0, dim_order)
			             , XYZPD_TO_KEY(0x00,0x00,0x00,0x00, 0x07)
			             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][0]]
			             );
		} else {
			// Send packets in the opposite dimension order when returning to the
			// master.
			// If the third dimension is not zero, route along it first
			if (xyz[DIM_ORDERS[dim_order][2]])
				ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,dim_order))
				             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0x7))
				             , OPPOSITE(DIM_DIRECTIONS[DIM_ORDERS[dim_order][2]])
				             );
			else if (xyz[DIM_ORDERS[dim_order][1]])
				ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,dim_order))
				             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0x7))
				             , OPPOSITE(DIM_DIRECTIONS[DIM_ORDERS[dim_order][1]])
				             );
			else if (xyz[DIM_ORDERS[dim_order][0]])
				ADD_RTR_ENTRY( RETURN_KEY(XYZPD_TO_KEY(0,0,0,0,dim_order))
				             , RETURN_MASK(XYZPD_TO_KEY(0,0,0,0,0x7))
				             , OPPOSITE(DIM_DIRECTIONS[DIM_ORDERS[dim_order][0]])
				             );
		}
		
		// Dimension order route packets (x, then y, then z)
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0]&DX1F, xyz[1]&DY1F,xyz[2]&DZ1F,   0,dim_order)
		             , XYZPD_TO_KEY(       DX1F,        DY1F,       DZ1F,0x00,0x07)
		             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][2]]
		             );
		ADD_RTR_ENTRY( XYZPD_TO_KEY(xyz[0]&DX0F, xyz[1]&DY0F,xyz[2]&DZ0F,   0,dim_order)
		             , XYZPD_TO_KEY(       DX0F,        DY0F,       DZ0F,0x00,0x07)
		             , DIM_DIRECTIONS[DIM_ORDERS[dim_order][1]]
		             );
	}
}
예제 #6
0
파일: exceptions.c 프로젝트: palves/cexcept
static int
cexcept_state_mc (enum catcher_action action)
{
  switch (current_catcher->state)
    {
    case CATCHER_CREATED:
      switch (action)
	{
	case CATCH_ITER:
	  /* Allow the code to run the catcher.  */
	  current_catcher->state = CATCHER_RUNNING;
	  return 1;
	default:
	  internal_error ("bad state");
	}
    case CATCHER_RUNNING:
      switch (action)
	{
	case CATCH_ITER:
	  /* No error/quit has occured.  Just clean up.  */
	  catcher_pop ();
	  return 0;
	case CATCH_ITER_1:
	  current_catcher->state = CATCHER_RUNNING_1;
	  return 1;
	case CATCH_THROWING:
	  current_catcher->state = CATCHER_ABORTING;
	  /* See also throw_exception.  */
	  return 1;
	default:
	  internal_error ("bad switch");
	}
    case CATCHER_RUNNING_1:
      switch (action)
	{
	case CATCH_ITER:
	  /* The did a "break" from the inner while loop.  */
	  catcher_pop ();
	  return 0;
	case CATCH_ITER_1:
	  current_catcher->state = CATCHER_RUNNING;
	  return 0;
	case CATCH_THROWING:
	  current_catcher->state = CATCHER_ABORTING;
	  /* See also throw_exception.  */
	  return 1;
	default:
	  internal_error ("bad switch");
	}
    case CATCHER_ABORTING:
      switch (action)
	{
	case CATCH_ITER:
	  {
	    struct cexception exception = *current_catcher->exception;

	    if (current_catcher->mask & RETURN_MASK (exception.reason))
	      {
		/* Exit normally if this catcher can handle this
		   exception.  The caller analyses the func return
		   values.  */
		catcher_pop ();
		return 0;
	      }
	    /* The caller didn't request that the event be caught,
	       relay the event to the next containing
	       catch_errors().  */
	    catcher_pop ();
	    cexcept_throw (exception);
	  }
	default:
	  internal_error ("bad state");
	}
    default:
      internal_error ("bad switch");
    }
}