Re: creating the gdb-7.4 branch tomorrow (?)

Tom Tromey
2011-12-06T18:54:04Z

[-- Attachment #1: Type: text/plain, Size: 58 bytes --]

Here is patch #4. This fixes some Ada regressions.

Tom

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch 4 --]
[-- Type: text/x-patch, Size: 11387 bytes --]

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index f960a25..250aba2 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5052,6 +5052,36 @@ done:
return ndefns;
}

+/* Implementation of the la_iterate_over_symbols method. */
+
+static void
+ada_iterate_over_symbols (const struct block *block,
+ const char *name, domain_enum domain,
+ int (*callback) (struct symbol *, void *),
+ void *data)
+{
+ int ndefs, i;
+ struct ada_symbol_info *results;
+ char *canon;
+ int nlen = strlen (name);
+
+ if (name[0] == '<' && name[nlen - 1] == '>')
+ {
+ canon = alloca (nlen - 1);
+ memcpy (canon, name + 1, nlen - 2);
+ canon[nlen - 2] = '\0';
+ }
+ else
+ canon = ada_encode (ada_fold_name (name));
+
+ ndefs = ada_lookup_symbol_list (canon, block, domain, &results);
+ for (i = 0; i < ndefs; ++i)
+ {
+ if (! (*callback) (results[i].sym, data))
+ break;
+ }
+}
+
struct symbol *
ada_lookup_encoded_symbol (const char *name, const struct block *block0,
domain_enum namespace, struct block **block_found)
@@ -12282,6 +12312,7 @@ const struct language_defn ada_language_defn = {
ada_print_array_index,
default_pass_by_reference,
c_get_string,
+ ada_iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 3a35a78..81e7849 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -863,6 +863,7 @@ const struct language_defn c_language_defn =
default_print_array_index,
default_pass_by_reference,
c_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

@@ -984,6 +985,7 @@ const struct language_defn cplus_language_defn =
default_print_array_index,
cp_pass_by_reference,
c_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

@@ -1023,6 +1025,7 @@ const struct language_defn asm_language_defn =
default_print_array_index,
default_pass_by_reference,
c_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

@@ -1067,6 +1070,7 @@ const struct language_defn minimal_language_defn =
default_print_array_index,
default_pass_by_reference,
c_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index c0599a5..44ff68a 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -273,6 +273,7 @@ static const struct language_defn d_language_defn =
default_print_array_index,
default_pass_by_reference,
c_get_string,
+ NULL,
LANG_MAGIC
};

diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index f538eee..7a8516d 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -309,6 +309,7 @@ const struct language_defn f_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 4eae356..ce65a2d 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1197,6 +1197,7 @@ const struct language_defn java_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/language.c b/gdb/language.c
index 825c02d..701c479 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1200,6 +1200,7 @@ const struct language_defn unknown_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

@@ -1241,6 +1242,7 @@ const struct language_defn auto_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

@@ -1280,6 +1282,7 @@ const struct language_defn local_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};
\f
diff --git a/gdb/language.h b/gdb/language.h
index 1ff575f..82e6a88 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -318,6 +318,26 @@ struct language_defn
void (*la_get_string) (struct value *value, gdb_byte **buffer, int *length,
struct type **chartype, const char **charset);

+ /* Find all symbols in the current program space matching NAME in
+ DOMAIN, according to this language's rules.
+
+ The search starts with BLOCK. This function iterates upward
+ through blocks. When the outermost block has been finished,
+ the function returns.
+
+ For each one, call CALLBACK with the symbol and the DATA
+ argument. If CALLBACK returns zero, the iteration ends at that
+ point.
+
+ This field can be NULL, meaning that this language doesn't need
+ any special code aside from ordinary searches of the symbol
+ table. */
+ void (*la_iterate_over_symbols) (const struct block *block,
+ const char *name,
+ domain_enum domain,
+ int (*callback) (struct symbol *, void *),
+ void *data);
+
/* Add fields above this point, so the magic number is always last. */
/* Magic number for compat checking. */

@@ -422,6 +442,10 @@ extern enum language set_language (enum language);
#define LA_PRINT_ARRAY_INDEX(index_value, stream, options) \
(current_language->la_print_array_index(index_value, stream, options))

+#define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK, DATA) \
+ (current_language->la_iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK, \
+ DATA))
+
/* Test a character to decide whether it can be printed in literal form
or needs to be printed in another representation. For example,
in C the literal form of the character with octal value 141 is 'a'
diff --git a/gdb/linespec.c b/gdb/linespec.c
index f8ae062..8b357a3 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -375,8 +375,9 @@ iterate_over_all_matching_symtabs (const char *name,
if (symtab->primary)
{
struct block *block;
+
block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
- iterate_over_symbols (block, name, domain, callback, data);
+ LA_ITERATE_OVER_SYMBOLS (block, name, domain, callback, data);
}
}
}
@@ -1836,10 +1837,10 @@ lookup_prefix_sym (char **argptr, char *p, VEC (symtab_p) *file_symtabs,
gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
set_current_program_space (SYMTAB_PSPACE (elt));
search_block = get_search_block (elt);
- iterate_over_symbols (search_block, copy, STRUCT_DOMAIN,
- collect_one_symbol, &collector);
- iterate_over_symbols (search_block, copy, VAR_DOMAIN,
- collect_one_symbol, &collector);
+ LA_ITERATE_OVER_SYMBOLS (search_block, copy, STRUCT_DOMAIN,
+ collect_one_symbol, &collector);
+ LA_ITERATE_OVER_SYMBOLS (search_block, copy, VAR_DOMAIN,
+ collect_one_symbol, &collector);
}
}

@@ -2191,28 +2192,6 @@ find_function_symbols (char **argptr, char *p, int is_quote_enclosed,
iterate_over_all_matching_symtabs (copy, VAR_DOMAIN,
collect_function_symbols, &result, NULL);

- /* If looking up the given name failed, try using the current
- language to look up a symbol. This may augment the search. If a
- symbol is found this way, repeat the iteration, but using the
- discovered name. */
- if (VEC_empty (symbolp, result)
- && current_language->la_language == language_ada)
- {
- struct symbol *function_symbol;
-
- function_symbol = lookup_symbol (copy, get_selected_block (0),
- VAR_DOMAIN, 0);
- if (function_symbol && SYMBOL_CLASS (function_symbol) == LOC_BLOCK)
- {
- xfree (copy);
- copy = xstrdup (SYMBOL_SEARCH_NAME (function_symbol));
- *user_function = copy;
- iterate_over_all_matching_symtabs (copy, VAR_DOMAIN,
- collect_function_symbols,
- &result, NULL);
- }
- }
-
if (VEC_empty (symbolp, result))
VEC_free (symbolp, result);
else
@@ -2807,9 +2786,9 @@ add_matching_symbols_to_info (const char *name,
been filtered out earlier. */
gdb_assert (!SYMTAB_PSPACE (elt)->executing_startup);
set_current_program_space (SYMTAB_PSPACE (elt));
- iterate_over_symbols (get_search_block (elt), name,
- VAR_DOMAIN, collect_symbols,
- info);
+ LA_ITERATE_OVER_SYMBOLS (get_search_block (elt), name,
+ VAR_DOMAIN, collect_symbols,
+ info);
}
}
}
@@ -2842,22 +2821,6 @@ decode_variable (struct linespec_state *self, char *copy)

add_matching_symbols_to_info (lookup_name, &info, NULL);

- /* If looking up the given name failed, try using the current
- language to look up a symbol. This may augment the search. If a
- symbol is found this way, repeat the iteration, but using the
- discovered name. */
- if (info.result.nelts == 0 && current_language->la_language == language_ada)
- {
- struct symbol *sym;
-
- sym = lookup_symbol (lookup_name, get_selected_block (0), VAR_DOMAIN, 0);
- if (sym)
- {
- copy = SYMBOL_SEARCH_NAME (sym);
- add_matching_symbols_to_info (copy, &info, NULL);
- }
- }
-
if (info.result.nelts > 0)
{
if (self->canonical)
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index f83c622..106dfcf 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -401,6 +401,7 @@ const struct language_defn m2_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index dcf9459..1da92a5 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -541,6 +541,7 @@ const struct language_defn objc_language_defn = {
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 05955b4..895a51c 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1024,6 +1024,7 @@ const struct language_defn opencl_language_defn =
default_print_array_index,
default_pass_by_reference,
c_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 655279b..30b890f 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -459,6 +459,7 @@ const struct language_defn pascal_language_defn =
default_print_array_index,
default_pass_by_reference,
default_get_string,
+ iterate_over_symbols,
LANG_MAGIC
};

diff --git a/gdb/testsuite/gdb.ada/homonym.exp b/gdb/testsuite/gdb.ada/homonym.exp
index b5dff1b..d568633 100644
--- a/gdb/testsuite/gdb.ada/homonym.exp
+++ b/gdb/testsuite/gdb.ada/homonym.exp
@@ -31,6 +31,24 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }

clean_restart ${testfile}

+
+# Do these tests before running, so we are operating in a known
+# environment.
+
+gdb_test "break Get_Value" \
+ "Breakpoint \[0-9\]+ at $hex: Get_Value. .2 locations." \
+ "set breakpoint at Get_Value"
+
+gdb_test "break homonym.adb:Get_Value" \
+ "Breakpoint \[0-9\]+ at $hex: homonym.adb:Get_Value. .2 locations." \
+ "set breakpoint at homonym.adb:Get_Value"
+
+gdb_test "break <homonym__get_value>" \
+ "Breakpoint \[0-9\]+ at $hex: <homonym__get_value>. .2 locations." \
+ "set breakpoint at <homonym__get_value>"
+
+delete_breakpoints
+
set bp_location [gdb_get_line_number "BREAK_1" ${testdir}/homonym.adb]
runto "homonym.adb:$bp_location"

@@ -86,6 +104,3 @@ gdb_test "ptype lcl" \
gdb_test "print lcl" \
"= 17" \
"print lcl at BREAK_2"
-
-
-
--
1.7.6.4