diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-25 17:54:55 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-23 15:38:54 -0400 |
commit | fd2dec2a45a73154d9824071ebb8664a39a69174 (patch) | |
tree | 2297cdb9fa147b25a87d354a0f7e1452f71a64d3 /gdb/procfs.c | |
parent | 90cc31c9e59a75122c2371fdf43f53d91e6ad5d6 (diff) | |
download | gdb-fd2dec2a45a73154d9824071ebb8664a39a69174.zip gdb-fd2dec2a45a73154d9824071ebb8664a39a69174.tar.gz gdb-fd2dec2a45a73154d9824071ebb8664a39a69174.tar.bz2 |
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
Diffstat (limited to 'gdb/procfs.c')
-rw-r--r-- | gdb/procfs.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/gdb/procfs.c b/gdb/procfs.c index 0641efd..a8ee933 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -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)); } } |