Make "list ambiguous" show symbol names too
[deliverable/binutils-gdb.git] / gdb / cli / cli-cmds.c
index 7d7e16a64a8fe7a214ae088615e7e8a390fb1031..260fd3f63532514db9b44084946a5b4a217971de 100644 (file)
@@ -90,6 +90,8 @@ static void list_command (char *, int);
 
 /* Prototypes for local utility functions */
 
+static void print_sal_location (const symtab_and_line &sal);
+
 static void ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
                                 const char *format, ...)
   ATTRIBUTE_PRINTF (2, 3);
@@ -1094,11 +1096,7 @@ list_command (char *arg, int from_tty)
          if (first_line < 1)
            first_line = 1;
          if (sals.size () > 1)
-           {
-             printf_filtered (_("file: \"%s\", line number: %d\n"),
-                              symtab_to_filename_for_display (sal.symtab),
-                              sal.line);
-           }
+           print_sal_location (sal);
          print_source_lines (sal.symtab,
                              first_line,
                              first_line + get_lines_to_list (),
@@ -1121,7 +1119,8 @@ list_command (char *arg, int from_tty)
 
 static void
 print_disassembly (struct gdbarch *gdbarch, const char *name,
-                  CORE_ADDR low, CORE_ADDR high, int flags)
+                  CORE_ADDR low, CORE_ADDR high,
+                  gdb_disassembly_flags flags)
 {
 #if defined(TUI)
   if (!tui_is_window_visible (DISASSEM_WIN))
@@ -1152,7 +1151,7 @@ print_disassembly (struct gdbarch *gdbarch, const char *name,
    Print a disassembly of the current function according to FLAGS.  */
 
 static void
-disassemble_current_function (int flags)
+disassemble_current_function (gdb_disassembly_flags flags)
 {
   struct frame_info *frame;
   struct gdbarch *gdbarch;
@@ -1207,7 +1206,7 @@ disassemble_command (char *arg, int from_tty)
   CORE_ADDR low, high;
   const char *name;
   CORE_ADDR pc;
-  int flags;
+  gdb_disassembly_flags flags;
   const char *p;
 
   p = arg;
@@ -1239,7 +1238,7 @@ disassemble_command (char *arg, int from_tty)
            }
        }
 
-      p = skip_spaces_const (p);
+      p = skip_spaces (p);
     }
 
   if ((flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE))
@@ -1276,7 +1275,7 @@ disassemble_command (char *arg, int from_tty)
       /* Two arguments.  */
       int incl_flag = 0;
       low = pc;
-      p = skip_spaces_const (p);
+      p = skip_spaces (p);
       if (p[0] == '+')
        {
          ++p;
@@ -1515,6 +1514,23 @@ alias_command (char *args, int from_tty)
     }
 }
 \f
+/* Print the file / line number / symbol name of the location
+   specified by SAL.  */
+
+static void
+print_sal_location (const symtab_and_line &sal)
+{
+  scoped_restore_current_program_space restore_pspace;
+  set_current_program_space (sal.pspace);
+
+  const char *sym_name = NULL;
+  if (sal.symbol != NULL)
+    sym_name = SYMBOL_PRINT_NAME (sal.symbol);
+  printf_filtered (_("file: \"%s\", line number: %d, symbol: \"%s\"\n"),
+                  symtab_to_filename_for_display (sal.symtab),
+                  sal.line, sym_name != NULL ? sym_name : "???");
+}
+
 /* Print a list of files and line numbers which a user may choose from
    in order to list a function which was specified ambiguously (as
    with `list classname::overloadedfuncname', for example).  The SALS
@@ -1532,9 +1548,7 @@ ambiguous_line_spec (gdb::array_view<const symtab_and_line> sals,
   va_end (ap);
 
   for (const auto &sal : sals)
-    printf_filtered (_("file: \"%s\", line number: %d\n"),
-                    symtab_to_filename_for_display (sal.symtab),
-                    sal.line);
+    print_sal_location (sal);
 }
 
 /* Comparison function for filter_sals.  Returns a qsort-style
@@ -1664,10 +1678,6 @@ show_max_user_call_depth (struct ui_file *file, int from_tty,
                    value);
 }
 
-\f
-
-initialize_file_ftype _initialize_cli_cmds;
-
 void
 _initialize_cli_cmds (void)
 {
This page took 0.024496 seconds and 4 git commands to generate.