* linespec.c: #include "stack.h".
[deliverable/binutils-gdb.git] / gdb / linespec.c
index ee91adfa6a5ed3ea8f1e301134a7694ad96f5256..4156694bc4fb23f7871d2afc454252be308c6645 100644 (file)
@@ -43,6 +43,7 @@
 #include "cli/cli-utils.h"
 #include "filenames.h"
 #include "ada-lang.h"
+#include "stack.h"
 
 typedef struct symtab *symtab_p;
 DEF_VEC_P (symtab_p);
@@ -987,27 +988,24 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
                                                  ALL_DOMAIN,
                                                  &matcher_data);
 
-      ALL_OBJFILE_SYMTABS (objfile, symtab)
+      ALL_OBJFILE_PRIMARY_SYMTABS (objfile, symtab)
        {
-         if (symtab->primary)
-           {
-             struct block *block;
+         struct block *block;
 
-             block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
-             LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
+         block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
+         LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
 
-             if (include_inline)
-               {
-                 struct symbol_and_data_callback cad = { callback, data };
-                 int i;
+         if (include_inline)
+           {
+             struct symbol_and_data_callback cad = { callback, data };
+             int i;
 
-                 for (i = FIRST_LOCAL_BLOCK;
-                      i < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (symtab)); i++)
-                   {
-                     block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), i);
-                     LA_ITERATE_OVER_SYMBOLS (block, name, domain,
-                                              iterate_inline_only, &cad);
-                   }
+             for (i = FIRST_LOCAL_BLOCK;
+                  i < BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (symtab)); i++)
+               {
+                 block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), i);
+                 LA_ITERATE_OVER_SYMBOLS (block, name, domain,
+                                          iterate_inline_only, &cad);
                }
            }
        }
@@ -2328,6 +2326,8 @@ decode_line_full (char **argptr, int flags,
   do_cleanups (cleanups);
 }
 
+/* See linespec.h.  */
+
 struct symtabs_and_lines
 decode_line_1 (char **argptr, int flags,
               struct symtab *default_symtab,
@@ -2348,6 +2348,51 @@ decode_line_1 (char **argptr, int flags,
   return result;
 }
 
+/* See linespec.h.  */
+
+struct symtabs_and_lines
+decode_line_with_current_source (char *string, int flags)
+{
+  struct symtabs_and_lines sals;
+  struct symtab_and_line cursal;
+
+  if (string == 0)
+    error (_("Empty line specification."));
+
+  /* We use whatever is set as the current source line.  We do not try
+     and get a default source symtab+line or it will recursively call us!  */
+  cursal = get_current_source_symtab_and_line ();
+
+  sals = decode_line_1 (&string, flags,
+                       cursal.symtab, cursal.line);
+
+  if (*string)
+    error (_("Junk at end of line specification: %s"), string);
+  return sals;
+}
+
+/* See linespec.h.  */
+
+struct symtabs_and_lines
+decode_line_with_last_displayed (char *string, int flags)
+{
+  struct symtabs_and_lines sals;
+
+  if (string == 0)
+    error (_("Empty line specification."));
+
+  if (last_displayed_sal_is_valid ())
+    sals = decode_line_1 (&string, flags,
+                         get_last_displayed_symtab (),
+                         get_last_displayed_line ());
+  else
+    sals = decode_line_1 (&string, flags, (struct symtab *) NULL, 0);
+
+  if (*string)
+    error (_("Junk at end of line specification: %s"), string);
+  return sals;
+}
+
 \f
 
 /* First, some functions to initialize stuff at the beggining of the
@@ -2409,6 +2454,7 @@ decode_objc (struct linespec_state *self, linespec_p ls, char **argptr)
   info.state = self;
   info.file_symtabs = NULL;
   VEC_safe_push (symtab_p, info.file_symtabs, NULL);
+  make_cleanup (VEC_cleanup (symtab_p), &info.file_symtabs);
   info.result.symbols = NULL;
   info.result.minimal_symbols = NULL;
   values.nelts = 0;
@@ -2949,6 +2995,7 @@ find_linespec_symbols (struct linespec_state *state,
 
   /* Find a list of classes named KLASS.  */
   classes = lookup_prefix_sym (state, file_symtabs, klass);
+  make_cleanup (VEC_cleanup (symbolp), &classes);
   if (!VEC_empty (symbolp, classes))
     {
       /* Now locate a list of suitable methods named METHOD.  */
This page took 0.027881 seconds and 4 git commands to generate.