int monitor_checktf(void)
{
  int nump=tf_nump();
  if (nump < 3)
  {
    cDispmon("disp", MON_ERR, "Usage: $dispmon(\"unit\", tag, "
           "\"printf-style-format\", modulename, reg-or-int, "
	   "reg-or-int);\nin instance %s", tf_mipname());
  } else if (tf_typep(1) != tf_string)
  {
    cDispmon("disp", MON_ERR,"dispmon unit name is not a string\n"
	     "in instance %s",tf_mipname());
  } else if (tf_typep(3) != tf_string)
  {
    cDispmon("disp", MON_ERR, "dispmon format field is not a string\n"
	     "in instance %s", tf_mipname());
  } else
  {
    size_t nargs=monitor_nfmtargs(tf_getcstringp(3));
    if(nargs+3!=nump)
    {
      cDispmon("disp",MON_ERR, 
	       "wrong number of parameters for format string \"%s\"\n"
	       "in instance %s", tf_getcstringp(3), tf_mipname());
    }
  }
  return 0;
}
Beispiel #2
0
void error_call(int data, int reason)
{
  char *ptr_mipname;
  char *ptr;
  int i;

  int ms, us, ns, ps;

  get_time (&ms, &us, &ns, &ps);

  ptr_mipname =  tf_mipname();

  /* Requires at least two arguments */
  if (tf_nump() < ARG2) {
      tf_error("$error requires at least two arguments, error-disable-tag, and format-string");
      tf_dofinish();
      return;
   }

   /*  First argument to $error() must be a string */
   if (tf_typep(ARG1) != tf_string) {
      tf_error("First argument to $error must be a value");
      tf_dofinish();
   }

   /*  Second argument to $error() must be a string */
   if (tf_typep(ARG2) != tf_string) {
      tf_error("Second argument to $error must be a formating string");
      tf_dofinish();
   }

   for (i = 0; i < diserr_num; i++) {
     ptr = strchr(diserr_arr[i], '.');
     if (ptr == NULL) {
       if (strcmp (tf_getcstringp(ARG1), diserr_arr[i]) == 0) {
	   io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n",  ms,us,ns,ps, ptr_mipname, format(ptr_mipname));
	 return;
       }
     }
     else {
       sprintf (format_buffer, "%s.%s\0", tf_getcstringp(ARG1), ptr_mipname);
       if (strcmp (format_buffer, diserr_arr[i]) == 0) {
	 io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n",  ms,us,ns,ps, ptr_mipname, format(ptr_mipname));
	 return;
       }
     }
   }
   io_printf ("%05d.%03d.%03d.%03d: ERROR: %s:%s\n",  ms,us,ns,ps, ptr_mipname, format(ptr_mipname));
   if (!error_disable) tf_dofinish();

   return;
}
Beispiel #3
0
void info_call(int data, int reason)
{
    char *ptr_mipname;
    int i, level;

    int ms, us, ns, ps;
    get_time (&ms, &us, &ns, &ps);
	 
    ptr_mipname =  tf_mipname();

   /* Requires at least two arguments */
  if (tf_nump() < ARG2) {
      tf_error("$info requires at least two arguments, info-level and format-string");
      tf_dofinish();
      return;
   }

   /*  First argument to $info() must be a value */
   if (tf_typep(ARG1) != tf_readonly) {
      tf_error("First argument to $info must be a value");
      tf_dofinish();
   }

   /*  Second argument to $info() must be a string */
   if (tf_typep(ARG2) != tf_string) {
      tf_error("Second argument to $info must be a formating string");
      tf_dofinish();
   }

   level = tf_getp(ARG1);

   if (level == 0) {
     io_printf ("%05d.%03d.%03d.%03d: INFO(%d): %s:%s\n",  ms,us,ns,ps, level, ptr_mipname, format(ptr_mipname));
   }
   else {
     for (i = 0; i < mon_path_num; i++) {
       if ((level <= mon_level[i]) &&
	   (strmatch (mon_inst_path[i], ptr_mipname) == 0)
	   ) {
	 io_printf ("%05d.%03d.%03d.%03d: INFO(%d): %s:%s\n",  ms,us,ns,ps, level, ptr_mipname, format(ptr_mipname));
       }
     }
   }
    return;
}
Beispiel #4
0
void warn_call(int data, int reason)
{
  char *ptr_mipname;
  int i;

  int ms, us, ns, ps;
  get_time (&ms, &us, &ns, &ps);

  ptr_mipname =  tf_mipname();

  /* Requires at least two arguments */
  if (tf_nump() < ARG2) {
      tf_error("$warn requires at least two arguments, warn-disable-tag, and format-string");
      tf_dofinish();
      return;
   }

   /*  First argument to $warn() must be a string */
   if (tf_typep(ARG1) != tf_string) {
      tf_error("First argument to $warn must be a value");
      tf_dofinish();
   }

   /*  Second argument to $warn() must be a string */
   if (tf_typep(ARG2) != tf_string) {
      tf_error("Second argument to $warn must be a formating string");
      tf_dofinish();
   }

   for (i = 0; i < diswarn_num; i++) {
     if (strcmp (tf_getcstringp(ARG1), diswarn_arr[i]) == 0) return;
   }
   io_printf ("%05d.%03d.%03d.%03d: WARN: %s:%s\n",  ms,us,ns,ps, ptr_mipname, format(ptr_mipname));

   return;
}
Beispiel #5
0
int fseq_checktf()
{
    int err = 0;
    if (tf_nump() != 1) {
        tf_error("$fibonacci requires exactly 1 argument.\n");
        err = 1;
    }
    if (tf_typep(1) == tf_nullparam) {
        tf_error("$fibonacci cannot have a NULL argument.\n");
        err = 1;
    }
    if (tf_sizep(1) > 8) {
        tf_error("$fibonacci input no larger than 8-bits.\n");
        err = 1;
    }
    if (err) {
        tf_message(ERR_ERROR, "", "", "");
    }
    return(0);
}
Beispiel #6
0
/*************************************************
   lxt2_recordvars
   - add objects to be recorded
 ************************************************/
int lxt2_recordvars( int data, int reason )
{
	int update = 0;
	int objects = 0;
	int i;
	acc_initialize();

	switch( reason ) {
	case reason_calltf:
		break;
	case reason_checktf:
		goto DONE;	
	case reason_finish:
		if( lxt.inited ) {
		    lxt2_close();
		}
		goto DONE;	
	case reason_rosynch:
		update = (lxt.updateList != NULL);
		while( lxt.updateList ) {
			info_p info;
			info = lxt.updateList;
			lxt2_dump( info, 0 );
			lxt.updateList = info->updateNext;
			info->updateNext = 0;
		}
		if( update ) {
		    lxt2_timemarkerp1(); 
		}
		while( lxt.eventList ) {
			info_p info;
			info = lxt.eventList;
			lxt2_dump( info, 1 );
			lxt.eventList = info->updateNext;
			info->updateNext = 0;
		}
		lxt2_nexttimemarker(); 
		goto DONE;	
	default:
		goto DONE;	
	}

	ginstance = tf_getinstance();
	/*
	 * parse options first
	 */
	for( i = 1; i <= tf_nump(); ++i ) {
	    handle object;
	    if( tf_typep(i) == tf_nullparam ) {
		continue;
	    }
	    if( tf_typep(i) == tf_string ) {
		char* str = acc_fetch_tfarg_str(i);
		lxt2_option( str );
		continue;
	    } 
	}
	/*
	 * on first call, initialize structure
	 */
	if( !lxt.inited ) {
	    lxt2_init();
	}
	for( i = 1; i <= tf_nump(); ++i ) {
	    handle object;
	    if( tf_typep(i) == tf_nullparam ) {
		continue;
	    }
	    if( tf_typep(i) == tf_string ) {
		continue;
	    } 
	    object = acc_handle_tfarg(i);
	    if( !object ) {
		tf_error( "cannot find object" );
		tf_dofinish();
		goto DONE;
	    }
	    lxt2_add( object, lxt.depth );
	    objects++;
	}
	if( objects == 0 ) {
#if DEBUG
	    io_printf( "lxt2_recordvars: defaultpath=%s\n",
			 acc_fetch_fullname(acc_handle_parent(acc_handle_tfinst())), lxt.depth );
#endif
	    lxt2_add( acc_handle_parent(acc_handle_tfinst()), lxt.depth );
	}
	lxt2_dump( lxt.objectList, 1 );
DONE:
	acc_close();
	return 0;
}