From owner-freebsd-arch@FreeBSD.ORG Mon Feb 11 21:09:45 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 89AF952C for ; Mon, 11 Feb 2013 21:09:45 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from smtp7.server.rpi.edu (smtp7.server.rpi.edu [128.113.2.227]) by mx1.freebsd.org (Postfix) with ESMTP id 4E222E2F for ; Mon, 11 Feb 2013 21:09:45 +0000 (UTC) Received: from gilead.netel.rpi.edu (gilead.netel.rpi.edu [128.113.124.121]) by smtp7.server.rpi.edu (8.13.1/8.13.1) with ESMTP id r1BJwhSU025621; Mon, 11 Feb 2013 14:58:43 -0500 Message-ID: <51194D73.2010804@FreeBSD.org> Date: Mon, 11 Feb 2013 14:58:43 -0500 From: Garance A Drosehn User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.9) Gecko/20100722 Eudora/3.0.4 MIME-Version: 1.0 To: Christoph Mallon Subject: Re: Proposal: Unify printing the function name in panic messages() References: <51141E33.4080103@gmx.de> In-Reply-To: <51141E33.4080103@gmx.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Bayes-Prob: 0.0001 (Score 0) X-RPI-SA-Score: 0.10 () [Hold at 11.00] COMBINED_FROM X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: 57036054 - 00adcdc2efb1 X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.227 Cc: Kirk McKusick , freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Feb 2013 21:09:45 -0000 On 2/7/13 4:35 PM, Christoph Mallon wrote: > > currently the style for printing panic messages varies greatly. > Here are some examples of the most common styles: > panic("just a message"); > panic("function_name: message"); > panic("wrong_function_name: message"); > panic("%s: message", __func__); > Especially the third -- a wrong function name being shown -- is annoying > and quite common. I propose a simple macro, which wraps panic() and > ensures that the right name is shown always by using __func__. > Do you have suggestions to improve this proposal? > > Chrsopth While I'm replying to the first message in the thread, I've read most of the messages up to this point. I do very little development in the kernel, but as it happens I've spent the last three weeks untangling a somewhat large C-based project which has similar messages, and due to the nature of the project it's nearly impossible to run debuggers on it. So I can't just pop into the debugger and get some kind of stack trace. That project uses __func__ on some printf()s, and __FILE__ on others. I found it quite useful there. When tracking down a few specific bugs there were multiple places which could generate the error message I was looking for, so I added __LINE__ to those printf()s. This was helpful, particularly in one case where the entire message was specified as a constant string in one place, but the same error *could* be printed out by a different printf which built the message via format specifiers. So scanning for the message would pick up the first case as an obvious hit, and never notice the second case. And, of course, it turned out that the message in my log file was coming from that second case. So maybe it'd be good to have two panic options. One with the __LINE__ number, and one without. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu