summaryrefslogtreecommitdiff
path: root/gdb/fbsd-nat.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2019-02-06 09:45:50 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2019-02-06 09:45:50 -0800
commit424eb552c27a1574974d9052dff4ff252a7db22d (patch)
tree1ec7879ab93d0de60ebed3b5bfcd786e0a8af2a7 /gdb/fbsd-nat.c
parent4249a53cce8651061092d666e5df06492cb91cf1 (diff)
downloadbinutils-gdb-424eb552c27a1574974d9052dff4ff252a7db22d.tar.gz
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.
Diffstat (limited to 'gdb/fbsd-nat.c')
-rw-r--r--gdb/fbsd-nat.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 712f9d3b7b8..184d63939f4 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -231,6 +231,13 @@ fbsd_fetch_cmdline (pid_t pid)
if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1)
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;
}