⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capture-cli.c

📁 RTEMS (Real-Time Executive for Multiprocessor Systems) is a free open source real-time operating sys
💻 C
📖 第 1 页 / 共 3 页
字号:
  sc = rtems_task_start (id, rtems_capture_cli_task_load_thread, 0);    if (sc != RTEMS_SUCCESSFUL)   {    printf ("error: cannot start helper thread: %s\n", rtems_status_text (sc));    rtems_task_delete (id);    return;  }  for (;;)  {    int c = getchar ();    if ((c == '\r') || (c == '\n'))    {      int loops = 20;            while (loops && cli_load_thread_active)        rtems_task_wake_after (TOD_MICROSECONDS_TO_TICKS (100000));      rtems_task_delete (id);      printf ("load monitoring stopped.\n");      return;    }  }}/* * rtems_capture_cli_watch_list * *  DESCRIPTION: * * This function lists the controls in the capture engine. * */static voidrtems_capture_cli_watch_list (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_capture_control_t* control = rtems_capture_get_control_list ();  rtems_task_priority      ceiling = rtems_capture_watch_get_ceiling ();  rtems_task_priority      floor = rtems_capture_watch_get_floor ();    printf ("watch priority ceiling is %i\n", ceiling);  printf ("watch priority floor is %i\n", floor);  printf ("global watch is %s\n",          rtems_capture_watch_global_on () ? "enabled" : "disabled");  printf ("total %d\n", rtems_capture_control_count ());  while (control)  {    int f;    int fshowed;    int lf;        printf (" ");    rtems_monitor_dump_id (rtems_capture_control_id (control));    printf (" ");    rtems_monitor_dump_name (rtems_capture_control_name (control));    printf (" %c%c%c%c%c",            rtems_capture_control_flags (control) & RTEMS_CAPTURE_WATCH ? 'w' : '-',            rtems_capture_watch_global_on () ? 'g' : '-',            rtems_capture_control_flags (control) & RTEMS_CAPTURE_TO_ANY ? 'F' : '-',            rtems_capture_control_flags (control) & RTEMS_CAPTURE_FROM_ANY ? 'T' : '-',            rtems_capture_control_flags (control) & RTEMS_CAPTURE_FROM_TO ? 'E' : '-');    for (f = 0, fshowed = 0, lf = 1; f < RTEMS_CAPTURE_TRIGGER_TASKS; f++)    {      if (lf && ((fshowed % 16) == 0))      {        printf ("\n");        lf = 0;      }            /*       * FIXME: name test.       */      if (rtems_capture_control_from_name (control, f))      {        printf ("  %2i:", f);        rtems_monitor_dump_name (rtems_capture_control_from_name (control, f));        printf ("/");        rtems_monitor_dump_id (rtems_capture_control_from_id (control, f));        fshowed++;        lf = 1;      }    }    if (lf)      printf ("\n");    control = rtems_capture_next_control (control);  }}/* * rtems_capture_cli_get_name_id * *  DESCRIPTION: * * This function checks arguments for a name or an id. * */static rtems_booleanrtems_capture_cli_get_name_id (char*          arg,                               rtems_boolean* valid_name,                               rtems_boolean* valid_id,                               rtems_name*    name,                               rtems_id*      id){  unsigned32 objclass;  int             l;  int             i;  if (*valid_name && *valid_id)  {    printf ("error: too many arguments\n");    return 0;  }  /*   * See if the arg is all hex digits.   */    l = strlen (arg);  for (i = 0; i < l; i++)    if (!isxdigit (arg[i]))      break;  *id = strtoul (arg, 0, 16);        objclass = _Objects_Get_class (*id);    if ((i == l))    *valid_id = 1;  else  {    memcpy (name, arg, sizeof (rtems_name));    *valid_name = 1;  }  return 1;}/* * rtems_capture_cli_watch_add * *  DESCRIPTION: * * This function is a monitor command that add a watch to the capture * engine. * */static char const * watch_add_usage = "usage: cwadd [task name] [id]\n";static voidrtems_capture_cli_watch_add (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_status_code sc;  int               arg;  rtems_name        name = 0;  rtems_id          id = 0;  rtems_boolean     valid_name = 0;  rtems_boolean     valid_id = 0;  if (argc <= 1)  {    printf (watch_add_usage);    return;  }  for (arg = 1; arg < argc; arg++)  {    if (argv[arg][0] == '-')    {      printf ("warning: option -%c ignored\n", argv[arg][1]);    }    else    {      if (!rtems_capture_cli_get_name_id (argv[arg], &valid_name, &valid_id, &name, &id))        return;    }  }  if (!valid_name && !valid_id)  {    printf("error: no valid name or task id located\n");    return;  }  sc = rtems_capture_watch_add (name, id);  if (sc != RTEMS_SUCCESSFUL)  {    printf ("error: watch add failed: %s\n", rtems_status_text (sc));    return;  }  printf ("watch added.\n");}/* * rtems_capture_cli_watch_del * *  DESCRIPTION: * * This function is a monitor command that deletes a watch from the capture * engine. * */static char const * watch_del_usage = "usage: cwdel [task name] [id]\n";static voidrtems_capture_cli_watch_del (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_status_code sc;  int               arg;  rtems_name        name = 0;  rtems_id          id = 0;  rtems_boolean     valid_name = 0;  rtems_boolean     valid_id = 0;  if (argc <= 1)  {    printf (watch_del_usage);    return;  }  for (arg = 1; arg < argc; arg++)  {    if (argv[arg][0] == '-')    {      printf ("warning: option -%c ignored\n", argv[arg][1]);    }    else    {      if (!rtems_capture_cli_get_name_id (argv[arg], &valid_name, &valid_id, &name, &id))        return;    }  }  if (!valid_name && !valid_id)  {    printf("error: no valid name or task id located\n");    return;  }  sc = rtems_capture_watch_del (name, id);  if (sc != RTEMS_SUCCESSFUL)  {    printf ("error: watch delete failed: %s\n", rtems_status_text (sc));    return;  }  printf ("watch delete.\n");}/* * rtems_capture_cli_watch_control * *  DESCRIPTION: * * This function is a monitor command that controls a watch. * */static char const * watch_control_usage = "usage: cwctl [task name] [id] on/off\n";static voidrtems_capture_cli_watch_control (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_status_code sc;  int               arg;  rtems_name        name = 0;  rtems_id          id = 0;  rtems_boolean     valid_name = 0;  rtems_boolean     valid_id = 0;  rtems_boolean     enable = 0;  if (argc <= 2)  {    printf (watch_control_usage);    return;  }  for (arg = 1; arg < argc; arg++)  {    if (argv[arg][0] == '-')    {      printf ("warning: option -%c ignored\n", argv[arg][1]);    }    else    {      if (strcmp (argv[arg], "on") == 0)        enable = 1;      else if (strcmp (argv[arg], "off") == 0)        enable = 0;      else if (!rtems_capture_cli_get_name_id (argv[arg], &valid_name, &valid_id, &name, &id))        return;    }  }  if (!valid_name && !valid_id)  {    printf("error: no valid name or task id located\n");    return;  }  sc = rtems_capture_watch_ctrl (name, id, enable);  if (sc != RTEMS_SUCCESSFUL)  {    printf ("error: watch control failed: %s\n", rtems_status_text (sc));    return;  }  printf ("watch %s.\n", enable ? "enabled" : "disabled");}/* * rtems_capture_cli_watch_global * *  DESCRIPTION: * * This function is a monitor command that sets a global watch. * */static char const * watch_global_usage = "usage: cwglob on/off\n";static voidrtems_capture_cli_watch_global (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_status_code sc;  int               arg;  rtems_boolean     enable = 0;  if (argc <= 1)  {    printf (watch_global_usage);    return;  }  for (arg = 1; arg < argc; arg++)  {    if (argv[arg][0] == '-')    {      printf ("warning: option -%c ignored\n", argv[arg][1]);    }    else    {      if (strcmp (argv[arg], "on") == 0)        enable = 1;      else if (strcmp (argv[arg], "off") == 0)        enable = 0;    }  }  sc = rtems_capture_watch_global (enable);  if (sc != RTEMS_SUCCESSFUL)  {    printf ("error: global watch failed: %s\n", rtems_status_text (sc));    return;  }  printf ("global watch %s.\n", enable ? "enabled" : "disabled");}/* * rtems_capture_cli_watch_ceiling * *  DESCRIPTION: * * This function is a monitor command that sets watch ceiling. * */static char const * watch_ceiling_usage = "usage: cwceil priority\n";static voidrtems_capture_cli_watch_ceiling (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_status_code   sc;  int                 arg;  rtems_task_priority priority = 0;  if (argc <= 1)  {    printf (watch_ceiling_usage);    return;  }  for (arg = 1; arg < argc; arg++)  {    if (argv[arg][0] == '-')    {      printf ("warning: option -%c ignored\n", argv[arg][1]);    }    else    {      priority = strtoul (argv[arg], 0, 0);    }  }  sc = rtems_capture_watch_ceiling (priority);  if (sc != RTEMS_SUCCESSFUL)  {    printf ("error: watch ceiling failed: %s\n", rtems_status_text (sc));    return;  }  printf ("watch ceiling is %i.\n", priority);}/* * rtems_capture_cli_watch_floor * *  DESCRIPTION: * * This function is a monitor command that sets watch floor. * */static char const * watch_floor_usage = "usage: cwfloor priority\n";static voidrtems_capture_cli_watch_floor (  int argc,   char **argv,  unsigned32 command_arg,   boolean verbose ){  rtems_status_code   sc;  int                 arg;  rtems_task_priority priority = 0;  if (argc <= 1)  {    printf (watch_floor_usage);    return;  }  for (arg = 1; arg < argc; arg++)  {    if (argv[arg][0] == '-')    {      printf ("warning: option -%c ignored\n", argv[arg][1]);    }    else    {      priority = strtoul (argv[arg], 0, 0);    }  }  sc = rtems_capture_watch_floor (priority);  if (sc != RTEMS_SUCCESSFUL)  {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -