Home | History | Annotate | Line # | Download | only in mi
      1   1.1  christos /* MI Command Set - symbol commands.
      2  1.11  christos    Copyright (C) 2003-2024 Free Software Foundation, Inc.
      3   1.1  christos 
      4   1.1  christos    This file is part of GDB.
      5   1.1  christos 
      6   1.1  christos    This program is free software; you can redistribute it and/or modify
      7   1.1  christos    it under the terms of the GNU General Public License as published by
      8   1.1  christos    the Free Software Foundation; either version 3 of the License, or
      9   1.1  christos    (at your option) any later version.
     10   1.1  christos 
     11   1.1  christos    This program is distributed in the hope that it will be useful,
     12   1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   1.1  christos    GNU General Public License for more details.
     15   1.1  christos 
     16   1.1  christos    You should have received a copy of the GNU General Public License
     17   1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     18   1.1  christos 
     19   1.1  christos #include "mi-cmds.h"
     20   1.1  christos #include "symtab.h"
     21   1.1  christos #include "objfiles.h"
     22   1.1  christos #include "ui-out.h"
     23   1.9  christos #include "source.h"
     24   1.9  christos #include "mi-getopt.h"
     25   1.1  christos 
     26   1.1  christos /* Print the list of all pc addresses and lines of code for the
     27   1.1  christos    provided (full or base) source file name.  The entries are sorted
     28   1.1  christos    in ascending PC order.  */
     29   1.1  christos 
     30   1.1  christos void
     31  1.11  christos mi_cmd_symbol_list_lines (const char *command, const char *const *argv,
     32  1.11  christos 			  int argc)
     33   1.1  christos {
     34   1.1  christos   struct gdbarch *gdbarch;
     35  1.11  christos   const char *filename;
     36   1.1  christos   struct symtab *s;
     37   1.1  christos   int i;
     38   1.1  christos   struct ui_out *uiout = current_uiout;
     39   1.1  christos 
     40   1.1  christos   if (argc != 1)
     41   1.1  christos     error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
     42   1.1  christos 
     43   1.1  christos   filename = argv[0];
     44  1.12  christos   s = lookup_symtab (current_program_space, filename);
     45   1.1  christos 
     46   1.1  christos   if (s == NULL)
     47   1.1  christos     error (_("-symbol-list-lines: Unknown source file name."));
     48   1.1  christos 
     49   1.1  christos   /* Now, dump the associated line table.  The pc addresses are
     50   1.1  christos      already sorted by increasing values in the symbol table, so no
     51   1.1  christos      need to perform any other sorting.  */
     52   1.1  christos 
     53  1.11  christos   struct objfile *objfile = s->compunit ()->objfile ();
     54  1.11  christos   gdbarch = objfile->arch ();
     55   1.1  christos 
     56   1.8  christos   ui_out_emit_list list_emitter (uiout, "lines");
     57  1.10  christos   if (s->linetable () != NULL && s->linetable ()->nitems > 0)
     58  1.10  christos     for (i = 0; i < s->linetable ()->nitems; i++)
     59  1.10  christos       {
     60  1.10  christos 	ui_out_emit_tuple tuple_emitter (uiout, NULL);
     61  1.11  christos 	uiout->field_core_addr ("pc", gdbarch,
     62  1.11  christos 				s->linetable ()->item[i].pc (objfile));
     63  1.10  christos 	uiout->field_signed ("line", s->linetable ()->item[i].line);
     64  1.10  christos       }
     65   1.1  christos }
     66   1.9  christos 
     67   1.9  christos /* Used by the -symbol-info-* and -symbol-info-module-* commands to print
     68   1.9  christos    information about the symbol SYM in a block of index BLOCK (either
     69   1.9  christos    GLOBAL_BLOCK or STATIC_BLOCK).  KIND is the kind of symbol we searched
     70   1.9  christos    for in order to find SYM, which impact which fields are displayed in the
     71   1.9  christos    results.  */
     72   1.9  christos 
     73   1.9  christos static void
     74  1.11  christos output_debug_symbol (ui_out *uiout, domain_search_flags kind,
     75   1.9  christos 		     struct symbol *sym, int block)
     76   1.9  christos {
     77   1.9  christos   ui_out_emit_tuple tuple_emitter (uiout, NULL);
     78   1.9  christos 
     79  1.10  christos   if (sym->line () != 0)
     80  1.10  christos     uiout->field_unsigned ("line", sym->line ());
     81   1.9  christos   uiout->field_string ("name", sym->print_name ());
     82   1.9  christos 
     83  1.11  christos   if ((kind & (SEARCH_FUNCTION_DOMAIN | SEARCH_VAR_DOMAIN)) != 0)
     84   1.9  christos     {
     85   1.9  christos       string_file tmp_stream;
     86  1.10  christos       type_print (sym->type (), "", &tmp_stream, -1);
     87   1.9  christos       uiout->field_string ("type", tmp_stream.string ());
     88   1.9  christos 
     89  1.11  christos       std::string str = symbol_to_info_string (sym, block);
     90   1.9  christos       uiout->field_string ("description", str);
     91   1.9  christos     }
     92   1.9  christos }
     93   1.9  christos 
     94   1.9  christos /* Actually output one nondebug symbol, puts a tuple emitter in place
     95   1.9  christos    and then outputs the fields for this msymbol.  */
     96   1.9  christos 
     97   1.9  christos static void
     98  1.12  christos output_nondebug_symbol (ui_out *uiout, const bound_minimal_symbol &msymbol)
     99   1.9  christos {
    100   1.9  christos   struct gdbarch *gdbarch = msymbol.objfile->arch ();
    101   1.9  christos   ui_out_emit_tuple tuple_emitter (uiout, NULL);
    102   1.9  christos 
    103   1.9  christos   uiout->field_core_addr ("address", gdbarch,
    104  1.10  christos 			  msymbol.value_address ());
    105   1.9  christos   uiout->field_string ("name", msymbol.minsym->print_name ());
    106   1.9  christos }
    107   1.9  christos 
    108   1.9  christos /* This is the guts of the commands '-symbol-info-functions',
    109   1.9  christos    '-symbol-info-variables', and '-symbol-info-types'.  It searches for
    110   1.9  christos    symbols matching KING, NAME_REGEXP, TYPE_REGEXP, and EXCLUDE_MINSYMS,
    111   1.9  christos    and then prints the matching [m]symbols in an MI structured format.  */
    112   1.9  christos 
    113   1.9  christos static void
    114  1.11  christos mi_symbol_info (domain_search_flags kind, const char *name_regexp,
    115   1.9  christos 		const char *type_regexp, bool exclude_minsyms,
    116   1.9  christos 		size_t max_results)
    117   1.9  christos {
    118   1.9  christos   global_symbol_searcher sym_search (kind, name_regexp);
    119   1.9  christos   sym_search.set_symbol_type_regexp (type_regexp);
    120   1.9  christos   sym_search.set_exclude_minsyms (exclude_minsyms);
    121   1.9  christos   sym_search.set_max_search_results (max_results);
    122   1.9  christos   std::vector<symbol_search> symbols = sym_search.search ();
    123   1.9  christos   ui_out *uiout = current_uiout;
    124   1.9  christos   int i = 0;
    125   1.9  christos 
    126   1.9  christos   ui_out_emit_tuple outer_symbols_emitter (uiout, "symbols");
    127   1.9  christos 
    128   1.9  christos   /* Debug symbols are placed first. */
    129   1.9  christos   if (i < symbols.size () && symbols[i].msymbol.minsym == nullptr)
    130   1.9  christos     {
    131   1.9  christos       ui_out_emit_list debug_symbols_list_emitter (uiout, "debug");
    132   1.9  christos 
    133   1.9  christos       /* As long as we have debug symbols...  */
    134   1.9  christos       while (i < symbols.size () && symbols[i].msymbol.minsym == nullptr)
    135   1.9  christos 	{
    136  1.10  christos 	  symtab *symtab = symbols[i].symbol->symtab ();
    137   1.9  christos 	  ui_out_emit_tuple symtab_tuple_emitter (uiout, nullptr);
    138   1.9  christos 
    139   1.9  christos 	  uiout->field_string ("filename",
    140   1.9  christos 			       symtab_to_filename_for_display (symtab));
    141   1.9  christos 	  uiout->field_string ("fullname", symtab_to_fullname (symtab));
    142   1.9  christos 
    143   1.9  christos 	  ui_out_emit_list symbols_list_emitter (uiout, "symbols");
    144   1.9  christos 
    145   1.9  christos 	  /* As long as we have debug symbols from this symtab...  */
    146   1.9  christos 	  for (; (i < symbols.size ()
    147   1.9  christos 		  && symbols[i].msymbol.minsym == nullptr
    148  1.10  christos 		  && symbols[i].symbol->symtab () == symtab);
    149   1.9  christos 	       ++i)
    150   1.9  christos 	    {
    151   1.9  christos 	      symbol_search &s = symbols[i];
    152   1.9  christos 
    153   1.9  christos 	      output_debug_symbol (uiout, kind, s.symbol, s.block);
    154   1.9  christos 	    }
    155   1.9  christos 	}
    156   1.9  christos     }
    157   1.9  christos 
    158   1.9  christos   /* Non-debug symbols are placed after.  */
    159   1.9  christos   if (i < symbols.size ())
    160   1.9  christos     {
    161   1.9  christos       ui_out_emit_list nondebug_symbols_list_emitter (uiout, "nondebug");
    162   1.9  christos 
    163   1.9  christos       /* As long as we have nondebug symbols...  */
    164   1.9  christos       for (; i < symbols.size (); i++)
    165   1.9  christos 	{
    166   1.9  christos 	  gdb_assert (symbols[i].msymbol.minsym != nullptr);
    167   1.9  christos 	  output_nondebug_symbol (uiout, symbols[i].msymbol);
    168   1.9  christos 	}
    169   1.9  christos     }
    170   1.9  christos }
    171   1.9  christos 
    172   1.9  christos /* Helper to parse the option text from an -max-results argument and return
    173   1.9  christos    the parsed value.  If the text can't be parsed then an error is thrown.  */
    174   1.9  christos 
    175   1.9  christos static size_t
    176  1.11  christos parse_max_results_option (const char *arg)
    177   1.9  christos {
    178  1.11  christos   char *ptr;
    179   1.9  christos   long long val = strtoll (arg, &ptr, 10);
    180   1.9  christos   if (arg == ptr || *ptr != '\0' || val > SIZE_MAX || val < 0)
    181   1.9  christos     error (_("invalid value for --max-results argument"));
    182   1.9  christos   size_t max_results = (size_t) val;
    183   1.9  christos 
    184   1.9  christos   return max_results;
    185   1.9  christos }
    186   1.9  christos 
    187   1.9  christos /* Helper for mi_cmd_symbol_info_{functions,variables} - depending on KIND.
    188   1.9  christos    Processes command line options from ARGV and ARGC.  */
    189   1.9  christos 
    190   1.9  christos static void
    191  1.11  christos mi_info_functions_or_variables (domain_search_flags kind,
    192  1.11  christos 				const char *const *argv, int argc)
    193   1.9  christos {
    194   1.9  christos   size_t max_results = SIZE_MAX;
    195   1.9  christos   const char *regexp = nullptr;
    196   1.9  christos   const char *t_regexp = nullptr;
    197   1.9  christos   bool exclude_minsyms = true;
    198   1.9  christos 
    199   1.9  christos   enum opt
    200   1.9  christos     {
    201   1.9  christos      INCLUDE_NONDEBUG_OPT, TYPE_REGEXP_OPT, NAME_REGEXP_OPT, MAX_RESULTS_OPT
    202   1.9  christos     };
    203   1.9  christos   static const struct mi_opt opts[] =
    204   1.9  christos   {
    205   1.9  christos     {"-include-nondebug" , INCLUDE_NONDEBUG_OPT, 0},
    206   1.9  christos     {"-type", TYPE_REGEXP_OPT, 1},
    207   1.9  christos     {"-name", NAME_REGEXP_OPT, 1},
    208   1.9  christos     {"-max-results", MAX_RESULTS_OPT, 1},
    209   1.9  christos     { 0, 0, 0 }
    210   1.9  christos   };
    211   1.9  christos 
    212   1.9  christos   int oind = 0;
    213  1.11  christos   const char *oarg = nullptr;
    214   1.9  christos 
    215   1.9  christos   while (1)
    216   1.9  christos     {
    217   1.9  christos       const char *cmd_string
    218  1.11  christos 	= ((kind == SEARCH_FUNCTION_DOMAIN)
    219   1.9  christos 	   ? "-symbol-info-functions" : "-symbol-info-variables");
    220   1.9  christos       int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg);
    221   1.9  christos       if (opt < 0)
    222   1.9  christos 	break;
    223   1.9  christos       switch ((enum opt) opt)
    224   1.9  christos 	{
    225   1.9  christos 	case INCLUDE_NONDEBUG_OPT:
    226   1.9  christos 	  exclude_minsyms = false;
    227   1.9  christos 	  break;
    228   1.9  christos 	case TYPE_REGEXP_OPT:
    229   1.9  christos 	  t_regexp = oarg;
    230   1.9  christos 	  break;
    231   1.9  christos 	case NAME_REGEXP_OPT:
    232   1.9  christos 	  regexp = oarg;
    233   1.9  christos 	  break;
    234   1.9  christos 	case MAX_RESULTS_OPT:
    235   1.9  christos 	  max_results = parse_max_results_option (oarg);
    236   1.9  christos 	  break;
    237   1.9  christos 	}
    238   1.9  christos     }
    239   1.9  christos 
    240   1.9  christos   mi_symbol_info (kind, regexp, t_regexp, exclude_minsyms, max_results);
    241   1.9  christos }
    242   1.9  christos 
    243   1.9  christos /* Type for an iterator over a vector of module_symbol_search results.  */
    244   1.9  christos typedef std::vector<module_symbol_search>::const_iterator
    245   1.9  christos 	module_symbol_search_iterator;
    246   1.9  christos 
    247   1.9  christos /* Helper for mi_info_module_functions_or_variables.  Display the results
    248   1.9  christos    from ITER up to END or until we find a symbol that is in a different
    249   1.9  christos    module, or in a different symtab than the first symbol we print.  Update
    250   1.9  christos    and return the new value for ITER.  */
    251   1.9  christos static module_symbol_search_iterator
    252   1.9  christos output_module_symbols_in_single_module_and_file
    253   1.9  christos 	(struct ui_out *uiout, module_symbol_search_iterator iter,
    254  1.11  christos 	 const module_symbol_search_iterator end, domain_search_flags kind)
    255   1.9  christos {
    256   1.9  christos   /* The symbol for the module in which the first result resides.  */
    257   1.9  christos   const symbol *first_module_symbol = iter->first.symbol;
    258   1.9  christos 
    259   1.9  christos   /* The symbol for the first result, and the symtab in which it resides.  */
    260   1.9  christos   const symbol *first_result_symbol = iter->second.symbol;
    261  1.10  christos   symtab *first_symbtab = first_result_symbol->symtab ();
    262   1.9  christos 
    263   1.9  christos   /* Formatted output.  */
    264   1.9  christos   ui_out_emit_tuple current_file (uiout, nullptr);
    265   1.9  christos   uiout->field_string ("filename",
    266   1.9  christos 		       symtab_to_filename_for_display (first_symbtab));
    267   1.9  christos   uiout->field_string ("fullname", symtab_to_fullname (first_symbtab));
    268   1.9  christos   ui_out_emit_list item_list (uiout, "symbols");
    269   1.9  christos 
    270   1.9  christos   /* Repeatedly output result symbols until either we run out of symbols,
    271   1.9  christos      we change module, or we change symtab.  */
    272   1.9  christos   for (; (iter != end
    273   1.9  christos 	  && first_module_symbol == iter->first.symbol
    274  1.10  christos 	  && first_symbtab == iter->second.symbol->symtab ());
    275   1.9  christos        ++iter)
    276   1.9  christos     output_debug_symbol (uiout, kind, iter->second.symbol,
    277   1.9  christos 			 iter->second.block);
    278   1.9  christos 
    279   1.9  christos   return iter;
    280   1.9  christos }
    281   1.9  christos 
    282   1.9  christos /* Helper for mi_info_module_functions_or_variables.  Display the results
    283   1.9  christos    from ITER up to END or until we find a symbol that is in a different
    284   1.9  christos    module than the first symbol we print.  Update and return the new value
    285   1.9  christos    for ITER.  */
    286   1.9  christos static module_symbol_search_iterator
    287   1.9  christos output_module_symbols_in_single_module
    288   1.9  christos 	(struct ui_out *uiout, module_symbol_search_iterator iter,
    289  1.11  christos 	 const module_symbol_search_iterator end, domain_search_flags kind)
    290   1.9  christos {
    291   1.9  christos   gdb_assert (iter->first.symbol != nullptr);
    292   1.9  christos   gdb_assert (iter->second.symbol != nullptr);
    293   1.9  christos 
    294   1.9  christos   /* The symbol for the module in which the first result resides.  */
    295   1.9  christos   const symbol *first_module_symbol = iter->first.symbol;
    296   1.9  christos 
    297   1.9  christos   /* Create output formatting.  */
    298   1.9  christos   ui_out_emit_tuple module_tuple (uiout, nullptr);
    299   1.9  christos   uiout->field_string ("module", first_module_symbol->print_name ());
    300   1.9  christos   ui_out_emit_list files_list (uiout, "files");
    301   1.9  christos 
    302   1.9  christos   /* The results are sorted so that symbols within the same file are next
    303   1.9  christos      to each other in the list.  Calling the output function once will
    304   1.9  christos      print all results within a single file.  We keep calling the output
    305   1.9  christos      function until we change module.  */
    306   1.9  christos   while (iter != end && first_module_symbol == iter->first.symbol)
    307   1.9  christos     iter = output_module_symbols_in_single_module_and_file (uiout, iter,
    308   1.9  christos 							    end, kind);
    309   1.9  christos   return iter;
    310   1.9  christos }
    311   1.9  christos 
    312   1.9  christos /* Core of -symbol-info-module-functions and -symbol-info-module-variables.
    313   1.9  christos    KIND indicates what we are searching for, and ARGV and ARGC are the
    314   1.9  christos    command line options passed to the MI command.  */
    315   1.9  christos 
    316   1.9  christos static void
    317  1.11  christos mi_info_module_functions_or_variables (domain_search_flags kind,
    318  1.11  christos 				       const char *const *argv, int argc)
    319   1.9  christos {
    320   1.9  christos   const char *module_regexp = nullptr;
    321   1.9  christos   const char *regexp = nullptr;
    322   1.9  christos   const char *type_regexp = nullptr;
    323   1.9  christos 
    324   1.9  christos   /* Process the command line options.  */
    325   1.9  christos 
    326   1.9  christos   enum opt
    327   1.9  christos     {
    328   1.9  christos      MODULE_REGEXP_OPT, TYPE_REGEXP_OPT, NAME_REGEXP_OPT
    329   1.9  christos     };
    330   1.9  christos   static const struct mi_opt opts[] =
    331   1.9  christos   {
    332   1.9  christos     {"-module", MODULE_REGEXP_OPT, 1},
    333   1.9  christos     {"-type", TYPE_REGEXP_OPT, 1},
    334   1.9  christos     {"-name", NAME_REGEXP_OPT, 1},
    335   1.9  christos     { 0, 0, 0 }
    336   1.9  christos   };
    337   1.9  christos 
    338   1.9  christos   int oind = 0;
    339  1.11  christos   const char *oarg = nullptr;
    340   1.9  christos 
    341   1.9  christos   while (1)
    342   1.9  christos     {
    343   1.9  christos       const char *cmd_string
    344  1.11  christos 	= ((kind == SEARCH_FUNCTION_DOMAIN)
    345   1.9  christos 	   ? "-symbol-info-module-functions"
    346   1.9  christos 	   : "-symbol-info-module-variables");
    347   1.9  christos       int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg);
    348   1.9  christos       if (opt < 0)
    349   1.9  christos 	break;
    350   1.9  christos       switch ((enum opt) opt)
    351   1.9  christos 	{
    352   1.9  christos 	case MODULE_REGEXP_OPT:
    353   1.9  christos 	  module_regexp = oarg;
    354   1.9  christos 	  break;
    355   1.9  christos 	case TYPE_REGEXP_OPT:
    356   1.9  christos 	  type_regexp = oarg;
    357   1.9  christos 	  break;
    358   1.9  christos 	case NAME_REGEXP_OPT:
    359   1.9  christos 	  regexp = oarg;
    360   1.9  christos 	  break;
    361   1.9  christos 	}
    362   1.9  christos     }
    363   1.9  christos 
    364   1.9  christos   std::vector<module_symbol_search> module_symbols
    365   1.9  christos     = search_module_symbols (module_regexp, regexp, type_regexp, kind);
    366   1.9  christos 
    367   1.9  christos   struct ui_out *uiout = current_uiout;
    368   1.9  christos   ui_out_emit_list all_matching_symbols (uiout, "symbols");
    369   1.9  christos 
    370   1.9  christos   /* The results in the module_symbols list are ordered so symbols in the
    371   1.9  christos      same module are next to each other.  Repeatedly call the output
    372   1.9  christos      function to print sequences of symbols that are in the same module
    373   1.9  christos      until we have no symbols left to print.  */
    374   1.9  christos   module_symbol_search_iterator iter = module_symbols.begin ();
    375   1.9  christos   const module_symbol_search_iterator end = module_symbols.end ();
    376   1.9  christos   while (iter != end)
    377   1.9  christos     iter = output_module_symbols_in_single_module (uiout, iter, end, kind);
    378   1.9  christos }
    379   1.9  christos 
    380   1.9  christos /* Implement -symbol-info-functions command.  */
    381   1.9  christos 
    382   1.9  christos void
    383  1.11  christos mi_cmd_symbol_info_functions (const char *command, const char *const *argv,
    384  1.11  christos 			      int argc)
    385   1.9  christos {
    386  1.11  christos   mi_info_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc);
    387   1.9  christos }
    388   1.9  christos 
    389   1.9  christos /* Implement -symbol-info-module-functions command.  */
    390   1.9  christos 
    391   1.9  christos void
    392  1.11  christos mi_cmd_symbol_info_module_functions (const char *command,
    393  1.11  christos 				     const char *const *argv, int argc)
    394   1.9  christos {
    395  1.11  christos   mi_info_module_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc);
    396   1.9  christos }
    397   1.9  christos 
    398   1.9  christos /* Implement -symbol-info-module-variables command.  */
    399   1.9  christos 
    400   1.9  christos void
    401  1.11  christos mi_cmd_symbol_info_module_variables (const char *command,
    402  1.11  christos 				     const char *const *argv, int argc)
    403   1.9  christos {
    404  1.11  christos   mi_info_module_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc);
    405   1.9  christos }
    406   1.9  christos 
    407   1.9  christos /* Implement -symbol-inf-modules command.  */
    408   1.9  christos 
    409   1.9  christos void
    410  1.11  christos mi_cmd_symbol_info_modules (const char *command, const char *const *argv,
    411  1.11  christos 			    int argc)
    412   1.9  christos {
    413   1.9  christos   size_t max_results = SIZE_MAX;
    414   1.9  christos   const char *regexp = nullptr;
    415   1.9  christos 
    416   1.9  christos   enum opt
    417   1.9  christos     {
    418   1.9  christos      NAME_REGEXP_OPT, MAX_RESULTS_OPT
    419   1.9  christos     };
    420   1.9  christos   static const struct mi_opt opts[] =
    421   1.9  christos   {
    422   1.9  christos     {"-name", NAME_REGEXP_OPT, 1},
    423   1.9  christos     {"-max-results", MAX_RESULTS_OPT, 1},
    424   1.9  christos     { 0, 0, 0 }
    425   1.9  christos   };
    426   1.9  christos 
    427   1.9  christos   int oind = 0;
    428  1.11  christos   const char *oarg = nullptr;
    429   1.9  christos 
    430   1.9  christos   while (1)
    431   1.9  christos     {
    432   1.9  christos       int opt = mi_getopt ("-symbol-info-modules", argc, argv, opts,
    433   1.9  christos 			   &oind, &oarg);
    434   1.9  christos       if (opt < 0)
    435   1.9  christos 	break;
    436   1.9  christos       switch ((enum opt) opt)
    437   1.9  christos 	{
    438   1.9  christos 	case NAME_REGEXP_OPT:
    439   1.9  christos 	  regexp = oarg;
    440   1.9  christos 	  break;
    441   1.9  christos 	case MAX_RESULTS_OPT:
    442   1.9  christos 	  max_results = parse_max_results_option (oarg);
    443   1.9  christos 	  break;
    444   1.9  christos 	}
    445   1.9  christos     }
    446   1.9  christos 
    447  1.11  christos   mi_symbol_info (SEARCH_MODULE_DOMAIN, regexp, nullptr, true, max_results);
    448   1.9  christos }
    449   1.9  christos 
    450   1.9  christos /* Implement -symbol-info-types command.  */
    451   1.9  christos 
    452   1.9  christos void
    453  1.11  christos mi_cmd_symbol_info_types (const char *command, const char *const *argv,
    454  1.11  christos 			  int argc)
    455   1.9  christos {
    456   1.9  christos   size_t max_results = SIZE_MAX;
    457   1.9  christos   const char *regexp = nullptr;
    458   1.9  christos 
    459   1.9  christos   enum opt
    460   1.9  christos     {
    461   1.9  christos      NAME_REGEXP_OPT, MAX_RESULTS_OPT
    462   1.9  christos     };
    463   1.9  christos   static const struct mi_opt opts[] =
    464   1.9  christos   {
    465   1.9  christos     {"-name", NAME_REGEXP_OPT, 1},
    466   1.9  christos     {"-max-results", MAX_RESULTS_OPT, 1},
    467   1.9  christos     { 0, 0, 0 }
    468   1.9  christos   };
    469   1.9  christos 
    470   1.9  christos   int oind = 0;
    471  1.11  christos   const char *oarg = nullptr;
    472   1.9  christos 
    473   1.9  christos   while (true)
    474   1.9  christos     {
    475   1.9  christos       int opt = mi_getopt ("-symbol-info-types", argc, argv, opts,
    476   1.9  christos 			   &oind, &oarg);
    477   1.9  christos       if (opt < 0)
    478   1.9  christos 	break;
    479   1.9  christos       switch ((enum opt) opt)
    480   1.9  christos 	{
    481   1.9  christos 	case NAME_REGEXP_OPT:
    482   1.9  christos 	  regexp = oarg;
    483   1.9  christos 	  break;
    484   1.9  christos 	case MAX_RESULTS_OPT:
    485   1.9  christos 	  max_results = parse_max_results_option (oarg);
    486   1.9  christos 	  break;
    487   1.9  christos 	}
    488   1.9  christos     }
    489   1.9  christos 
    490  1.11  christos   mi_symbol_info (SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, regexp, nullptr,
    491  1.11  christos 		  true, max_results);
    492   1.9  christos }
    493   1.9  christos 
    494   1.9  christos /* Implement -symbol-info-variables command.  */
    495   1.9  christos 
    496   1.9  christos void
    497  1.11  christos mi_cmd_symbol_info_variables (const char *command, const char *const *argv,
    498  1.11  christos 			      int argc)
    499   1.9  christos {
    500  1.11  christos   mi_info_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc);
    501   1.9  christos }
    502