diff options
-rw-r--r-- | gdb/breakpoint.c | 18 | ||||
-rw-r--r-- | gdb/breakpoint.h | 8 | ||||
-rw-r--r-- | gdb/symtab.c | 54 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/info_auto_lang.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/default.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/fullpath-expand.exp | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/realname-expand.exp | 5 |
7 files changed, 78 insertions, 19 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 60100fb..e7fdeca 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -869,6 +869,24 @@ scoped_rbreak_breakpoints::~scoped_rbreak_breakpoints () prev_breakpoint_count = rbreak_start_breakpoint_count; } +/* See breakpoint.h. */ + +int +scoped_rbreak_breakpoints::first_breakpoint () const +{ + return rbreak_start_breakpoint_count + 1; +} + +/* See breakpoint.h. */ + +int +scoped_rbreak_breakpoints::last_breakpoint () const +{ + return (rbreak_start_breakpoint_count == breakpoint_count + ? -1 + : breakpoint_count); +} + /* Used in run_command to zero the hit count when a new run starts. */ void diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index be127a9..696dd9e 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1970,6 +1970,14 @@ public: scoped_rbreak_breakpoints (); ~scoped_rbreak_breakpoints (); + /* Return the number of first breakpoint made while this object is + in scope. */ + int first_breakpoint () const; + + /* Return the number of the most recent breakpoint made while this + object is in scope, or -1 if no breakpoints were made. */ + int last_breakpoint () const; + DISABLE_COPY_AND_ASSIGN (scoped_rbreak_breakpoints); }; diff --git a/gdb/symtab.c b/gdb/symtab.c index 30c22dc..72a18dc 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -46,6 +46,7 @@ #include "fnmatch.h" #include "hashtab.h" #include "typeprint.h" +#include "exceptions.h" #include "gdbsupport/gdb_obstack.h" #include "block.h" @@ -5615,28 +5616,53 @@ rbreak_command (const char *regexp, int from_tty) std::vector<symbol_search> symbols = spec.search (); scoped_rbreak_breakpoints finalize; + int err_count = 0; + for (const symbol_search &p : symbols) { - if (p.msymbol.minsym == NULL) + try { - struct symtab *symtab = p.symbol->symtab (); - const char *fullname = symtab_to_fullname (symtab); + if (p.msymbol.minsym == NULL) + { + struct symtab *symtab = p.symbol->symtab (); + const char *fullname = symtab_to_fullname (symtab); - string = string_printf ("%s:'%s'", fullname, - p.symbol->linkage_name ()); - break_command (&string[0], from_tty); - print_symbol_info (p.symbol, p.block, nullptr); + string = string_printf ("%s:'%s'", fullname, + p.symbol->linkage_name ()); + break_command (&string[0], from_tty); + print_symbol_info (p.symbol, p.block, nullptr); + } + else + { + string = string_printf ("'%s'", + p.msymbol.minsym->linkage_name ()); + + break_command (&string[0], from_tty); + gdb_printf ("<function, no debug info> %s;\n", + p.msymbol.minsym->print_name ()); + } } - else + catch (const gdb_exception_error &ex) { - string = string_printf ("'%s'", - p.msymbol.minsym->linkage_name ()); - - break_command (&string[0], from_tty); - gdb_printf ("<function, no debug info> %s;\n", - p.msymbol.minsym->print_name ()); + exception_print (gdb_stderr, ex); + ++err_count; } } + + int first_bp = finalize.first_breakpoint (); + int last_bp = finalize.last_breakpoint (); + + if (last_bp == -1) + gdb_printf (_("No breakpoints made.\n")); + else if (first_bp == last_bp) + gdb_printf (_("Successfully created breakpoint %d.\n"), first_bp); + else + gdb_printf (_("Successfully created breakpoints %d-%d.\n"), + first_bp, last_bp); + + if (err_count > 0) + gdb_printf (_("%d breakpoints failed due to errors, see above.\n"), + err_count); } diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp index cb2a5a7..e15232d 100644 --- a/gdb/testsuite/gdb.ada/info_auto_lang.exp +++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp @@ -153,7 +153,8 @@ foreach_with_prefix language_choice { "auto" "ada" "c" } { "Breakpoint.*file .*proc_in_ada.adb,.*" \ $rbreak_func_in_ada($ada_match) \ "Breakpoint.*file .*some_c.c,.*" \ - $rbreak_func_in_c($c_match) + $rbreak_func_in_c($c_match) \ + "Successfully created breakpoints $decimal-$decimal." ] delete_breakpoints } diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp index 628f070..b1cf957 100644 --- a/gdb/testsuite/gdb.base/default.exp +++ b/gdb/testsuite/gdb.base/default.exp @@ -525,7 +525,7 @@ if $use_gdb_stub { } #test rbreak -gdb_test "rbreak" "rbreak" +gdb_test "rbreak" "No breakpoints made." # test restore gdb_test "restore" "You can't do that without a process to debug\." diff --git a/gdb/testsuite/gdb.base/fullpath-expand.exp b/gdb/testsuite/gdb.base/fullpath-expand.exp index 7ed07b9..c2ae85a 100644 --- a/gdb/testsuite/gdb.base/fullpath-expand.exp +++ b/gdb/testsuite/gdb.base/fullpath-expand.exp @@ -41,7 +41,12 @@ if { $result != 0 || $realsrcfile2 == "" } { clean_restart ${testfile} -gdb_test "rbreak $realsrcfile2:func" "^Breakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\.\r\nvoid func\\(void\\);" "rbreak XXX/fullpath-expand-func.c:func" +gdb_test "rbreak $realsrcfile2:func" \ + [multi_line \ + "Breakpoint 1 at 0x\[0-9a-f\]+: file [string_to_regexp ${subdir}/${srcfile2}], line \[0-9\]+\\." \ + "void func\\(void\\);" \ + "Successfully created breakpoint 1."] \ + "rbreak XXX/fullpath-expand-func.c:func" # Verify the compilation pathnames are as expected: gdb_test "list func" "\tfunc \\(void\\)\r\n.*" diff --git a/gdb/testsuite/gdb.base/realname-expand.exp b/gdb/testsuite/gdb.base/realname-expand.exp index 36d3db5..e62a4db 100644 --- a/gdb/testsuite/gdb.base/realname-expand.exp +++ b/gdb/testsuite/gdb.base/realname-expand.exp @@ -41,8 +41,9 @@ gdb_test_no_output "set basenames-may-differ on" gdb_test "rbreak realname-expand-real.c:func" \ [multi_line "" \ - "Breakpoint 1 at $hex: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." \ - "void func\\(void\\);"] + "Breakpoint 1 at $hex: file \[^\r\n\]*/realname-expand-link\\.c, line $decimal\\." \ + "void func\\(void\\);" \ + "Successfully created breakpoint 1."] delete_breakpoints |