Fix 'info proc cmdline' for native FreeBSD processes.

The kern.proc.args.<pid> sysctl returns the argv array as a packed
array of arguments, each null terminated.  To construct a complete
command line, the arguments must be joined with spaces by converting
the intermediate nul characters to spaces.  Previously only the first
argument was shown in cmdline output.  Now, all arguments are shown.

gdb/ChangeLog:

	* fbsd-nat.c (fbsd_fetch_cmdline): Join arguments with spaces.
This commit is contained in:
John Baldwin 2019-02-06 09:45:50 -08:00
parent 4249a53cce
commit 424eb552c2
2 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2019-02-06 John Baldwin <jhb@FreeBSD.org>
* fbsd-nat.c (fbsd_fetch_cmdline): Join arguments with spaces.
2019-02-05 Tom Tromey <tom@tromey.com> 2019-02-05 Tom Tromey <tom@tromey.com>
* target.c (target_stack::unpush): Move assertion earlier. * target.c (target_stack::unpush): Move assertion earlier.

View File

@ -231,6 +231,13 @@ fbsd_fetch_cmdline (pid_t pid)
if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1) if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1)
return nullptr; return nullptr;
/* Join the arguments with spaces to form a single string. */
char *cp = cmdline.get ();
for (size_t i = 0; i < len - 1; i++)
if (cp[i] == '\0')
cp[i] = ' ';
cp[len - 1] = '\0';
return cmdline; return cmdline;
} }