aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-05-06 13:47:07 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-05-06 13:47:07 +0000
commit1976171a47ef25e0b893222c5d704c89a8678ed7 (patch)
tree79d7bd281caae5d952e075f99706c3829d314c5f /gdb/symtab.c
parent7db6f30f9d4707b04e7292d7d8bfa5d37eaff67f (diff)
downloadgdb-1976171a47ef25e0b893222c5d704c89a8678ed7.zip
gdb-1976171a47ef25e0b893222c5d704c89a8678ed7.tar.gz
gdb-1976171a47ef25e0b893222c5d704c89a8678ed7.tar.bz2
gdb/
* symtab.c (compare_symbol_name): New function. (completion_list_add_name, expand_partial_symbol_name): Call it, remove the variable ncmp. (default_make_symbol_completion_list_break_on): Reduce SYM_TEXT_LEN, gdb_assert it. gdb/testsuite/ * gdb.cp/psymtab-parameter.cc: New file. * gdb.cp/psymtab-parameter.exp: New file.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c65
1 files changed, 53 insertions, 12 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index d98ac57..7f8877f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3489,6 +3489,40 @@ rbreak_command (char *regexp, int from_tty)
}
+/* Evaluate if NAME matches SYM_TEXT and SYM_TEXT_LEN.
+
+ Either sym_text[sym_text_len] != '(' and then we search for any
+ symbol starting with SYM_TEXT text.
+
+ Otherwise sym_text[sym_text_len] == '(' and then we require symbol name to
+ be terminated at that point. Partial symbol tables do not have parameters
+ information. */
+
+static int
+compare_symbol_name (const char *name, const char *sym_text, int sym_text_len)
+{
+ int (*ncmp) (const char *, const char *, size_t);
+
+ ncmp = (case_sensitivity == case_sensitive_on ? strncmp : strncasecmp);
+
+ if (ncmp (name, sym_text, sym_text_len) != 0)
+ return 0;
+
+ if (sym_text[sym_text_len] == '(')
+ {
+ /* User searches for `name(someth...'. Require NAME to be terminated.
+ Normally psymtabs and gdbindex have no parameter types so '\0' will be
+ present but accept even parameters presence. In this case this
+ function is in fact strcmp_iw but whitespace skipping is not supported
+ for tab completion. */
+
+ if (name[sym_text_len] != '\0' && name[sym_text_len] != '(')
+ return 0;
+ }
+
+ return 1;
+}
+
/* Helper routine for make_symbol_completion_list. */
static int return_val_size;
@@ -3508,16 +3542,10 @@ completion_list_add_name (char *symname, char *sym_text, int sym_text_len,
char *text, char *word)
{
int newsize;
- int (*ncmp) (const char *, const char *, size_t);
-
- ncmp = (case_sensitivity == case_sensitive_on ? strncmp : strncasecmp);
/* Clip symbols that cannot match. */
-
- if (ncmp (symname, sym_text, sym_text_len) != 0)
- {
- return;
- }
+ if (!compare_symbol_name (symname, sym_text, sym_text_len))
+ return;
/* We have a match for a completion, so add SYMNAME to the current list
of matches. Note that the name is moved to freshly malloc'd space. */
@@ -3707,11 +3735,8 @@ static int
expand_partial_symbol_name (const char *name, void *user_data)
{
struct add_name_data *datum = (struct add_name_data *) user_data;
- int (*ncmp) (const char *, const char *, size_t);
-
- ncmp = (case_sensitivity == case_sensitive_on ? strncmp : strncasecmp);
- return ncmp (name, datum->sym_text, datum->sym_text_len) == 0;
+ return compare_symbol_name (name, datum->sym_text, datum->sym_text_len);
}
char **
@@ -3790,6 +3815,22 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
sym_text_len = strlen (sym_text);
+ /* Prepare SYM_TEXT_LEN for compare_symbol_name. */
+
+ if (current_language->la_language == language_cplus
+ || current_language->la_language == language_java
+ || current_language->la_language == language_fortran)
+ {
+ /* These languages may have parameters entered by user but they are never
+ present in the partial symbol tables. */
+
+ const char *cs = memchr (sym_text, '(', sym_text_len);
+
+ if (cs)
+ sym_text_len = cs - sym_text;
+ }
+ gdb_assert (sym_text[sym_text_len] == '\0' || sym_text[sym_text_len] == '(');
+
return_val_size = 100;
return_val_index = 0;
return_val = (char **) xmalloc ((return_val_size + 1) * sizeof (char *));