From owner-svn-src-all@freebsd.org Wed Jul 12 23:41:40 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 520C3DA7AEA; Wed, 12 Jul 2017 23:41:40 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qt0-x232.google.com (mail-qt0-x232.google.com [IPv6:2607:f8b0:400d:c0d::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 091107C0F4; Wed, 12 Jul 2017 23:41:40 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qt0-x232.google.com with SMTP id b40so25623316qtb.2; Wed, 12 Jul 2017 16:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ErrCiTdt6Lgf7vbZUBMNWE3Eizdxj7MUZsnH2tuwbkU=; b=UdkWVDPucXNgnyt4Xz9hhfE6sqBxcy9RxxV1HO4d18gZnPbR6SGbx89JyIxEDKveS6 zmnKUh5SaMPWNeTh2kJJY9to9CTKfkyH+cuNk5t7fiwfuAO4nQ/xoHaIpwgLu7ZrhU9t 7aBIUrvlc0dYKMVfKoOE0/DbCi4C70rP9uJw39N4jE3EYQkssuTQ2JHO1AJ22o4SU8S/ tW5/k7EbLFnDaLHWozDZoQWu4GCWLp+nS2qujZ7njvuO0MGfzqDpmcoAOv+V0mDQEpQY r+mrLXpLf46daVjVUZxaZJSyjQNu9Byoz0pySsUpETS09opt3PZK7zj0Uf/U+3lgdGq6 gg6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=ErrCiTdt6Lgf7vbZUBMNWE3Eizdxj7MUZsnH2tuwbkU=; b=J5+TIdNpSeXVfd3CUKxIFql373jyShHqFSwutMABy2yCbFjhzQUtiiYJd5lo2xfqOq GLsOB3GJhqrK/CKcFMJv87CU1KVvIRQhMHBYcBmE2xliKEUt2/ZW9QfOGOyxzpz9VID0 b/cqO+gd/6wH9RNtIUaerVkki88VILWPewf5aVhutXQxfSjgrp/3M4OCNnKTF1QFVqbl PERyrPIfNGR+6Dz94MtYsDHk1sTIGakUwTFrkoFNvPaRyIX7fFskU2X++unDqy2d7CEP BQPJA/JSQgMH02Pb+eMfICGcIw5RJIoPv/2oz5gD0DiXJVDLYynJqp4ySQRD6YM+dOUi c2IA== X-Gm-Message-State: AIVw110A9yj1jyaHolo54qoj7rHWgIzWOw+ESgRw5x5XId4h3/zTJymx qQqaUXBCl3zaH3Al X-Received: by 10.200.50.93 with SMTP id y29mr1536931qta.108.1499902898817; Wed, 12 Jul 2017 16:41:38 -0700 (PDT) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id y17sm3181706qtb.37.2017.07.12.16.41.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 16:41:38 -0700 (PDT) Sender: Mark Johnston Date: Wed, 12 Jul 2017 16:41:09 -0700 From: Mark Johnston To: John Baldwin Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r320918 - head/sbin/savecore Message-ID: <20170712234108.GA48612@wkstn-mjohnston.west.isilon.com> References: <201707121829.v6CITPxG012102@repo.freebsd.org> <1930640.IHpqZ2aWqS@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1930640.IHpqZ2aWqS@ralph.baldwin.cx> User-Agent: Mutt/1.8.3 (2017-05-23) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jul 2017 23:41:40 -0000 On Wed, Jul 12, 2017 at 02:23:52PM -0700, John Baldwin wrote: > On Wednesday, July 12, 2017 06:29:25 PM Mark Johnston wrote: > > Author: markj > > Date: Wed Jul 12 18:29:25 2017 > > New Revision: 320918 > > URL: https://svnweb.freebsd.org/changeset/base/320918 > > > > Log: > > Add a newline after the version string. > > > > MFC after: 3 days > > I think the version string normally has a trailing \n emedded in it? You're right. The problem in my case is that the version string is getting truncated in mkdumpheader(), and so the trailing \n is omitted. > Also, > have you verified that crashinfo is still able to match the Version String > from the generated info.X file? I think it might as it stops printing lines > once it matches the second line of the version, so I think (just reading the > awk) that it will not include the extra newline in the 'ivers' compared > against 'version' from gdb. That's true, but it looks like it doesn't work properly in the truncated case. What if we declare a match when the version string in the info.X file matches a prefix of the version string reported by gdb? diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c index 22b4793f4ff5..f5862782bb21 100644 --- a/sbin/savecore/savecore.c +++ b/sbin/savecore/savecore.c @@ -119,7 +119,7 @@ printheader(xo_handle_t *xo, const struct kerneldumpheader *h, const char *devic xo_emit_h(xo, "{P: }{Lwc:Dumptime}{:dumptime/%s}", ctime(&t)); xo_emit_h(xo, "{P: }{Lwc:Hostname}{:hostname/%s}\n", h->hostname); xo_emit_h(xo, "{P: }{Lwc:Magic}{:magic/%s}\n", h->magic); - xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}\n", h->versionstring); + xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}", h->versionstring); xo_emit_h(xo, "{P: }{Lwc:Panic String}{:panic_string/%s}\n", h->panicstring); xo_emit_h(xo, "{P: }{Lwc:Dump Parity}{:dump_parity/%u}\n", h->parity); xo_emit_h(xo, "{P: }{Lwc:Bounds}{:bounds/%d}\n", bounds); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 5c6c0e136769..d87b63461de5 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -1229,6 +1229,7 @@ void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz) { + size_t dstsize; bzero(kdh, sizeof(*kdh)); strlcpy(kdh->magic, magic, sizeof(kdh->magic)); @@ -1240,7 +1241,9 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, kdh->dumpkeysize = htod32(dumpkeysize); kdh->blocksize = htod32(blksz); strlcpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname)); - strlcpy(kdh->versionstring, version, sizeof(kdh->versionstring)); + dstsize = sizeof(kdh->versionstring); + if (strlcpy(kdh->versionstring, version, dstsize) >= dstsize) + kdh->versionstring[dstsize - 2] = '\n'; if (panicstr != NULL) strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); kdh->parity = kerneldump_parity(kdh); diff --git a/usr.sbin/crashinfo/crashinfo.sh b/usr.sbin/crashinfo/crashinfo.sh index e52c01419b0d..b3029c6eea4a 100755 --- a/usr.sbin/crashinfo/crashinfo.sh +++ b/usr.sbin/crashinfo/crashinfo.sh @@ -85,8 +85,9 @@ find_kernel() # Look for a matching kernel version. for k in `sysctl -n kern.bootfile` $(ls -t /boot/*/kernel); do - kvers=$(gdb_command $k 'printf " Version String: %s", version' \ - 2>/dev/null) + kvers=$(gdb_command $k 'printf " Version String: %s", version' | \ + awk "{line=line\$0\"\n\"} END{print substr(line,1,${#ivers})}" \ + 2>/dev/null) if [ "$ivers" = "$kvers" ]; then KERNEL=$k break