From owner-freebsd-current@freebsd.org Tue Aug 4 13:31:39 2015 Return-Path: Delivered-To: freebsd-current@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 4A2DD9B2AB0 for ; Tue, 4 Aug 2015 13:31:39 +0000 (UTC) (envelope-from eric@badgerio.us) Received: from sasl.smtp.pobox.com (pb-smtp1.int.icgroup.com [208.72.237.35]) by mx1.freebsd.org (Postfix) with ESMTP id 0D740C66 for ; Tue, 4 Aug 2015 13:31:38 +0000 (UTC) (envelope-from eric@badgerio.us) Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 4BEE66485B; Tue, 4 Aug 2015 09:27:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=subject:to :references:cc:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=sasl; bh=DMwl1/NRgAUN F+rBaXtZQBdI4dg=; b=qxHgM5fUMVHdLw5phSnj1zGjSdEYEMVdavjhL2KyW9uY D1Nv62sP6RhOIbUdW4/l1h4yf9uCBIPKycgXB1pWTJiK7lVTw4E1SDURxcdSgxPW JgGXFGYMnen5G661sOB9Ng8cHD2QHCKw0Jy5qnAcZ9B6ghuwbHiJTV+ymg3M304= Received: from pb-smtp1.int.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 458D764859; Tue, 4 Aug 2015 09:27:34 -0400 (EDT) Received: from [192.168.1.103] (unknown [24.7.205.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id C5C2664856; Tue, 4 Aug 2015 09:27:33 -0400 (EDT) Subject: Re: Appending to message buffer while in ddb To: Marcel Moolenaar References: <55BFC80B.2000005@dell.com> <16785483-7FD3-4475-9958-168528AFB2D9@xcllnt.net> Cc: FreeBSD Current From: Eric Badger Message-ID: <55C0BDC0.7010109@badgerio.us> Date: Tue, 4 Aug 2015 08:27:28 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <16785483-7FD3-4475-9958-168528AFB2D9@xcllnt.net> Content-Type: text/plain; charset=utf-8; format=flowed X-Pobox-Relay-ID: 90939C08-3AAC-11E5-8CBB-21AE9F42C9D4-46178211!pb-smtp1.pobox.com Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2015 13:31:39 -0000 On 08/03/2015 03:21 PM, Marcel Moolenaar wrote: >> On Aug 3, 2015, at 12:59 PM, Eric Badger wrote: >> >> Hi there, >> >> Since r226435, output from kernel printf/log functions is not appended= to the message buffer when in ddb. The commit message doesn't call this = out specifically; instead it appears to have been to address double print= ing to the console while in ddb. I noticed this because a ddb script whic= h previously resulted in some things ending up in a textdump's msgbuf.txt= no longer does so. It may be that the answer is "use db_printf in ddb", = which is ok, but I thought I'd check anyway to see if the aforementioned = change was indeed intentional, since I wasn't able to dig up any discussi= on about it. > It=E2=80=99s a direct consequence. > But is it a necessary consequence? For example, would the below patch=20 also be acceptable (it's perhaps not the cleanest way to do it, but=20 gives the idea)? This way we'll print to the console (once) and, if=20 TOLOG is also specified, append to the message buffer. If this is not=20 acceptable, then I think all ddb commands not using db_printf (such as=20 'show rtc') should be converted to doing so (this might be a good idea=20 either way), since their output cannot currently be captured in textdumps= . Thanks, Eric diff --git sys/kern/subr_prf.c sys/kern/subr_prf.c index 4f35838..4739331 100644 --- sys/kern/subr_prf.c +++ sys/kern/subr_prf.c @@ -463,19 +463,28 @@ putchar(int c, void *arg) struct putchar_arg *ap =3D (struct putchar_arg*) arg; struct tty *tp =3D ap->tty; int flags =3D ap->flags; + int putbuf_done =3D 0; /* Don't use the tty code after a panic or while in ddb. */ if (kdb_active) { if (c !=3D '\0') cnputc(c); - return; - } - - if ((flags & TOTTY) && tp !=3D NULL && panicstr =3D=3D NULL) - tty_putchar(tp, c); + /* Prevent double printing. */ + ap->flags &=3D ~(TOCONS); + flags =3D ap->flags; + } else { + if ((panicstr =3D=3D NULL) && (flags & TOTTY) && (tp !=3D NULL)) + tty_putchar(tp, c); - if ((flags & (TOCONS | TOLOG)) && c !=3D '\0') - putbuf(c, ap); + if (flags & TOCONS) { + putbuf(c, ap); + putbuf_done =3D 1; + } + } + if ((flags & TOLOG) && (putbuf_done =3D=3D 0)) { + if (c !=3D '\0') + putbuf(c, ap); + } } /*