Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH v2 07/15] Add single-argument overloads of process_options et al
Date: Wed, 11 Nov 2026 08:58:55 -0700	[thread overview]
Message-ID: <20261111-span-part-1-v2-7-cd4e33a8a723@adacore.com> (raw)
In-Reply-To: <20261111-span-part-1-v2-0-cd4e33a8a723@adacore.com>

The C++20 std::span doesn't allow construction from a single object,
whereas gdb's old gdb::array_view did.

This patch fixes one class of the resulting compilation failures by
introducing single-object overloads of process_options and some
related functions.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31422
---
 gdb/cli/cli-option.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h
index 560b189ffc9..6c5b93d1adc 100644
--- a/gdb/cli/cli-option.h
+++ b/gdb/cli/cli-option.h
@@ -387,6 +387,15 @@ extern bool process_options
    process_options_mode mode,
    gdb::span<const option_def_group> options_group);
 
+/* An overload of process_options that accepts a single option.  */
+static inline bool
+process_options (const char **args,
+		 process_options_mode mode,
+		 const option_def_group &options_group)
+{
+  return process_options (args, mode, gdb::make_span (&options_group, 1));
+}
+
 /* Complete ARGS on options listed by OPTIONS_GROUP.  Returns true if
    the string has been fully parsed and there are no operands to
    handle by the caller.  Return false if options were parsed, and
@@ -397,11 +406,31 @@ extern bool complete_options
    process_options_mode mode,
    gdb::span<const option_def_group> options_group);
 
+/* An overload of complete_options that accepts a single option.  */
+static inline bool
+complete_options (completion_tracker &tracker,
+		  const char **args,
+		  process_options_mode mode,
+		  const option_def_group &options_group)
+{
+  return complete_options (tracker, args, mode,
+			   gdb::make_span (&options_group, 1));
+}
+
 /* Complete on all options listed by OPTIONS_GROUP.  */
 extern void
   complete_on_all_options (completion_tracker &tracker,
 			   gdb::span<const option_def_group> options_group);
 
+/* An overload of complete_on_all_options that accepts a single
+   option.  */
+static inline void
+complete_on_all_options (completion_tracker &tracker,
+			 const option_def_group &options_group)
+{
+  complete_on_all_options (tracker, gdb::make_span (&options_group, 1));
+}
+
 /* Return a string with the result of replacing %OPTIONS% in HELP_TMLP
    with an auto-generated "help" string fragment for all the options
    in OPTIONS_GROUP.  */
@@ -409,6 +438,14 @@ extern std::string build_help
   (const char *help_tmpl,
    gdb::span<const option_def_group> options_group);
 
+/* An overload of build_help that accepts a single option.  */
+static inline std::string
+build_help (const char *help_tmpl,
+	    const option_def_group &options_group)
+{
+  return build_help (help_tmpl, gdb::make_span (&options_group, 1));
+}
+
 /* Install set/show commands for options defined in OPTIONS.  DATA is
    a pointer to the structure that holds the data associated with the
    OPTIONS array.  */

-- 
2.56.0


  parent reply	other threads:[~2026-11-11 16:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 15:58 [PATCH v2 00/15] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 01/15] Rename array_view files Tom Tromey
2026-11-15  4:09   ` Simon Marchi
2026-11-16 15:55     ` Tom Tromey
2026-11-11 15:58 ` [PATCH v2 02/15] Rename gdb::array_view to gdb::span Tom Tromey
2026-11-15  4:18   ` Simon Marchi
2026-11-11 15:58 ` [PATCH v2 03/15] Rename gdb::make_array_view to gdb::make_span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 04/15] Remove operator== and operator!= from gdb::span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 05/15] Rename span::slice to span::subspan Tom Tromey
2026-11-11 15:58 ` [PATCH v2 06/15] Qualify calls to gdb::copy Tom Tromey
2026-11-11 15:58 ` Tom Tromey [this message]
2026-11-11 15:58 ` [PATCH v2 08/15] Remove span from cli-option.c:build_help_option Tom Tromey
2026-11-15  3:40   ` Simon Marchi
2026-11-11 15:58 ` [PATCH v2 09/15] Add gdb::make_span overload and add necessary calls Tom Tromey
2026-11-15  3:53   ` Simon Marchi
2026-11-15  4:35     ` Simon Marchi
2026-11-16 16:55       ` Tom Tromey
2026-11-11 15:58 ` [PATCH v2 10/15] Don't turn rvalue reference into a span Tom Tromey
2026-11-11 15:58 ` [PATCH v2 11/15] Change span-selftests.c for C++20 Tom Tromey
2026-11-15  4:01   ` Simon Marchi
2026-11-15  5:15     ` Simon Marchi
2026-11-11 15:59 ` [PATCH v2 12/15] Make gdb::span conform more closely to C++20 Tom Tromey
2026-11-11 15:59 ` [PATCH v2 13/15] Allow the use of C++20 std::ranges in gdbsupport/ranges.h Tom Tromey
2026-11-15  5:18   ` Simon Marchi
2026-11-11 15:59 ` [PATCH v2 14/15] Allow the use of C++20 std::span in gdbsupport/span.h Tom Tromey
2026-11-15  4:05   ` Simon Marchi
2026-11-11 15:59 ` [PATCH v2 15/15] Move gdb::ranges::equal to gdbsupport/ranges.h Tom Tromey
2026-11-15  5:21 ` [PATCH v2 00/15] Rename gdb::array_view to gdb::span Simon Marchi
2026-11-17 21:42   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261111-span-part-1-v2-7-cd4e33a8a723@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox