From 06cfa23b27eec28047d3fc715431786a90854934 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sat, 2 Jul 2011 20:07:59 +0000 Subject: [PATCH] commit 2daaa790297294478cb724dbec677879580bb2cf Author: Jan Kratochvil Date: Fri Jul 1 20:16:38 2011 +0000 gdb/ Fall back linespec to minimal symbols. * linespec.c (decode_line_1): New variable ex, saved_argptr. Protect decode_compound by TRY_CATCH, fall back on minsyms if it failed. (find_method, symbol_found): Change error to cplusplus_error. gdb/testsuite/ Fall back linespec to minimal symbols. * gdb.base/psymtab.exp (Don't search past end of psymtab.): Update the error message. * gdb.cp/cplusfuncs.exp (list foo::operator int*): Likewise. * gdb.cp/minsym-fallback-main.cc: New file. * gdb.cp/minsym-fallback.cc: New file. * gdb.cp/minsym-fallback.exp: New file. * gdb.cp/minsym-fallback.h: New file. --- gdb/ChangeLog | 7 ++ gdb/linespec.c | 71 +++++++++++++------- gdb/testsuite/ChangeLog | 11 +++ gdb/testsuite/gdb.base/psymtab.exp | 2 +- gdb/testsuite/gdb.cp/cplusfuncs.exp | 2 +- gdb/testsuite/gdb.cp/minsym-fallback-main.cc | 1 - gdb/testsuite/gdb.cp/minsym-fallback.cc | 5 -- gdb/testsuite/gdb.cp/minsym-fallback.exp | 4 +- gdb/testsuite/gdb.cp/minsym-fallback.h | 1 - 9 files changed, 67 insertions(+), 37 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e4be01ccf94..e33c77d12cd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2011-07-02 Jan Kratochvil + + Fall back linespec to minimal symbols. + * linespec.c (decode_line_1): New variable ex, saved_argptr. Protect + decode_compound by TRY_CATCH, fall back on minsyms if it failed. + (find_method, symbol_found): Change error to cplusplus_error. + 2011-07-02 Jan Kratochvil * symtab.c (symbol_find_demangled_name): Remove DMGL_VERBOSE. diff --git a/gdb/linespec.c b/gdb/linespec.c index 51e7bfa0015..88e95af02c7 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -932,35 +932,51 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab, if (p[0] == '.' || p[1] == ':') { struct symtabs_and_lines values; + volatile struct gdb_exception ex; + char *saved_argptr = *argptr; if (is_quote_enclosed) ++saved_arg; - values = decode_compound (argptr, funfirstline, canonical, - file_symtab, saved_arg, p); + + TRY_CATCH (ex, RETURN_MASK_ERROR) + { + values = decode_compound (argptr, funfirstline, canonical, + file_symtab, saved_arg, p); + } if ((is_quoted || is_squote_enclosed) && **argptr == '\'') *argptr = *argptr + 1; - return values; - } - /* If there was an exception looking up a specified filename earlier, - then check whether we were really given `function:label'. */ - if (file_exception.reason < 0) - { - function_symbol = find_function_symbol (argptr, p, is_quote_enclosed); - /* If we did not find a function, re-throw the original - exception. */ - if (!function_symbol) - throw_exception (file_exception); - } + if (ex.reason >= 0) + return values; - /* Check for single quotes on the non-filename part. */ - if (!is_quoted) + if (ex.error != NOT_FOUND_ERROR) + throw_exception (ex); + + *argptr = saved_argptr; + } + else { - is_quoted = (**argptr - && strchr (get_gdb_completer_quote_characters (), - **argptr) != NULL); - if (is_quoted) - end_quote = skip_quoted (*argptr); + /* If there was an exception looking up a specified filename earlier, + then check whether we were really given `function:label'. */ + if (file_exception.reason < 0) + { + function_symbol = find_function_symbol (argptr, p, + is_quote_enclosed); + /* If we did not find a function, re-throw the original + exception. */ + if (!function_symbol) + throw_exception (file_exception); + } + + /* Check for single quotes on the non-filename part. */ + if (!is_quoted) + { + is_quoted = (**argptr + && strchr (get_gdb_completer_quote_characters (), + **argptr) != NULL); + if (is_quoted) + end_quote = skip_quoted (*argptr); + } } } @@ -1797,9 +1813,9 @@ find_method (int funfirstline, struct linespec_result *canonical, } } - error (_("the class `%s' does not have " - "any method instance named %s"), - SYMBOL_PRINT_NAME (sym_class), copy); + cplusplus_error (saved_arg, _("the class `%s' does not have " + "any method instance named %s"), + SYMBOL_PRINT_NAME (sym_class), copy); } return decode_line_2 (sym_arr, i1, funfirstline, canonical); @@ -2207,7 +2223,12 @@ symbol_found (int funfirstline, struct linespec_result *canonical, char *copy, return values; } else if (funfirstline) - error (_("\"%s\" is not a function"), copy); + { + /* NOT_FOUND_ERROR is not correct but it ensures COPY will be + searched also as a minimal symbol. */ + + throw_error (NOT_FOUND_ERROR, _("\"%s\" is not a function"), copy); + } else if (SYMBOL_LINE (sym) != 0) { /* We know its line number. */ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 89bdc85ea73..1a5832191b0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2011-07-02 Jan Kratochvil + + Fall back linespec to minimal symbols. + * gdb.base/psymtab.exp (Don't search past end of psymtab.): Update the + error message. + * gdb.cp/cplusfuncs.exp (list foo::operator int*): Likewise. + * gdb.cp/minsym-fallback-main.cc: New file. + * gdb.cp/minsym-fallback.cc: New file. + * gdb.cp/minsym-fallback.exp: New file. + * gdb.cp/minsym-fallback.h: New file. + 2011-07-02 Jan Kratochvil * gdb.cp/no-dmgl-verbose.cc: New file. diff --git a/gdb/testsuite/gdb.base/psymtab.exp b/gdb/testsuite/gdb.base/psymtab.exp index 903c286d76d..a68513022d3 100644 --- a/gdb/testsuite/gdb.base/psymtab.exp +++ b/gdb/testsuite/gdb.base/psymtab.exp @@ -71,4 +71,4 @@ gdb_test_no_output "set breakpoint pending off" "psymtab pending setup" # zzz::dummy currently causes a search for 'zzz' in STRUCT_NAMESPACE # without a preceding search for 'zzz' in VAR_NAMESPACE. -gdb_test "break zzz::dummy" "Can't find member of namespace, class, struct, or union named \"zzz::dummy\"\r\n.*" "Don't search past end of psymtab." +gdb_test "break zzz::dummy" {Function "zzz::dummy" not defined\.} "Don't search past end of psymtab." diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp index 10e4dac61ac..f0753525985 100644 --- a/gdb/testsuite/gdb.cp/cplusfuncs.exp +++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp @@ -616,7 +616,7 @@ proc do_tests {} { # A regression test on errors involving operators gdb_test "list foo::operator $dm_type_int_star" \ - ".*the class foo does not have any method named operator $dm_type_int_star.*" + "Function \"foo::operator [string_to_regexp $dm_type_int_star]\" not defined\\." } do_tests diff --git a/gdb/testsuite/gdb.cp/minsym-fallback-main.cc b/gdb/testsuite/gdb.cp/minsym-fallback-main.cc index d2a677ba222..a82adefb623 100644 --- a/gdb/testsuite/gdb.cp/minsym-fallback-main.cc +++ b/gdb/testsuite/gdb.cp/minsym-fallback-main.cc @@ -23,5 +23,4 @@ int main () { c.f (); - c (); } diff --git a/gdb/testsuite/gdb.cp/minsym-fallback.cc b/gdb/testsuite/gdb.cp/minsym-fallback.cc index 1231f7d9834..1ecd2892300 100644 --- a/gdb/testsuite/gdb.cp/minsym-fallback.cc +++ b/gdb/testsuite/gdb.cp/minsym-fallback.cc @@ -21,8 +21,3 @@ void C::f () { } - -void -C::operator () () -{ -} diff --git a/gdb/testsuite/gdb.cp/minsym-fallback.exp b/gdb/testsuite/gdb.cp/minsym-fallback.exp index 20065450e8f..df95a2d6e3c 100644 --- a/gdb/testsuite/gdb.cp/minsym-fallback.exp +++ b/gdb/testsuite/gdb.cp/minsym-fallback.exp @@ -35,6 +35,4 @@ clean_restart ${executable} gdb_test_no_output "set breakpoint pending off" -gdb_test "break C::f()" {Breakpoint [0-9]+ at 0x[0-9a-f]+} - -gdb_test "break C::operator()()" {Breakpoint [0-9]+ at 0x[0-9a-f]+} +gdb_test "break 'C::f()'" {Breakpoint [0-9]+ at 0x[0-9a-f]+} diff --git a/gdb/testsuite/gdb.cp/minsym-fallback.h b/gdb/testsuite/gdb.cp/minsym-fallback.h index 88bcb5cb58f..db32e4571b0 100644 --- a/gdb/testsuite/gdb.cp/minsym-fallback.h +++ b/gdb/testsuite/gdb.cp/minsym-fallback.h @@ -19,5 +19,4 @@ class C { public: static void f (); - void operator () (); }; -- 2.47.2