[0/4] Rewrite gdb_argv using extract_string_maybe_quoted

Message ID cover.1707409662.git.aburgess@redhat.com
Headers
Series Rewrite gdb_argv using extract_string_maybe_quoted |

Message

Andrew Burgess Feb. 8, 2024, 4:28 p.m. UTC
  This short series is really a refactor, though it does fix one tiny
bug in gdb_argv which can be seen in the Python API's
gdb.string_to_argv.  See patch #4 for details.

Patches #1 and #3 are purely about adding more unit tests.

Patches #2 and #4 are the real GDB changes.

This series feeds into two other projects that I'm working on, one of
which is already on the mailing list, and the other is still in
progress.

The first patch in this series:

  https://inbox.sourceware.org/gdb-patches/cover.1704809585.git.aburgess@redhat.com

is for libiberties buildargv function.  Using that function is good
(code reuse), but we already have extract_string_maybe_quoted which is
a GDB local copy of the core loop from within buildargv.  I therefore
claim that using buildargv is good, but using
extract_string_maybe_quoted is better -- the more heavily used GDB's
utility functions are, the more confident we can be that they are
correct.

The second place where this refactor will help is, I think, is with
addign support for filename command options (e.g. -option FILENAME),
in this case, when completing, we need to be able to skip over
FILENAME, which requires having a version of
extract_string_maybe_quoted that can adapt to the escaping which is
applied to FILENAME.  The extract_string_maybe_quoted changes in this
series will be helpful here.

All feedback welcome.

Thanks,
Andrew

---

Andrew Burgess (4):
  gdb/unittests: add extract_string_maybe_quoted self tests
  gdbsupport: allow for configuration of extract_string_maybe_quoted
  gdb/unittests: additional tests for gdb_argv class
  gdbsupport: rewrite gdb_argv to use extract_string_maybe_quoted

 gdb/Makefile.in                          |   2 +
 gdb/testsuite/gdb.python/py-cmd.exp      |   8 ++
 gdb/unittests/extract-string-selftests.c |  96 +++++++++++++++
 gdb/unittests/gdb_argv-selftests.c       | 134 +++++++++++++++++++++
 gdb/utils.c                              |  26 ----
 gdbsupport/buildargv.h                   |  50 +++++---
 gdbsupport/common-utils.cc               |  80 +++++++------
 gdbsupport/common-utils.h                | 144 ++++++++++++++++++++++-
 8 files changed, 464 insertions(+), 76 deletions(-)
 create mode 100644 gdb/unittests/extract-string-selftests.c
 create mode 100644 gdb/unittests/gdb_argv-selftests.c


base-commit: e58beedf2c8a1e0c78e0f57aeab3934de9416bfc