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);
};
#include "fnmatch.h"
#include "hashtab.h"
#include "typeprint.h"
+#include "exceptions.h"
#include "gdbsupport/gdb_obstack.h"
#include "block.h"
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);
}
\f
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.*"