contrib/gdb-7/gdb/linespec.c
static int
decode_label (struct linespec_state *self,
	      VEC (symbolp) *function_symbols, char *copy,
	      struct symtabs_and_lines *result)
{
  struct symbol *fn_sym;
  int ix;

  if (function_symbols == NULL)
    {
      struct block *block;
      struct symbol *sym;
      struct symtab_and_line sal;
      struct symtabs_and_lines values;

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

      set_current_program_space (self->program_space);
      block = get_search_block (NULL);

      for (;
	   block && !BLOCK_FUNCTION (block);
	   block = BLOCK_SUPERBLOCK (block))
	;
      if (!block)
	return 0;
      fn_sym = BLOCK_FUNCTION (block);

      sym = lookup_symbol (copy, block, LABEL_DOMAIN, 0);

      if (sym == NULL)
	return 0;

      symbol_to_sal (&sal, self->funfirstline, sym);
      add_sal_to_sals (self, &values, &sal,
		       SYMBOL_NATURAL_NAME (fn_sym));

      if (self->canonical)
	{
	  self->canonical->special_display = 1;
	  self->canonical->addr_string
	    = xstrprintf ("%s:%s", SYMBOL_NATURAL_NAME (fn_sym),
			  copy);
	}

      *result = values;

      return 1;
    }

  result->sals = NULL;
  result->nelts = 0;

  for (ix = 0; VEC_iterate (symbolp, function_symbols, ix, fn_sym); ++ix)
    {
      struct block *block;
      struct symbol *sym;

      set_current_program_space (SYMTAB_PSPACE (SYMBOL_SYMTAB (fn_sym)));
      block = SYMBOL_BLOCK_VALUE (fn_sym);
      sym = lookup_symbol (copy, block, LABEL_DOMAIN, 0);

      if (sym != NULL)
	{
	  struct symtab_and_line sal;
	  char *symname;

	  symbol_to_sal (&sal, self->funfirstline, sym);
	  symname = xstrprintf ("%s:%s",
				SYMBOL_NATURAL_NAME (fn_sym),
				SYMBOL_NATURAL_NAME (sym));
	  add_sal_to_sals (self, result, &sal, symname);
	  xfree (symname);
	}
    }

  if (self->canonical && result->nelts > 0)
    {
      self->canonical->pre_expanded = 1;
      self->canonical->special_display = 1;

      gdb_assert (self->user_function);
      self->canonical->addr_string
	= xstrprintf ("%s:%s", self->user_function, copy);
    }

  return result->nelts > 0;
}
/* A helper for decode_line_1 that tries to find a label.  The label
   is searched for in the current block.
   FUNCTION_SYMBOLS is a list of the enclosing functions; or NULL if none
   specified.
   COPY is the name of the label to find.
   CANONICAL is the same as the "canonical" argument to decode_line_1.
   RESULT is a pointer to a symtabs_and_lines structure which will be
   filled in on success.
   This function returns 1 if a label was found, 0 otherwise.  */
A helper for decode_line_1 that tries to find a label.  The label
is searched for in the current block.
FUNCTION_SYMBOLS is a list of the enclosing functions; or NULL if none
specified.
COPY is the name of the label to find.
CANONICAL is the same as the "canonical" argument to decode_line_1.
RESULT is a pointer to a symtabs_and_lines structure which will be
filled in on success.
This function returns 1 if a label was found, 0 otherwise.
A helper for decode_line_1 that tries to find a label . The label is searched for in the current block . FUNCTION_SYMBOLS is a list of the enclosing functions ; or NULL if none specified . COPY is the name of the label to find . CANONICAL is the same as the " canonical " argument to decode_line_1 . RESULT is a pointer to a symtabs_and_lines structure which will be filled in on success . This function returns 1 if a label was found 0 otherwise .
static int
decode_label (struct linespec_state *self,
	      VEC (symbolp) *function_symbols, char *copy,
	      struct symtabs_and_lines *result)
{
  struct symbol *fn_sym;
  int ix;
  if (function_symbols == NULL)
    {
      struct block *block;
      struct symbol *sym;
      struct symtab_and_line sal;
      struct symtabs_and_lines values;
      values.nelts = 0;
      values.sals = NULL;
      set_current_program_space (self->program_space);
      block = get_search_block (NULL);
      for (;
	   block && !BLOCK_FUNCTION (block);
	   block = BLOCK_SUPERBLOCK (block))
	;
      if (!block)
	return 0;
      fn_sym = BLOCK_FUNCTION (block);
      sym = lookup_symbol (copy, block, LABEL_DOMAIN, 0);
      if (sym == NULL)
	return 0;
      symbol_to_sal (&sal, self->funfirstline, sym);
      add_sal_to_sals (self, &values, &sal,
		       SYMBOL_NATURAL_NAME (fn_sym));
      if (self->canonical)
	{
	  self->canonical->special_display = 1;
	  self->canonical->addr_string
	    = xstrprintf ("%s:%s", SYMBOL_NATURAL_NAME (fn_sym),
			  copy);
	}
      *result = values;
      return 1;
    }
  result->sals = NULL;
  result->nelts = 0;
  for (ix = 0; VEC_iterate (symbolp, function_symbols, ix, fn_sym); ++ix)
    {
      struct block *block;
      struct symbol *sym;
      set_current_program_space (SYMTAB_PSPACE (SYMBOL_SYMTAB (fn_sym)));
      block = SYMBOL_BLOCK_VALUE (fn_sym);
      sym = lookup_symbol (copy, block, LABEL_DOMAIN, 0);
      if (sym != NULL)
	{
	  struct symtab_and_line sal;
	  char *symname;
	  symbol_to_sal (&sal, self->funfirstline, sym);
	  symname = xstrprintf ("%s:%s",
				SYMBOL_NATURAL_NAME (fn_sym),
				SYMBOL_NATURAL_NAME (sym));
	  add_sal_to_sals (self, result, &sal, symname);
	  xfree (symname);
	}
    }
  if (self->canonical && result->nelts > 0)
    {
      self->canonical->pre_expanded = 1;
      self->canonical->special_display = 1;
      gdb_assert (self->user_function);
      self->canonical->addr_string
	= xstrprintf ("%s:%s", self->user_function, copy);
    }
  return result->nelts > 0;
}
static int decode_label ( struct linespec_state * self , VEC ( symbolp ) * function_symbols , char * copy , struct symtabs_and_lines * result ) { struct symbol * fn_sym ; int ix ; if ( function_symbols == NULL ) { struct block * block ; struct symbol * sym ; struct symtab_and_line sal ; struct symtabs_and_lines values ; values . nelts = 0 ; values . sals = NULL ; set_current_program_space ( self -> program_space ) ; block = get_search_block ( NULL ) ; for ( ; block && ! BLOCK_FUNCTION ( block ) ; block = BLOCK_SUPERBLOCK ( block ) ) ; if ( ! block ) return 0 ; fn_sym = BLOCK_FUNCTION ( block ) ; sym = lookup_symbol ( copy , block , LABEL_DOMAIN , 0 ) ; if ( sym == NULL ) return 0 ; symbol_to_sal ( & sal , self -> funfirstline , sym ) ; add_sal_to_sals ( self , & values , & sal , SYMBOL_NATURAL_NAME ( fn_sym ) ) ; if ( self -> canonical ) { self -> canonical -> special_display = 1 ; self -> canonical -> addr_string = xstrprintf ( " " , SYMBOL_NATURAL_NAME ( fn_sym ) , copy ) ; } * result = values ; return 1 ; } result -> sals = NULL ; result -> nelts = 0 ; for ( ix = 0 ; VEC_iterate ( symbolp , function_symbols , ix , fn_sym ) ; ++ ix ) { struct block * block ; struct symbol * sym ; set_current_program_space ( SYMTAB_PSPACE ( SYMBOL_SYMTAB ( fn_sym ) ) ) ; block = SYMBOL_BLOCK_VALUE ( fn_sym ) ; sym = lookup_symbol ( copy , block , LABEL_DOMAIN , 0 ) ; if ( sym != NULL ) { struct symtab_and_line sal ; char * symname ; symbol_to_sal ( & sal , self -> funfirstline , sym ) ; symname = xstrprintf ( " " , SYMBOL_NATURAL_NAME ( fn_sym ) , SYMBOL_NATURAL_NAME ( sym ) ) ; add_sal_to_sals ( self , result , & sal , symname ) ; xfree ( symname ) ; } } if ( self -> canonical && result -> nelts > 0 ) { self -> canonical -> pre_expanded = 1 ; self -> canonical -> special_display = 1 ; gdb_assert ( self -> user_function ) ; self -> canonical -> addr_string = xstrprintf ( " " , self -> user_function , copy ) ; } return result -> nelts > 0 ; }
A helper for decode_line_1 that tries to find a label.
A helper for decode_line_1 that tries to find a label .