2002-10-24 Elena Zannoni <ezannoni@redhat.com>
[deliverable/binutils-gdb.git] / gdb / linespec.c
index b9a772c9ad15509f92f27079fdb4a9bc3ff8b20c..94f3b731c0e18b4ad1e326990c3f052167e6d4df 100644 (file)
 #include "command.h"
 #include "symfile.h"
 #include "objfiles.h"
+#include "source.h"
 #include "demangle.h"
 #include "value.h"
 #include "completer.h"
 #include "cp-abi.h"
-
-/* Prototype for one function in parser-defs.h,
-   instead of including that entire file. */
-
-extern char *find_template_name_end (char *);
+#include "parser-defs.h"
 
 /* We share this one with symtab.c, but it is not exported widely. */
 
@@ -130,6 +127,7 @@ find_methods (struct type *t, char *name, struct symbol **sym_arr)
                         (struct symtab **) NULL)))
     {
       int method_counter;
+      int name_len = strlen (name);
 
       CHECK_TYPEDEF (t);
 
@@ -202,7 +200,9 @@ find_methods (struct type *t, char *name, struct symbol **sym_arr)
                     */
                  }
              }
-         else if (strcmp_iw (class_name, name) == 0)
+         else if (strncmp (class_name, name, name_len) == 0
+                  && (class_name[name_len] == '\0'
+                      || class_name[name_len] == '<'))
            {
              /* For GCC 3.x and stabs, constructors and destructors have names
                 like __base_ctor and __complete_dtor.  Check the physname for now
@@ -367,8 +367,8 @@ decode_line_2 (struct symbol *sym_arr[], int nelts, int funfirstline,
   printf_unfiltered ("[0] cancel\n[1] all\n");
   while (i < nelts)
     {
-      INIT_SAL (&return_values.sals[i]);       /* initialize to zeroes */
-      INIT_SAL (&values.sals[i]);
+      init_sal (&return_values.sals[i]);       /* initialize to zeroes */
+      init_sal (&values.sals[i]);
       if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK)
        {
          values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline);
@@ -536,14 +536,20 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
   char *saved_arg = *argptr;
   extern char *gdb_completer_quote_characters;
 
-  INIT_SAL (&val);             /* initialize to zeroes */
+  init_sal (&val);             /* initialize to zeroes */
 
   /* Defaults have defaults.  */
 
   if (default_symtab == 0)
     {
-      default_symtab = current_source_symtab;
-      default_line = current_source_line;
+      /* Use whatever we have for the default source line.  We don't use
+         get_current_or_default_symtab_and_line as it can recurse and call
+        us back! */
+      struct symtab_and_line cursal = 
+                       get_current_source_symtab_and_line ();
+      
+      default_symtab = cursal.symtab;
+      default_line = cursal.line;
     }
 
   /* See if arg is *PC */
@@ -931,20 +937,12 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
       if ((*p == '"') && is_quote_enclosed)
        --p;
       copy = (char *) alloca (p - *argptr + 1);
-      if ((**argptr == '"') && is_quote_enclosed)
-       {
-         memcpy (copy, *argptr + 1, p - *argptr - 1);
-         /* It may have the ending quote right after the file name */
-         if (copy[p - *argptr - 2] == '"')
-           copy[p - *argptr - 2] = 0;
-         else
-           copy[p - *argptr - 1] = 0;
-       }
+      memcpy (copy, *argptr, p - *argptr);
+      /* It may have the ending quote right after the file name */
+      if (is_quote_enclosed && copy[p - *argptr - 1] == '"')
+       copy[p - *argptr - 1] = 0;
       else
-       {
-         memcpy (copy, *argptr, p - *argptr);
-         copy[p - *argptr] = 0;
-       }
+       copy[p - *argptr] = 0;
 
       /* Find that file's data.  */
       s = lookup_symtab (copy);
@@ -1025,13 +1023,19 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
       /* This is where we need to make sure that we have good defaults.
          We must guarantee that this section of code is never executed
          when we are called with just a function name, since
-         select_source_symtab calls us with such an argument  */
+        set_default_source_symtab_and_line uses
+         select_source_symtab that calls us with such an argument  */
 
       if (s == 0 && default_symtab == 0)
        {
-         select_source_symtab (0);
-         default_symtab = current_source_symtab;
-         default_line = current_source_line;
+          struct symtab_and_line cursal;
+
+         /* Make sure we have at least a default source file. */
+         set_default_source_symtab_and_line ();
+          cursal = get_current_source_symtab_and_line ();
+      
+          default_symtab = cursal.symtab;
+          default_line = cursal.line;
        }
 
       if (**argptr == '+')
This page took 0.024699 seconds and 4 git commands to generate.