From d369b608a1fc84813762e71a40a6cafb3ab828fe Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 14 Aug 2020 12:27:22 -0400 Subject: gdb: add gdb_argv::as_array_view method Introduce the gdb_argv::as_array_view method, as a way to easily pass the parsed arguments array to a function taking an array view. There is currently one caller where we can use this (which prompted the suggestion to implement this method). Add some selftests for the new method, which at the same time test a little bit gdb_argv. As far as I know, it's not tested currently. gdb/ChangeLog: * utils.h (class gdb_argv) : New method. * utils.c (gdb_argv_as_array_view_test): New. (_initialize_utils): Register selftest. * maint.c (maintenance_selftest): Use the new method. Change-Id: I0645037613ed6549aabe60f14a36f3494513b177 --- gdb/utils.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gdb/utils.h') diff --git a/gdb/utils.h b/gdb/utils.h index 3434ff1..9a235b9 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -22,6 +22,7 @@ #define UTILS_H #include "exceptions.h" +#include "gdbsupport/array-view.h" #include "gdbsupport/scoped_restore.h" #include @@ -210,6 +211,13 @@ public: return m_argv[arg]; } + /* Return the arguments array as an array view. */ + + gdb::array_view as_array_view () + { + return gdb::array_view (this->get (), this->count ()); + } + /* The iterator type. */ typedef char **iterator; -- cgit v1.1