aboutsummaryrefslogtreecommitdiff
path: root/gdb/unittests/command-def-selftests.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/unittests/command-def-selftests.c')
-rw-r--r--gdb/unittests/command-def-selftests.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 6a9b194..0a54d31 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -1,6 +1,6 @@
/* Self tests for GDB command definitions for GDB, the GNU debugger.
- Copyright (C) 2019-2024 Free Software Foundation, Inc.
+ Copyright (C) 2019-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -20,8 +20,7 @@
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
#include "gdbsupport/selftest.h"
-
-#include <map>
+#include "gdbsupport/unordered_map.h"
namespace selftests {
@@ -78,9 +77,10 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
(prefix, c->name,
"has superfluous trailing whitespace");
+ const char *prev_start = c->doc;
for (const char *nl = strchr (c->doc, '\n');
nl != nullptr;
- nl = strchr (nl + 1, '\n'))
+ nl = strchr (prev_start, '\n'))
{
if (nl == c->doc)
broken_doc_invariant (prefix, c->name, "has a leading newline");
@@ -91,8 +91,15 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
broken_doc_invariant (prefix, c->name,
"has whitespace before a newline");
}
+
+ if (nl - prev_start > cli_help_line_length)
+ broken_doc_invariant (prefix, c->name, "has over-long line");
+ prev_start = nl + 1;
}
+ if (strlen (prev_start) > cli_help_line_length)
+ broken_doc_invariant (prefix, c->name, "has over-long line");
+
/* Check if this command has subcommands and is not an
abbreviation. We skip checking subcommands of abbreviations
in order to avoid duplicates in the output. */
@@ -126,7 +133,7 @@ static unsigned int nr_invalid_prefixcmd = 0;
/* A map associating a list with the prefix leading to it. */
-static std::map<cmd_list_element **, const char *> lists;
+static gdb::unordered_map<cmd_list_element **, const char *> lists;
/* Store each command list in lists, associated with the prefix to reach it. A
list must only be found once.
@@ -212,9 +219,7 @@ command_structure_invariants_tests ()
} /* namespace selftests */
-void _initialize_command_def_selftests ();
-void
-_initialize_command_def_selftests ()
+INIT_GDB_FILE (command_def_selftests)
{
selftests::register_test
("help_doc_invariants",