diff --git a/gdb/linespec.c b/gdb/linespec.c index 871d37d..e8eaf59 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -731,12 +731,22 @@ keep_name_info (char *ptr) return remove_trailing_whitespace (start, ptr); /* Keep important keywords. */ - while (isspace (*p)) - ++p; - if (strncmp (p, "const", 5) == 0 - && (isspace (p[5]) || p[5] == '\0' - || strchr (get_gdb_completer_quote_characters (), p[5]) != NULL)) - ptr = p = p + 5; + while (1) + { + char *quotes = get_gdb_completer_quote_characters (); + while (isspace (*p)) + ++p; + if (strncmp (p, "const", 5) == 0 + && (isspace (p[5]) || p[5] == '\0' + || strchr (quotes, p[5]) != NULL)) + ptr = p = p + 5; + else if (strncmp (p, "volatile", 8) == 0 + && (isspace (p[8]) || p[8] == '\0' + || strchr (quotes, p[8]) != NULL)) + ptr = p = p + 8; + else + break; + } return remove_trailing_whitespace (start, ptr); } @@ -1574,9 +1584,7 @@ decode_compound (char **argptr, int funfirstline, /* We couldn't find a class, so we're in case 2 above. We check the entire name as a symbol instead. */ - if (current_language->la_language == language_cplus - || current_language->la_language == language_java) - p = keep_name_info (p); + p = keep_name_info (p); copy = (char *) alloca (p - saved_arg2 + 1); memcpy (copy, saved_arg2, p - saved_arg2); diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.cc b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc index 21d5c4e..fa66786 100644 --- a/gdb/testsuite/gdb.cp/cmpd-minsyms.cc +++ b/gdb/testsuite/gdb.cp/cmpd-minsyms.cc @@ -25,11 +25,17 @@ class GDB static X even_harder (T a) { return static_cast (a); } int operator == (GDB const& other) { return 1; } + void a (void) const { } + void b (void) volatile { } + void c (void) const volatile { } }; int main(int argc, char **argv) { GDB a, b; + a.a (); + a.b (); + a.c (); if (a == b) return GDB::harder('a') + GDB::harder(3) + GDB::even_harder ('a'); diff --git a/gdb/testsuite/gdb.cp/cmpd-minsyms.exp b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp index 36176fc..696022e 100644 --- a/gdb/testsuite/gdb.cp/cmpd-minsyms.exp +++ b/gdb/testsuite/gdb.cp/cmpd-minsyms.exp @@ -19,13 +19,26 @@ if {[skip_cplus_tests]} { continue } -# Test for c++/12273 +# Tests for c++/12273, breakpoint/12803 set testfile "cmpd-minsyms" # Do NOT compile with debug flag. if {[prepare_for_testing $testfile $testfile $testfile.cc {c++}]} { return -1 } +# Before setting the language, try to set a few simple breakpoints +set min_syms [list \ + "GDB::a() const" \ + "GDB::b() volatile" \ + "GDB::c() const volatile"] +foreach sym $min_syms { + set tst "setting breakpoint at '$sym'" + if {[gdb_breakpoint "'$sym'"]} { + pass $tst + } +} + + gdb_test_no_output "set language c++" # A list of minimal symbol names to check.