Ejemplo n.º 1
0
void
cli_style_option::add_setshow_commands (const char *name,
					enum command_class theclass,
					const char *prefix_doc,
					struct cmd_list_element **set_list,
					void (*do_set) (const char *args,
							int from_tty),
					struct cmd_list_element **show_list,
					void (*do_show) (const char *args,
							 int from_tty))
{
  m_set_prefix = std::string ("set style ") + name + " ";
  m_show_prefix = std::string ("show style ") + name + " ";

  add_prefix_cmd (name, no_class, do_set, prefix_doc, &m_set_list,
		  m_set_prefix.c_str (), 0, set_list);
  add_prefix_cmd (name, no_class, do_show, prefix_doc, &m_show_list,
		  m_show_prefix.c_str (), 0, show_list);

  add_setshow_enum_cmd ("foreground", theclass, cli_colors,
			&m_foreground,
			_("Set the foreground color for this property"),
			_("Show the foreground color for this property"),
			nullptr,
			nullptr,
			do_show_foreground,
			&m_set_list, &m_show_list, (void *) name);
  add_setshow_enum_cmd ("background", theclass, cli_colors,
			&m_background,
			_("Set the background color for this property"),
			_("Show the background color for this property"),
			nullptr,
			nullptr,
			do_show_background,
			&m_set_list, &m_show_list, (void *) name);
  add_setshow_enum_cmd ("intensity", theclass, cli_intensities,
			&m_intensity,
			_("Set the display intensity for this property"),
			_("Show the display intensity for this property"),
			nullptr,
			nullptr,
			do_show_intensity,
			&m_set_list, &m_show_list, (void *) name);
}
Ejemplo n.º 2
0
void
_initialize_gdbarch_utils (void)
{
  add_setshow_enum_cmd ("endian", class_support,
			endian_enum, &set_endian_string, 
			_("Set endianness of target."),
			_("Show endianness of target."),
			NULL, set_endian, show_endian,
			&setlist, &showlist);
}
Ejemplo n.º 3
0
void
_initialize_gdb_osabi (void)
{
  if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID], "<invalid>") != 0)
    internal_error
      (__FILE__, __LINE__,
       _("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));

  /* Register a generic sniffer for ELF flavoured files.  */
  gdbarch_register_osabi_sniffer (bfd_arch_unknown,
				  bfd_target_elf_flavour,
				  generic_elf_osabi_sniffer);

  /* Register the "set osabi" command.  */
  add_setshow_enum_cmd ("osabi", class_support, gdb_osabi_available_names,
			&set_osabi_string,
			_("Set OS ABI of target."),
			_("Show OS ABI of target."),
			NULL, set_osabi, show_osabi,
			&setlist, &showlist);
  user_osabi_state = osabi_auto;
}
Ejemplo n.º 4
0
void
initialize_current_architecture (void)
{
  const char **arches = gdbarch_printable_names ();
  struct gdbarch_info info;

  /* determine a default architecture and byte order.  */
  gdbarch_info_init (&info);
  
  /* Find a default architecture.  */
  if (default_bfd_arch == NULL)
    {
      /* Choose the architecture by taking the first one
	 alphabetically.  */
      const char *chosen = arches[0];
      const char **arch;
      for (arch = arches; *arch != NULL; arch++)
	{
	  if (strcmp (*arch, chosen) < 0)
	    chosen = *arch;
	}
      if (chosen == NULL)
	internal_error (__FILE__, __LINE__,
			_("initialize_current_architecture: No arch"));
      default_bfd_arch = bfd_scan_arch (chosen);
      if (default_bfd_arch == NULL)
	internal_error (__FILE__, __LINE__,
			_("initialize_current_architecture: Arch not found"));
    }

  info.bfd_arch_info = default_bfd_arch;

  /* Take several guesses at a byte order.  */
  if (default_byte_order == BFD_ENDIAN_UNKNOWN
      && default_bfd_vec != NULL)
    {
      /* Extract BFD's default vector's byte order.  */
      switch (default_bfd_vec->byteorder)
	{
	case BFD_ENDIAN_BIG:
	  default_byte_order = BFD_ENDIAN_BIG;
	  break;
	case BFD_ENDIAN_LITTLE:
	  default_byte_order = BFD_ENDIAN_LITTLE;
	  break;
	default:
	  break;
	}
    }
  if (default_byte_order == BFD_ENDIAN_UNKNOWN)
    {
      /* look for ``*el-*'' in the target name.  */
      const char *chp;
      chp = strchr (target_name, '-');
      if (chp != NULL
	  && chp - 2 >= target_name
	  && startswith (chp - 2, "el"))
	default_byte_order = BFD_ENDIAN_LITTLE;
    }
  if (default_byte_order == BFD_ENDIAN_UNKNOWN)
    {
      /* Wire it to big-endian!!! */
      default_byte_order = BFD_ENDIAN_BIG;
    }

  info.byte_order = default_byte_order;
  info.byte_order_for_code = info.byte_order;

  if (! gdbarch_update_p (info))
    internal_error (__FILE__, __LINE__,
		    _("initialize_current_architecture: Selection of "
		      "initial architecture failed"));

  /* Create the ``set architecture'' command appending ``auto'' to the
     list of architectures.  */
  {
    /* Append ``auto''.  */
    int nr;
    for (nr = 0; arches[nr] != NULL; nr++);
    arches = xrealloc (arches, sizeof (char*) * (nr + 2));
    arches[nr + 0] = "auto";
    arches[nr + 1] = NULL;
    add_setshow_enum_cmd ("architecture", class_support,
			  arches, &set_architecture_string, 
			  _("Set architecture of target."),
			  _("Show architecture of target."), NULL,
			  set_architecture, show_architecture,
			  &setlist, &showlist);
    add_alias_cmd ("processor", "architecture", class_support, 1, &setlist);
  }
}
Ejemplo n.º 5
0
static void
add_setshow_generic (enum var_types param_type, enum command_class cmd_class,
		     char *cmd_name, param_smob *self,
		     char *set_doc, char *show_doc, char *help_doc,
		     cmd_const_sfunc_ftype *set_func,
		     show_value_ftype *show_func,
		     struct cmd_list_element **set_list,
		     struct cmd_list_element **show_list,
		     struct cmd_list_element **set_cmd,
		     struct cmd_list_element **show_cmd)
{
  struct cmd_list_element *param = NULL;
  const char *tmp_name = NULL;

  switch (param_type)
    {
    case var_boolean:
      add_setshow_boolean_cmd (cmd_name, cmd_class,
			       &self->value.intval,
			       set_doc, show_doc, help_doc,
			       set_func, show_func,
			       set_list, show_list);

      break;

    case var_auto_boolean:
      add_setshow_auto_boolean_cmd (cmd_name, cmd_class,
				    &self->value.autoboolval,
				    set_doc, show_doc, help_doc,
				    set_func, show_func,
				    set_list, show_list);
      break;

    case var_uinteger:
      add_setshow_uinteger_cmd (cmd_name, cmd_class,
				&self->value.uintval,
				set_doc, show_doc, help_doc,
				set_func, show_func,
				set_list, show_list);
      break;

    case var_zinteger:
      add_setshow_zinteger_cmd (cmd_name, cmd_class,
				&self->value.intval,
				set_doc, show_doc, help_doc,
				set_func, show_func,
				set_list, show_list);
      break;

    case var_zuinteger:
      add_setshow_zuinteger_cmd (cmd_name, cmd_class,
				 &self->value.uintval,
				 set_doc, show_doc, help_doc,
				 set_func, show_func,
				 set_list, show_list);
      break;

    case var_zuinteger_unlimited:
      add_setshow_zuinteger_unlimited_cmd (cmd_name, cmd_class,
					   &self->value.intval,
					   set_doc, show_doc, help_doc,
					   set_func, show_func,
					   set_list, show_list);
      break;

    case var_string:
      add_setshow_string_cmd (cmd_name, cmd_class,
			      &self->value.stringval,
			      set_doc, show_doc, help_doc,
			      set_func, show_func,
			      set_list, show_list);
      break;

    case var_string_noescape:
      add_setshow_string_noescape_cmd (cmd_name, cmd_class,
				       &self->value.stringval,
				       set_doc, show_doc, help_doc,
				       set_func, show_func,
				       set_list, show_list);

      break;

    case var_optional_filename:
      add_setshow_optional_filename_cmd (cmd_name, cmd_class,
					 &self->value.stringval,
					 set_doc, show_doc, help_doc,
					 set_func, show_func,
					 set_list, show_list);
      break;

    case var_filename:
      add_setshow_filename_cmd (cmd_name, cmd_class,
				&self->value.stringval,
				set_doc, show_doc, help_doc,
				set_func, show_func,
				set_list, show_list);
      break;

    case var_enum:
      add_setshow_enum_cmd (cmd_name, cmd_class,
			    self->enumeration,
			    &self->value.cstringval,
			    set_doc, show_doc, help_doc,
			    set_func, show_func,
			    set_list, show_list);
      /* Initialize the value, just in case.  */
      self->value.cstringval = self->enumeration[0];
      break;

    default:
      gdb_assert_not_reached ("bad param_type value");
    }

  /* Lookup created parameter, and register Scheme object against the
     parameter context.  Perform this task against both lists.  */
  tmp_name = cmd_name;
  param = lookup_cmd (&tmp_name, *show_list, "", 0, 1);
  gdb_assert (param != NULL);
  set_cmd_context (param, self);
  *set_cmd = param;

  tmp_name = cmd_name;
  param = lookup_cmd (&tmp_name, *set_list, "", 0, 1);
  gdb_assert (param != NULL);
  set_cmd_context (param, self);
  *show_cmd = param;
}
Ejemplo n.º 6
0
void
add_language (const struct language_defn *lang)
{
  /* For the "set language" command.  */
  static const char **language_names = NULL;
  /* For the "help set language" command.  */
  char *language_set_doc = NULL;

  int i;
  struct ui_file *tmp_stream;

  if (lang->la_magic != LANG_MAGIC)
    {
      fprintf_unfiltered (gdb_stderr,
			  "Magic number of %s language struct wrong\n",
			  lang->la_name);
      internal_error (__FILE__, __LINE__,
		      _("failed internal consistency check"));
    }

  if (!languages)
    {
      languages_allocsize = DEFAULT_ALLOCSIZE;
      languages = (const struct language_defn **) xmalloc
	(languages_allocsize * sizeof (*languages));
    }
  if (languages_size >= languages_allocsize)
    {
      languages_allocsize *= 2;
      languages = (const struct language_defn **) xrealloc ((char *) languages,
				 languages_allocsize * sizeof (*languages));
    }
  languages[languages_size++] = lang;

  /* Build the language names array, to be used as enumeration in the
     set language" enum command.  */
  language_names = xrealloc (language_names,
			     (languages_size + 1) * sizeof (const char *));
  for (i = 0; i < languages_size; ++i)
    language_names[i] = languages[i]->la_name;
  language_names[i] = NULL;

  /* Build the "help set language" docs.  */
  tmp_stream = mem_fileopen ();

  fprintf_unfiltered (tmp_stream,
		      _("Set the current source language.\n"
			"The currently understood settings are:\n\nlocal or "
			"auto    Automatic setting based on source file\n"));

  for (i = 0; i < languages_size; ++i)
    {
      /* Already dealt with these above.  */
      if (languages[i]->la_language == language_unknown
	  || languages[i]->la_language == language_auto)
	continue;

      /* FIXME: i18n: for now assume that the human-readable name
	 is just a capitalization of the internal name.  */
      fprintf_unfiltered (tmp_stream, "%-16s Use the %c%s language\n",
			  languages[i]->la_name,
			  /* Capitalize first letter of language
			     name.  */
			  toupper (languages[i]->la_name[0]),
			  languages[i]->la_name + 1);
    }

  language_set_doc = ui_file_xstrdup (tmp_stream, NULL);
  ui_file_delete (tmp_stream);

  add_setshow_enum_cmd ("language", class_support,
			(const char **) language_names,
			&language,
			language_set_doc,
			_("Show the current source language."),
			NULL, set_language_command,
			show_language_command,
			&setlist, &showlist);

  xfree (language_set_doc);
}