From patchwork Mon Jan 28 21:58:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 31235 Received: (qmail 126298 invoked by alias); 28 Jan 2019 21:58:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 126290 invoked by uid 89); 28 Jan 2019 21:58:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Jan 2019 21:58:51 +0000 Received: from ralph.baldwin.cx (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 1186C10B68A for ; Mon, 28 Jan 2019 16:58:48 -0500 (EST) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH] Fix 'info proc cmdline' for native FreeBSD processes. Date: Mon, 28 Jan 2019 13:58:42 -0800 Message-Id: MIME-Version: 1.0 X-IsSubscribed: yes The kern.proc.args. 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. --- gdb/ChangeLog | 4 ++++ gdb/fbsd-nat.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5d5f72b817..3cb630255e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-01-28 John Baldwin + + * fbsd-nat.c (fbsd_fetch_cmdline): Join arguments with spaces. + 2019-01-28 John Baldwin * aarch64-fbsd-tdep.c (aarch64_fbsd_gregmap) diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 712f9d3b7b..184d63939f 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; }