contrib/gdb-7/gdb/linespec.c
static struct symtabs_and_lines
decode_dollar (struct linespec_state *self, char *copy)
{
  LONGEST valx;
  int index = 0;
  struct symtabs_and_lines values;
  struct symtab_and_line val;
  char *p;
  struct symbol *sym;
  struct minimal_symbol *msymbol;
  int ix;
  struct symtab *elt;

  p = (copy[1] == '$') ? copy + 2 : copy + 1;
  while (*p >= '0' && *p <= '9')
    p++;
  if (!*p)		/* Reached end of token without hitting non-digit.  */
    {
      /* We have a value history reference.  */
      struct value *val_history;

      sscanf ((copy[1] == '$') ? copy + 2 : copy + 1, "%d", &index);
      val_history = access_value_history ((copy[1] == '$') ? -index : index);
      if (TYPE_CODE (value_type (val_history)) != TYPE_CODE_INT)
	error (_("History values used in line "
		 "specs must have integer values."));
      valx = value_as_long (val_history);
    }
  else
    {
      /* Not all digits -- may be user variable/function or a
	 convenience variable.  */

      volatile struct gdb_exception exc;

      /* Avoid "may be used uninitialized" warning.  */
      values.sals = NULL;
      values.nelts = 0;

      TRY_CATCH (exc, RETURN_MASK_ERROR)
	{
	  values = decode_variable (self, copy);
	}

      if (exc.reason == 0)
	return values;

      if (exc.error != NOT_FOUND_ERROR)
	throw_exception (exc);

      /* Not a user variable or function -- must be convenience variable.  */
      if (!get_internalvar_integer (lookup_internalvar (copy + 1), &valx))
	error (_("Convenience variables used in line "
		 "specs must have integer values."));
    }

  init_sal (&val);

  values.sals = NULL;
  values.nelts = 0;

  for (ix = 0; VEC_iterate (symtab_p, self->file_symtabs, ix, elt); ++ix)
    {
      if (elt == NULL)
	{
	  elt = self->default_symtab;
	  set_current_program_space (self->program_space);
	}
      else
	set_current_program_space (SYMTAB_PSPACE (elt));

      /* Either history value or convenience value from above, in valx.  */
      val.symtab = elt;
      val.line = valx;
      val.pc = 0;
      val.pspace = elt ? SYMTAB_PSPACE (elt) : current_program_space;

      add_sal_to_sals (self, &values, &val, NULL);
    }

  if (self->canonical)
    {
      self->canonical->pre_expanded = 1;
      if (self->user_filename)
	self->canonical->addr_string = xstrprintf ("%s:%s",
						   self->user_filename, copy);
      else
	self->canonical->addr_string = xstrdup (copy);
    }

  return values;
}
/* Decode a linespec starting with a dollar sign.  */
Decode a linespec starting with a dollar sign.
Decode a linespec starting with a dollar sign .
static struct symtabs_and_lines
decode_dollar (struct linespec_state *self, char *copy)
{
  LONGEST valx;
  int index = 0;
  struct symtabs_and_lines values;
  struct symtab_and_line val;
  char *p;
  struct symbol *sym;
  struct minimal_symbol *msymbol;
  int ix;
  struct symtab *elt;
  p = (copy[1] == '$') ? copy + 2 : copy + 1;
  while (*p >= '0' && *p <= '9')
    p++;
  if (!*p)		
    {
      struct value *val_history;
      sscanf ((copy[1] == '$') ? copy + 2 : copy + 1, "%d", &index);
      val_history = access_value_history ((copy[1] == '$') ? -index : index);
      if (TYPE_CODE (value_type (val_history)) != TYPE_CODE_INT)
	error (_("History values used in line "
		 "specs must have integer values."));
      valx = value_as_long (val_history);
    }
  else
    {
      volatile struct gdb_exception exc;
      values.sals = NULL;
      values.nelts = 0;
      TRY_CATCH (exc, RETURN_MASK_ERROR)
	{
	  values = decode_variable (self, copy);
	}
      if (exc.reason == 0)
	return values;
      if (exc.error != NOT_FOUND_ERROR)
	throw_exception (exc);
      if (!get_internalvar_integer (lookup_internalvar (copy + 1), &valx))
	error (_("Convenience variables used in line "
		 "specs must have integer values."));
    }
  init_sal (&val);
  values.sals = NULL;
  values.nelts = 0;
  for (ix = 0; VEC_iterate (symtab_p, self->file_symtabs, ix, elt); ++ix)
    {
      if (elt == NULL)
	{
	  elt = self->default_symtab;
	  set_current_program_space (self->program_space);
	}
      else
	set_current_program_space (SYMTAB_PSPACE (elt));
      val.symtab = elt;
      val.line = valx;
      val.pc = 0;
      val.pspace = elt ? SYMTAB_PSPACE (elt) : current_program_space;
      add_sal_to_sals (self, &values, &val, NULL);
    }
  if (self->canonical)
    {
      self->canonical->pre_expanded = 1;
      if (self->user_filename)
	self->canonical->addr_string = xstrprintf ("%s:%s",
						   self->user_filename, copy);
      else
	self->canonical->addr_string = xstrdup (copy);
    }
  return values;
}
static struct symtabs_and_lines decode_dollar ( struct linespec_state * self , char * copy ) { LONGEST valx ; int index = 0 ; struct symtabs_and_lines values ; struct symtab_and_line val ; char * p ; struct symbol * sym ; struct minimal_symbol * msymbol ; int ix ; struct symtab * elt ; p = ( copy [ 1 ] == ' ' ) ? copy + 2 : copy + 1 ; while ( * p >= ' ' && * p <= ' ' ) p ++ ; if ( ! * p ) { struct value * val_history ; sscanf ( ( copy [ 1 ] == ' ' ) ? copy + 2 : copy + 1 , " " , & index ) ; val_history = access_value_history ( ( copy [ 1 ] == ' ' ) ? - index : index ) ; if ( TYPE_CODE ( value_type ( val_history ) ) != TYPE_CODE_INT ) error ( _ ( " " " " ) ) ; valx = value_as_long ( val_history ) ; } else { volatile struct gdb_exception exc ; values . sals = NULL ; values . nelts = 0 ; TRY_CATCH ( exc , RETURN_MASK_ERROR ) { values = decode_variable ( self , copy ) ; } if ( exc . reason == 0 ) return values ; if ( exc . error != NOT_FOUND_ERROR ) throw_exception ( exc ) ; if ( ! get_internalvar_integer ( lookup_internalvar ( copy + 1 ) , & valx ) ) error ( _ ( " " " " ) ) ; } init_sal ( & val ) ; values . sals = NULL ; values . nelts = 0 ; for ( ix = 0 ; VEC_iterate ( symtab_p , self -> file_symtabs , ix , elt ) ; ++ ix ) { if ( elt == NULL ) { elt = self -> default_symtab ; set_current_program_space ( self -> program_space ) ; } else set_current_program_space ( SYMTAB_PSPACE ( elt ) ) ; val . symtab = elt ; val . line = valx ; val . pc = 0 ; val . pspace = elt ? SYMTAB_PSPACE ( elt ) : current_program_space ; add_sal_to_sals ( self , & values , & val , NULL ) ; } if ( self -> canonical ) { self -> canonical -> pre_expanded = 1 ; if ( self -> user_filename ) self -> canonical -> addr_string = xstrprintf ( " " , self -> user_filename , copy ) ; else self -> canonical -> addr_string = xstrdup ( copy ) ; } return values ; }
Decode a linespec starting with a dollar sign.
Decode a linespec starting with a dollar sign .
/* Reached end of token without hitting non-digit.  */ /* We have a value history reference.  */ /* Not all digits -- may be user variable/function or a
	 convenience variable.  */ /* Avoid "may be used uninitialized" warning.  */ /* Not a user variable or function -- must be convenience variable.  */ /* Either history value or convenience value from above, in valx.  */