]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/source.c
the "ambiguous linespec" series
[thirdparty/binutils-gdb.git] / gdb / source.c
index e456ac07cc752570e87710395f1c107fdf8f536d..3bff89bd8475072a180441643d22911865bc287a 100644 (file)
@@ -245,7 +245,7 @@ select_source_symtab (struct symtab *s)
      if one exists.  */
   if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0))
     {
-      sals = decode_line_spec (main_name (), 1);
+      sals = decode_line_spec (main_name (), DECODE_LINE_FUNFIRSTLINE);
       sal = sals.sals[0];
       xfree (sals.sals);
       current_source_pspace = sal.pspace;
@@ -1415,12 +1415,14 @@ line_info (char *arg, int from_tty)
   struct symtab_and_line sal;
   CORE_ADDR start_pc, end_pc;
   int i;
+  struct cleanup *cleanups;
 
   init_sal (&sal);             /* initialize to zeroes */
 
   if (arg == 0)
     {
       sal.symtab = current_source_symtab;
+      sal.pspace = current_program_space;
       sal.line = last_line_listed;
       sals.nelts = 1;
       sals.sals = (struct symtab_and_line *)
@@ -1429,16 +1431,20 @@ line_info (char *arg, int from_tty)
     }
   else
     {
-      sals = decode_line_spec_1 (arg, 0);
+      sals = decode_line_spec_1 (arg, DECODE_LINE_LIST_MODE);
 
       dont_repeat ();
     }
 
+  cleanups = make_cleanup (xfree, sals.sals);
+
   /* C++  More than one line may have been specified, as when the user
      specifies an overloaded function name.  Print info on them all.  */
   for (i = 0; i < sals.nelts; i++)
     {
       sal = sals.sals[i];
+      if (sal.pspace != current_program_space)
+       continue;
 
       if (sal.symtab == 0)
        {
@@ -1504,7 +1510,7 @@ line_info (char *arg, int from_tty)
        printf_filtered (_("Line number %d is out of range for \"%s\".\n"),
                         sal.line, sal.symtab->filename);
     }
-  xfree (sals.sals);
+  do_cleanups (cleanups);
 }
 \f
 /* Commands to search the source file for a regexp.  */