Skip to content

Commit 424eb55

Browse files
committed
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.
1 parent 4249a53 commit 424eb55

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gdb/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019-02-06 John Baldwin <[email protected]>
2+
3+
* fbsd-nat.c (fbsd_fetch_cmdline): Join arguments with spaces.
4+
15
2019-02-05 Tom Tromey <[email protected]>
26

37
* target.c (target_stack::unpush): Move assertion earlier.

gdb/fbsd-nat.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ fbsd_fetch_cmdline (pid_t pid)
231231
if (sysctl (mib, 4, cmdline.get (), &len, NULL, 0) == -1)
232232
return nullptr;
233233

234+
/* Join the arguments with spaces to form a single string. */
235+
char *cp = cmdline.get ();
236+
for (size_t i = 0; i < len - 1; i++)
237+
if (cp[i] == '\0')
238+
cp[i] = ' ';
239+
cp[len - 1] = '\0';
240+
234241
return cmdline;
235242
}
236243

0 commit comments

Comments
 (0)