Пример #1
0
static void
mem_delete_command (char *args, int from_tty)
{
  int num;
  struct get_number_or_range_state state;

  require_user_regions (from_tty);

  target_dcache_invalidate ();

  if (args == NULL || *args == '\0')
    {
      if (query (_("Delete all memory regions? ")))
	mem_clear ();
      dont_repeat ();
      return;
    }

  init_number_or_range (&state, args);
  while (!state.finished)
    {
      num = get_number_or_range (&state);
      mem_delete (num);
    }

  dont_repeat ();
}
Пример #2
0
static void
mem_disable_command (char *args, int from_tty)
{
  int num;
  struct mem_region *m;
  int ix;

  require_user_regions (from_tty);

  target_dcache_invalidate ();

  if (args == NULL || *args == '\0')
    {
      for (ix = 0; VEC_iterate (mem_region_s, mem_region_list, ix, m); ix++)
	m->enabled_p = 0;
    }
  else
    {
      struct get_number_or_range_state state;

      init_number_or_range (&state, args);
      while (!state.finished)
	{
	  num = get_number_or_range (&state);
	  mem_disable (num);
	}
    }
}
Пример #3
0
int
number_is_in_list (char *list, int number)
{
  struct get_number_or_range_state state;

  if (list == NULL || *list == '\0')
    return 1;

  init_number_or_range (&state, list);
  while (!state.finished)
    {
      int gotnum = get_number_or_range (&state);

      if (gotnum == 0)
	error (_("Args must be numbers or '$' variables."));
      if (gotnum == number)
	return 1;
    }
  return 0;
}
Пример #4
0
static int
get_tid_or_range (struct tid_range_parser *parser, int *inf_num,
		  int *thr_start, int *thr_end)
{
  if (parser->state == TID_RANGE_STATE_INFERIOR)
    {
      const char *p;
      const char *space;

      space = skip_to_space (parser->string);

      p = parser->string;
      while (p < space && *p != '.')
	p++;
      if (p < space)
	{
	  const char *dot = p;

	  /* Parse number to the left of the dot.  */
	  p = parser->string;
	  parser->inf_num
	    = get_positive_number_trailer (&p, '.', parser->string);
	  if (parser->inf_num == 0)
	    return 0;

	  parser->qualified = 1;
	  p = dot + 1;

	  if (isspace (*p))
	    return 0;
	}
      else
	{
	  parser->inf_num = parser->default_inferior;
	  parser->qualified = 0;
	  p = parser->string;
	}

      init_number_or_range (&parser->range_parser, p);
      if (p[0] == '*' && (p[1] == '\0' || isspace (p[1])))
	{
	  /* Setup the number range parser to return numbers in the
	     whole [1,INT_MAX] range.  */
	  number_range_setup_range (&parser->range_parser, 1, INT_MAX,
				    skip_spaces_const (p + 1));
	  parser->state = TID_RANGE_STATE_STAR_RANGE;
	}
      else
	parser->state = TID_RANGE_STATE_THREAD_RANGE;
    }

  *inf_num = parser->inf_num;
  *thr_start = get_number_or_range (&parser->range_parser);
  if (*thr_start < 0)
    error (_("negative value: %s"), parser->string);
  if (*thr_start == 0)
    {
      parser->state = TID_RANGE_STATE_INFERIOR;
      return 0;
    }

  /* If we successfully parsed a thread number or finished parsing a
     thread range, switch back to assuming the next TID is
     inferior-qualified.  */
  if (parser->range_parser.end_ptr == NULL
      || parser->range_parser.string == parser->range_parser.end_ptr)
    {
      parser->state = TID_RANGE_STATE_INFERIOR;
      parser->string = parser->range_parser.string;

      if (thr_end != NULL)
	*thr_end = *thr_start;
    }

  /* If we're midway through a range, and the caller wants the end
     value, return it and skip to the end of the range.  */
  if (thr_end != NULL
      && (parser->state == TID_RANGE_STATE_THREAD_RANGE
	  || parser->state == TID_RANGE_STATE_STAR_RANGE))
    {
      *thr_end = parser->range_parser.end_value;
      tid_range_parser_skip (parser);
    }

  return (*inf_num != 0 && *thr_start != 0);
}