From: Jan Kratochvil Date: Fri, 1 Jul 2011 20:16:39 +0000 (+0000) Subject: gdb/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dcf9f4ab7f00dba719a501c8bca3ff446edd200d;p=binutils-gdb.git 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 09a70a99ce4..f46d1edb391 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2011-07-01 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-01 Jan Kratochvil * symtab.c (symbol_find_demangled_name): Remove DMGL_VERBOSE. diff --git a/gdb/linespec.c b/gdb/linespec.c index c820539307f..534560b85f3 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -933,35 +933,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); + } } } @@ -1798,9 +1814,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); @@ -2208,7 +2224,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 756cd316383..ee88fc24fed 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2011-07-01 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-01 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 new file mode 100644 index 00000000000..a82adefb623 --- /dev/null +++ b/gdb/testsuite/gdb.cp/minsym-fallback-main.cc @@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "minsym-fallback.h" + +C c; + +int +main () +{ + c.f (); +} diff --git a/gdb/testsuite/gdb.cp/minsym-fallback.cc b/gdb/testsuite/gdb.cp/minsym-fallback.cc new file mode 100644 index 00000000000..1ecd2892300 --- /dev/null +++ b/gdb/testsuite/gdb.cp/minsym-fallback.cc @@ -0,0 +1,23 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "minsym-fallback.h" + +void +C::f () +{ +} diff --git a/gdb/testsuite/gdb.cp/minsym-fallback.exp b/gdb/testsuite/gdb.cp/minsym-fallback.exp new file mode 100644 index 00000000000..df95a2d6e3c --- /dev/null +++ b/gdb/testsuite/gdb.cp/minsym-fallback.exp @@ -0,0 +1,38 @@ +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# The goal is to have class with full DWARF symbols present in one file having +# only a declaration there for the method. The method is then defined in +# a different file providing only ELF symbols. + +set testfile minsym-fallback +set srcfile ${testfile}.cc +set srcmainfile ${testfile}-main.cc +set executable $testfile +set objfile $objdir/$subdir/${testfile}.o +set objmainfile $objdir/$subdir/${testfile}-main.o +set binfile $objdir/$subdir/$executable +if {[gdb_compile $srcdir/$subdir/$srcfile $objfile object {}] != "" + || [gdb_compile $srcdir/$subdir/$srcmainfile $objmainfile object {debug}] != "" + || [gdb_compile "$objfile $objmainfile" $binfile executable {}] != ""} { + untested ${testfile}.exp + return -1 +} + +clean_restart ${executable} + +gdb_test_no_output "set breakpoint pending off" + +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 new file mode 100644 index 00000000000..db32e4571b0 --- /dev/null +++ b/gdb/testsuite/gdb.cp/minsym-fallback.h @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +class C +{ +public: + static void f (); +};