* config/tc-mips.c (macro_build_jalr): Reverse a negative
[deliverable/binutils-gdb.git] / gdb / symtab.c
index d1e2cb4a1fd1a8b353997aa8f69aeb351014d146..3d94e6b9a3367fc5dfab3cb54a00c35fa24bc763 100644 (file)
@@ -83,10 +83,6 @@ static void output_source_filename (const char *, int *);
 
 static int find_line_common (struct linetable *, int, int *);
 
-/* This one is used by linespec.c */
-
-char *operator_chars (char *p, char **end);
-
 static struct symbol *lookup_symbol_aux (const char *name,
                                         const struct block *block,
                                         const domain_enum domain,
@@ -116,6 +112,11 @@ void _initialize_symtab (void);
 
 /* */
 
+/* Non-zero if a file may be known by two different basenames.
+   This is the uncommon case, and significantly slows down gdb.
+   Default set to "off" to not slow down the common case.  */
+int basenames_may_differ = 0;
+
 /* Allow the user to configure the debugger behavior with respect
    to multiple-choice menus when more than one symbol matches during
    a symbol lookup.  */
@@ -159,6 +160,7 @@ lookup_symtab (const char *name)
   char *real_path = NULL;
   char *full_path = NULL;
   struct cleanup *cleanup;
+  const char* base_name = lbasename (name);
 
   cleanup = make_cleanup (null_cleanup, NULL);
 
@@ -184,6 +186,12 @@ got_symtab:
        return s;
       }
 
+    /* Before we invoke realpath, which can get expensive when many
+       files are involved, do a quick comparison of the basenames.  */
+    if (! basenames_may_differ
+       && FILENAME_CMP (base_name, lbasename (s->filename)) != 0)
+      continue;
+
     /* If the user gave us an absolute path, try to find the file in
        this symtab and use its absolute path.  */
 
@@ -2553,8 +2561,8 @@ skip_prologue_sal (struct symtab_and_line *sal)
       /* Check if gdbarch_skip_prologue left us in mid-line, and the next
         line is still part of the same function.  */
       if (skip && start_sal.pc != pc
-         && (sym? (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) <= start_sal.end
-                   && start_sal.end < BLOCK_END (SYMBOL_BLOCK_VALUE (sym)))
+         && (sym ? (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) <= start_sal.end
+                    && start_sal.end < BLOCK_END (SYMBOL_BLOCK_VALUE (sym)))
              : (lookup_minimal_symbol_by_pc_section (start_sal.end, section)
                 == lookup_minimal_symbol_by_pc_section (pc, section))))
        {
@@ -2637,7 +2645,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
    some legitimate operator text, return a pointer to the
    beginning of the substring of the operator text.
    Otherwise, return "".  */
-char *
+static char *
 operator_chars (char *p, char **end)
 {
   *end = "";
@@ -2885,7 +2893,8 @@ sources_info (char *ignore, int from_tty)
                   "will be read in on demand:\n\n");
 
   first = 1;
-  map_partial_symbol_filenames (output_partial_symbol_filename, &first);
+  map_partial_symbol_filenames (output_partial_symbol_filename, &first,
+                               1 /*need_fullname*/);
   printf_filtered ("\n");
 }
 
@@ -3577,6 +3586,30 @@ compare_symbol_name (const char *name, const char *sym_text, int sym_text_len)
   return 1;
 }
 
+/* Free any memory associated with a completion list.  */
+
+static void
+free_completion_list (char ***list_ptr)
+{
+  int i = 0;
+  char **list = *list_ptr;
+
+  while (list[i] != NULL)
+    {
+      xfree (list[i]);
+      i++;
+    }
+  xfree (list);
+}
+
+/* Callback for make_cleanup.  */
+
+static void
+do_free_completion_list (void *list)
+{
+  free_completion_list (list);
+}
+
 /* Helper routine for make_symbol_completion_list.  */
 
 static int return_val_size;
@@ -3775,6 +3808,7 @@ struct add_name_data
    This adds a macro's name to the current completion list.  */
 static void
 add_macro_name (const char *name, const struct macro_definition *ignore,
+               struct macro_source_file *ignore2, int ignore3,
                void *user_data)
 {
   struct add_name_data *datum = (struct add_name_data *) user_data;
@@ -3813,6 +3847,7 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
   /* Length of sym_text.  */
   int sym_text_len;
   struct add_name_data datum;
+  struct cleanup *back_to;
 
   /* Now look for the symbol we are supposed to complete on.  */
   {
@@ -3889,6 +3924,7 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
   return_val_index = 0;
   return_val = (char **) xmalloc ((return_val_size + 1) * sizeof (char *));
   return_val[0] = NULL;
+  back_to = make_cleanup (do_free_completion_list, &return_val);
 
   datum.sym_text = sym_text;
   datum.sym_text_len = sym_text_len;
@@ -3998,6 +4034,7 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
       macro_for_each (macro_user_macros, add_macro_name, &datum);
     }
 
+  discard_cleanups (back_to);
   return (return_val);
 }
 
@@ -4247,12 +4284,15 @@ make_source_files_completion_list (char *text, char *word)
   char **list = (char **) xmalloc (list_alloced * sizeof (char *));
   const char *base_name;
   struct add_partial_filename_data datum;
+  struct cleanup *back_to;
 
   list[0] = NULL;
 
   if (!have_full_symbols () && !have_partial_symbols ())
     return list;
 
+  back_to = make_cleanup (do_free_completion_list, &list);
+
   ALL_SYMTABS (objfile, s)
     {
       if (not_interesting_fname (s->filename))
@@ -4287,7 +4327,9 @@ make_source_files_completion_list (char *text, char *word)
   datum.list = &list;
   datum.list_used = &list_used;
   datum.list_alloced = &list_alloced;
-  map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum);
+  map_partial_symbol_filenames (maybe_add_partial_symtab_filename, &datum,
+                               0 /*need_fullname*/);
+  discard_cleanups (back_to);
 
   return list;
 }
@@ -4379,8 +4421,8 @@ in_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR func_start)
    The functions end point and an increasing SAL line are used as
    indicators of the prologue's endpoint.
 
-   This code is based on the function refine_prologue_limit (versions
-   found in both ia64 and ppc).  */
+   This code is based on the function refine_prologue_limit
+   (found in ia64).  */
 
 CORE_ADDR
 skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
@@ -4397,7 +4439,7 @@ skip_prologue_using_sal (struct gdbarch *gdbarch, CORE_ADDR func_addr)
   prologue_sal = find_pc_line (start_pc, 0);
   if (prologue_sal.line != 0)
     {
-      /* For langauges other than assembly, treat two consecutive line
+      /* For languages other than assembly, treat two consecutive line
         entries at the same address as a zero-instruction prologue.
         The GNU assembler emits separate line notes for each instruction
         in a multi-instruction macro, but compilers generally will not
@@ -4754,7 +4796,6 @@ expand_line_sal (struct symtab_and_line sal)
 
       filter[i] = 1;
       blocks[i] = block_for_pc_sect (ret.sals[i].pc, ret.sals[i].section);
-
     }
   do_cleanups (old_chain);
 
@@ -4856,5 +4897,19 @@ Show how the debugger handles ambiguities in expressions."), _("\
 Valid values are \"ask\", \"all\", \"cancel\", and the default is \"all\"."),
                         NULL, NULL, &setlist, &showlist);
 
+  add_setshow_boolean_cmd ("basenames-may-differ", class_obscure,
+                          &basenames_may_differ, _("\
+Set whether a source file may have multiple base names."), _("\
+Show whether a source file may have multiple base names."), _("\
+(A \"base name\" is the name of a file with the directory part removed.\n\
+Example: The base name of \"/home/user/hello.c\" is \"hello.c\".)\n\
+If set, GDB will canonicalize file names (e.g., expand symlinks)\n\
+before comparing them.  Canonicalization is an expensive operation,\n\
+but it allows the same file be known by more than one base name.\n\
+If not set (the default), all source files are assumed to have just\n\
+one base name, and gdb will do file name comparisons more efficiently."),
+                          NULL, NULL,
+                          &setlist, &showlist);
+
   observer_attach_executable_changed (symtab_observer_executable_changed);
 }
This page took 0.026087 seconds and 4 git commands to generate.