/* */
+/* 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. */
char *real_path = NULL;
char *full_path = NULL;
struct cleanup *cleanup;
+ const char* base_name = lbasename (name);
cleanup = make_cleanup (null_cleanup, NULL);
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. */
/* 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))))
{
"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");
}
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;
/* 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. */
{
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;
macro_for_each (macro_user_macros, add_macro_name, &datum);
}
+ discard_cleanups (back_to);
return (return_val);
}
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))
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;
}
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);
}