Fix "list ambiguous_variable"
[deliverable/binutils-gdb.git] / gdb / linespec.c
index 480180869fa4fe126f150ae51b868302415844d7..35ef15983653017455ec7c24d0fa0c84cf354d10 100644 (file)
@@ -45,6 +45,7 @@
 #include "stack.h"
 #include "location.h"
 #include "common/function-view.h"
+#include "common/def-vector.h"
 
 /* An enumeration of the various things a user might attempt to
    complete for a linespec location.  */
@@ -473,7 +474,7 @@ linespec_lexer_lex_keyword (const char *p)
              if (i != IF_KEYWORD_INDEX)
                {
                  p += len;
-                 p = skip_spaces_const (p);
+                 p = skip_spaces (p);
                  for (j = 0; linespec_keywords[j] != NULL; ++j)
                    {
                      int nextlen = strlen (linespec_keywords[j]);
@@ -708,7 +709,7 @@ linespec_lexer_lex_string (linespec_parser *parser)
        {
          if (isspace (*PARSER_STREAM (parser)))
            {
-             p = skip_spaces_const (PARSER_STREAM (parser));
+             p = skip_spaces (PARSER_STREAM (parser));
              /* When we get here we know we've found something followed by
                 a space (we skip over parens and templates below).
                 So if we find a keyword now, we know it is a keyword and not,
@@ -855,7 +856,7 @@ linespec_lexer_lex_one (linespec_parser *parser)
   if (parser->lexer.current.type == LSTOKEN_CONSUMED)
     {
       /* Skip any whitespace.  */
-      PARSER_STREAM (parser) = skip_spaces_const (PARSER_STREAM (parser));
+      PARSER_STREAM (parser) = skip_spaces (PARSER_STREAM (parser));
 
       /* Check for a keyword, they end the linespec.  */
       keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser));
@@ -1769,7 +1770,7 @@ set_completion_after_number (linespec_parser *parser,
 {
   if (*PARSER_STREAM (parser) == ' ')
     {
-      parser->completion_word = skip_spaces_const (PARSER_STREAM (parser) + 1);
+      parser->completion_word = skip_spaces (PARSER_STREAM (parser) + 1);
       parser->complete_what = next;
     }
   else
@@ -1999,7 +2000,7 @@ linespec_parse_basic (linespec_parser *parser)
                  if (ptr[i] == ' ')
                    {
                      LS_TOKEN_STOKEN (token).length = i;
-                     PARSER_STREAM (parser) = skip_spaces_const (ptr + i + 1);
+                     PARSER_STREAM (parser) = skip_spaces (ptr + i + 1);
                      break;
                    }
                }
@@ -2182,8 +2183,6 @@ create_sals_line_offset (struct linespec_state *self,
   else
     {
       struct linetable_entry *best_entry = NULL;
-      int *filter;
-      const struct block **blocks;
       int i, j;
 
       std::vector<symtab_and_line> intermediate_results
@@ -2203,10 +2202,8 @@ create_sals_line_offset (struct linespec_state *self,
         above, we see if there are other PCs that are in the same
         block.  If yes, the other PCs are filtered out.  */
 
-      filter = XNEWVEC (int, intermediate_results.size ());
-      struct cleanup *cleanup = make_cleanup (xfree, filter);
-      blocks = XNEWVEC (const struct block *, intermediate_results.size ());
-      make_cleanup (xfree, blocks);
+      gdb::def_vector<int> filter (intermediate_results.size ());
+      gdb::def_vector<const block *> blocks (intermediate_results.size ());
 
       for (i = 0; i < intermediate_results.size (); ++i)
        {
@@ -2245,8 +2242,6 @@ create_sals_line_offset (struct linespec_state *self,
            add_sal_to_sals (self, &values, &intermediate_results[i],
                             sym ? SYMBOL_NATURAL_NAME (sym) : NULL, 0);
          }
-
-      do_cleanups (cleanup);
     }
 
   if (values.empty ())
@@ -2702,7 +2697,7 @@ parse_linespec (linespec_parser *parser, const char *arg)
         advances past a keyword automatically, so skip it
         manually.  */
       parser->completion_word
-       = skip_spaces_const (skip_to_space_const (PARSER_STREAM (parser)));
+       = skip_spaces (skip_to_space (PARSER_STREAM (parser)));
       parser->complete_what = linespec_complete_what::EXPRESSION;
     }
 
@@ -4318,35 +4313,46 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
   CORE_ADDR pc;
   struct symtab_and_line sal;
 
-  sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (objfile, msymbol),
-                          (struct obj_section *) 0, 0);
-  sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
-
-  /* The minimal symbol might point to a function descriptor;
-     resolve it to the actual code address instead.  */
-  pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc, &current_target);
-  if (pc != sal.pc)
-    sal = find_pc_sect_line (pc, NULL, 0);
-
-  if (self->funfirstline)
+  if (msymbol_is_text (msymbol))
     {
-      if (sal.symtab != NULL
-         && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))
-             || SYMTAB_LANGUAGE (sal.symtab) == language_asm))
+      sal = find_pc_sect_line (MSYMBOL_VALUE_ADDRESS (objfile, msymbol),
+                              (struct obj_section *) 0, 0);
+      sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
+
+      /* The minimal symbol might point to a function descriptor;
+        resolve it to the actual code address instead.  */
+      pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc,
+                                              &current_target);
+      if (pc != sal.pc)
+       sal = find_pc_sect_line (pc, NULL, 0);
+
+      if (self->funfirstline)
        {
-         /* If gdbarch_convert_from_func_ptr_addr does not apply then
-            sal.SECTION, sal.LINE&co. will stay correct from above.
-            If gdbarch_convert_from_func_ptr_addr applies then
-            sal.SECTION is cleared from above and sal.LINE&co. will
-            stay correct from the last find_pc_sect_line above.  */
-         sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol);
-         sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc,
-                                                      &current_target);
-         if (gdbarch_skip_entrypoint_p (gdbarch))
-           sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc);
+         if (sal.symtab != NULL
+             && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab))
+                 || SYMTAB_LANGUAGE (sal.symtab) == language_asm))
+           {
+             /* If gdbarch_convert_from_func_ptr_addr does not apply then
+                sal.SECTION, sal.LINE&co. will stay correct from above.
+                If gdbarch_convert_from_func_ptr_addr applies then
+                sal.SECTION is cleared from above and sal.LINE&co. will
+                stay correct from the last find_pc_sect_line above.  */
+             sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol);
+             sal.pc = gdbarch_convert_from_func_ptr_addr (gdbarch, sal.pc,
+                                                          &current_target);
+             if (gdbarch_skip_entrypoint_p (gdbarch))
+               sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc);
+           }
+         else
+           skip_prologue_sal (&sal);
        }
-      else
-       skip_prologue_sal (&sal);
+    }
+  else
+    {
+      sal.objfile = objfile;
+      sal.pc = MSYMBOL_VALUE_ADDRESS (objfile, msymbol);
+      sal.pspace = current_program_space;
+      sal.section = MSYMBOL_OBJ_SECTION (objfile, msymbol);
     }
 
   if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))
@@ -4633,6 +4639,7 @@ symbol_to_sal (struct symtab_and_line *result,
          *result = {};
          result->symtab = symbol_symtab (sym);
          result->line = SYMBOL_LINE (sym);
+         result->pc = SYMBOL_VALUE_ADDRESS (sym);
          result->pspace = SYMTAB_PSPACE (result->symtab);
          return 1;
        }
This page took 0.028284 seconds and 4 git commands to generate.