/* Test gdb_disassembler for a given gdbarch by reading data from a
pre-allocated buffer. If you want to see the disassembled
- instruction printed to gdb_stdout, set verbose to true. */
- static const bool verbose = false;
+ instruction printed to gdb_stdout, use maint selftest -verbose. */
class gdb_disassembler_test : public gdb_disassembler
{
const gdb_byte *insn,
size_t len)
: gdb_disassembler (gdbarch,
- (verbose ? gdb_stdout : &null_stream),
+ (run_verbose () ? gdb_stdout : &null_stream),
gdb_disassembler_test::read_memory),
m_insn (insn), m_len (len)
{
int
print_insn (CORE_ADDR memaddr)
{
- if (verbose)
+ if (run_verbose ())
{
fprintf_unfiltered (stream (), "%s ",
gdbarch_bfd_arch_info (arch ())->arch_name);
int len = gdb_disassembler::print_insn (memaddr);
- if (verbose)
+ if (run_verbose ())
fprintf_unfiltered (stream (), "\n");
return len;
@kindex maint selftest
@cindex self tests
-@item maint selftest @r{[}@var{filter}@r{]}
+@item maint selftest @r{[}-verbose@r{]} @r{[}@var{filter}@r{]}
Run any self tests that were compiled in to @value{GDBN}. This will
print a message showing how many tests were run, and how many failed.
If a @var{filter} is passed, only the tests with @var{filter} in their
-name will be ran.
+name will be ran. If @code{-verbose} is passed, the self tests can be
+more verbose.
@kindex maint info selftests
@cindex self tests
maintenance_selftest (const char *args, int from_tty)
{
#if GDB_SELF_TEST
+ bool verbose = args != nullptr && check_for_argument (&args, "-verbose");
gdb_argv argv (args);
- selftests::run_tests (argv.as_array_view ());
+ selftests::run_tests (argv.as_array_view (), verbose);
#else
printf_filtered (_("\
Selftests have been disabled for this build.\n"));
/* See selftest.h. */
+static bool run_verbose_ = false;
+
+/* See selftest.h. */
+
+bool
+run_verbose ()
+{
+ return run_verbose_;
+}
+
+/* See selftest.h. */
+
void
-run_tests (gdb::array_view<const char *const> filters)
+run_tests (gdb::array_view<const char *const> filters, bool verbose)
{
int ran = 0, failed = 0;
+ run_verbose_ = verbose;
for (const auto &pair : tests)
{
virtual void operator() () const = 0;
};
+/* True if selftest should run verbosely. */
+
+extern bool run_verbose ();
+
/* Register a new self-test. */
extern void register_test (const std::string &name, selftest *test);
If FILTERS is not empty, only run tests with names containing one of the
element of FILTERS. */
-extern void run_tests (gdb::array_view<const char *const> filters);
+extern void run_tests (gdb::array_view<const char *const> filters,
+ bool verbose = false);
/* Reset GDB or GDBserver's internal state. */
extern void reset ();