contrib/gdb-7/gdb/linespec.c
static VEC (symbolp) *
lookup_prefix_sym (char **argptr, char *p, VEC (symtab_p) *file_symtabs,
		   char **class_name)
{
  char *p1;
  char *copy;
  int ix;
  struct symtab *elt;
  struct decode_compound_collector collector;
  struct cleanup *outer;
  struct cleanup *cleanup;
  struct block *search_block;

  /* Extract the class name.  */
  p1 = p;
  while (p != *argptr && p[-1] == ' ')
    --p;
  copy = (char *) xmalloc (p - *argptr + 1);
  memcpy (copy, *argptr, p - *argptr);
  copy[p - *argptr] = 0;
  *class_name = copy;
  outer = make_cleanup (xfree, copy);

  /* Discard the class name from the argptr.  */
  p = p1 + (p1[0] == ':' ? 2 : 1);
  p = skip_spaces (p);
  *argptr = p;

  /* At this point p1->"::inA::fun", p->"inA::fun" copy->"AAA",
     argptr->"inA::fun".  */

  collector.symbols = NULL;
  make_cleanup (VEC_cleanup (symbolp), &collector.symbols);

  collector.unique_syms = htab_create_alloc (1, htab_hash_pointer,
					     htab_eq_pointer, NULL,
					     xcalloc, xfree);
  cleanup = make_cleanup_htab_delete (collector.unique_syms);

  for (ix = 0; VEC_iterate (symtab_p, file_symtabs, ix, elt); ++ix)
    {
      if (elt == NULL)
	{
	  iterate_over_all_matching_symtabs (copy, STRUCT_DOMAIN,
					     collect_one_symbol, &collector,
					     NULL);
	  iterate_over_all_matching_symtabs (copy, VAR_DOMAIN,
					     collect_one_symbol, &collector,
					     NULL);
	}
      else
	{
	  struct block *search_block;

	  /* Program spaces that are executing startup should have
	     been filtered out earlier.  */
	  gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
	  set_current_program_space (SYMTAB_PSPACE (elt));
	  search_block = get_search_block (elt);
	  LA_ITERATE_OVER_SYMBOLS (search_block, copy, STRUCT_DOMAIN,
				   collect_one_symbol, &collector);
	  LA_ITERATE_OVER_SYMBOLS (search_block, copy, VAR_DOMAIN,
				   collect_one_symbol, &collector);
	}
    }

  do_cleanups (cleanup);
  discard_cleanups (outer);
  return collector.symbols;
}
/* Return the symbol corresponding to the substring of *ARGPTR ending
   at P, allowing whitespace.  Also, advance *ARGPTR past the symbol
   name in question, the compound object separator ("::" or "."), and
   whitespace.  Note that *ARGPTR is changed whether or not the
   this call finds anything (i.e we return NULL).  As an
   example, say ARGPTR is "AAA::inA::fun" and P is "::inA::fun".  */
Return the symbol corresponding to the substring of *ARGPTR ending
at P, allowing whitespace.  Also, advance *ARGPTR past the symbol
name in question, the compound object separator ("::" or "."), and
whitespace.  Note that *ARGPTR is changed whether or not the
this call finds anything .
Return the symbol corresponding to the substring of * ARGPTR ending at P allowing whitespace . Also advance * ARGPTR past the symbol name in question the compound object separator ( " :: " or " . " ) and whitespace . Note that * ARGPTR is changed whether or not the this call finds anything .
static VEC (symbolp) *
lookup_prefix_sym (char **argptr, char *p, VEC (symtab_p) *file_symtabs,
		   char **class_name)
{
  char *p1;
  char *copy;
  int ix;
  struct symtab *elt;
  struct decode_compound_collector collector;
  struct cleanup *outer;
  struct cleanup *cleanup;
  struct block *search_block;
  p1 = p;
  while (p != *argptr && p[-1] == ' ')
    --p;
  copy = (char *) xmalloc (p - *argptr + 1);
  memcpy (copy, *argptr, p - *argptr);
  copy[p - *argptr] = 0;
  *class_name = copy;
  outer = make_cleanup (xfree, copy);
  p = p1 + (p1[0] == ':' ? 2 : 1);
  p = skip_spaces (p);
  *argptr = p;
  collector.symbols = NULL;
  make_cleanup (VEC_cleanup (symbolp), &collector.symbols);
  collector.unique_syms = htab_create_alloc (1, htab_hash_pointer,
					     htab_eq_pointer, NULL,
					     xcalloc, xfree);
  cleanup = make_cleanup_htab_delete (collector.unique_syms);
  for (ix = 0; VEC_iterate (symtab_p, file_symtabs, ix, elt); ++ix)
    {
      if (elt == NULL)
	{
	  iterate_over_all_matching_symtabs (copy, STRUCT_DOMAIN,
					     collect_one_symbol, &collector,
					     NULL);
	  iterate_over_all_matching_symtabs (copy, VAR_DOMAIN,
					     collect_one_symbol, &collector,
					     NULL);
	}
      else
	{
	  struct block *search_block;
	  gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
	  set_current_program_space (SYMTAB_PSPACE (elt));
	  search_block = get_search_block (elt);
	  LA_ITERATE_OVER_SYMBOLS (search_block, copy, STRUCT_DOMAIN,
				   collect_one_symbol, &collector);
	  LA_ITERATE_OVER_SYMBOLS (search_block, copy, VAR_DOMAIN,
				   collect_one_symbol, &collector);
	}
    }
  do_cleanups (cleanup);
  discard_cleanups (outer);
  return collector.symbols;
}
static VEC ( symbolp ) * lookup_prefix_sym ( char * * argptr , char * p , VEC ( symtab_p ) * file_symtabs , char * * class_name ) { char * p1 ; char * copy ; int ix ; struct symtab * elt ; struct decode_compound_collector collector ; struct cleanup * outer ; struct cleanup * cleanup ; struct block * search_block ; p1 = p ; while ( p != * argptr && p [ -1 ] == ' ' ) -- p ; copy = ( char * ) xmalloc ( p - * argptr + 1 ) ; memcpy ( copy , * argptr , p - * argptr ) ; copy [ p - * argptr ] = 0 ; * class_name = copy ; outer = make_cleanup ( xfree , copy ) ; p = p1 + ( p1 [ 0 ] == ' ' ? 2 : 1 ) ; p = skip_spaces ( p ) ; * argptr = p ; collector . symbols = NULL ; make_cleanup ( VEC_cleanup ( symbolp ) , & collector . symbols ) ; collector . unique_syms = htab_create_alloc ( 1 , htab_hash_pointer , htab_eq_pointer , NULL , xcalloc , xfree ) ; cleanup = make_cleanup_htab_delete ( collector . unique_syms ) ; for ( ix = 0 ; VEC_iterate ( symtab_p , file_symtabs , ix , elt ) ; ++ ix ) { if ( elt == NULL ) { iterate_over_all_matching_symtabs ( copy , STRUCT_DOMAIN , collect_one_symbol , & collector , NULL ) ; iterate_over_all_matching_symtabs ( copy , VAR_DOMAIN , collect_one_symbol , & collector , NULL ) ; } else { struct block * search_block ; gdb_assert ( ! SYMTAB_PSPACE ( elt ) -> executing_startup ) ; set_current_program_space ( SYMTAB_PSPACE ( elt ) ) ; search_block = get_search_block ( elt ) ; LA_ITERATE_OVER_SYMBOLS ( search_block , copy , STRUCT_DOMAIN , collect_one_symbol , & collector ) ; LA_ITERATE_OVER_SYMBOLS ( search_block , copy , VAR_DOMAIN , collect_one_symbol , & collector ) ; } } do_cleanups ( cleanup ) ; discard_cleanups ( outer ) ; return collector . symbols ; }
Return the symbol corresponding to the substring of *ARGPTR ending
at P, allowing whitespace.
Return the symbol corresponding to the substring of * ARGPTR ending at P allowing whitespace .
/* Extract the class name.  */ /* Discard the class name from the argptr.  */ /* At this point p1->"::inA::fun", p->"inA::fun" copy->"AAA",
     argptr->"inA::fun".  */ /* Program spaces that are executing startup should have
	     been filtered out earlier.  */