gdb: make inferior::m_args an std::string

With the current code, both a NULL pointer and an empty string can mean
"no arguments".  We don't need this distinction.  Changing to a string
has the advantage that there is now a single state for that (an empty
string), which makes the code a bit simpler in my opinion.

Change-Id: Icdc622820f7869478791dbaa84b4a1c7fec21ced
This commit is contained in:
Simon Marchi 2021-06-25 17:54:55 -04:00
parent 90cc31c9e5
commit fd2dec2a45
6 changed files with 23 additions and 35 deletions

View file

@ -3603,7 +3603,6 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size)
char psargs[80] = {'\0'};
procinfo *pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
gdb::unique_xmalloc_ptr<char> note_data;
const char *inf_args;
enum gdb_signal stop_signal;
if (get_exec_file (0))
@ -3613,14 +3612,13 @@ procfs_target::make_corefile_notes (bfd *obfd, int *note_size)
strncpy (psargs, get_exec_file (0), sizeof (psargs));
psargs[sizeof (psargs) - 1] = 0;
inf_args = current_inferior ()->args ();
if (inf_args && *inf_args
&& (strlen (inf_args)
< ((int) sizeof (psargs) - (int) strlen (psargs))))
const std::string &inf_args = current_inferior ()->args ();
if (!inf_args.empty () &&
inf_args.length () < ((int) sizeof (psargs) - (int) strlen (psargs)))
{
strncat (psargs, " ",
sizeof (psargs) - strlen (psargs));
strncat (psargs, inf_args,
strncat (psargs, inf_args.c_str (),
sizeof (psargs) - strlen (psargs));
}
}