[PATCH 2/4] gdbserver: Don't add extra NULL to program args

Michael Weghorn m.weghorn@posteo.de
Wed Apr 29 11:16:36 GMT 2020


The vector holding the program args is passed as a parameter
to target_create_inferior, which then passes it to
stringify_argv for all platforms, where any NULL entry in
the vector is ignored, so there seems to be no reason
to actually add one after all.

(Since the intention is to replace uses of stringify_argv with
construct_inferior_arguments in a follow-up commit and that
function doesn't currently handle such NULL arguments, it
would otherwise have to be extended.)

gdbserver/ChangeLog:

2020-04-29  Michael Weghorn  <m.weghorn@posteo.de>

        * server.cc (captured_main): No longer insert extra NULL
        element to args vector.
---
 gdbserver/server.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 0672f9bc4d..239511c104 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3815,7 +3815,6 @@ captured_main (int argc, char *argv[])
       program_path.set (make_unique_xstrdup (next_arg[0]));
       for (i = 1; i < n; i++)
 	program_args.push_back (xstrdup (next_arg[i]));
-      program_args.push_back (NULL);
 
       /* Wait till we are at first instruction in program.  */
       target_create_inferior (program_path.get (), program_args);
-- 
2.26.2



More information about the Gdb-patches mailing list