Date: Sat, 9 Feb 2013 20:26:47 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Christoph Mallon <christoph.mallon@gmx.de> Cc: Kirk McKusick <mckusick@mckusick.com>, Andriy Gapon <avg@freebsd.org>, freebsd-arch@freebsd.org Subject: Re: Proposal: Unify printing the function name in panic messages() Message-ID: <20130209195417.C1753@besplex.bde.org> In-Reply-To: <51160E06.1070404@gmx.de> References: <51141E33.4080103@gmx.de> <511426B8.2070800@FreeBSD.org> <51160E06.1070404@gmx.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 9 Feb 2013, Christoph Mallon wrote: > On 07.02.2013 23:12, Andriy Gapon wrote: >> on 07/02/2013 23:35 Christoph Mallon said the following: >>> panic("just a message"); >> >> This seems perfect. >> Panic without at least a stack trace or preferably a crash dump is practically >> useless in most cases. A stack trace already has all the function names. >> So a function name in a message seems to be redundant. > > This is nice in theory, but infeasible in practice. This is feasible in practice, and needs less churn. panic() can edit out duplicates. The callers can be changed at leisure. > More than half of the panic() calls include the correct function name in a way or another. If the function name is correct and is normally formatted as a literal followed by a colon and a space at the start of the message, then it is easy to detect and edit out. If the function name is __func__ and is normally formatted with "%s: " at the start of the format, then it is only a little harder to detect and equally easy to edit out. > I estimate, that another quarter show a wrong name. > It is hard to get this number mechanically, because, well, the names are wrong. If the name is wrong, then it is hard to detect the "duplication", either at runtime or by reading the code. > So most calls include the name (or try to). > Having no function name is a minority. > I plan to correct and unify this hotchpotch. > Also, if stack traces are disabled, you at least can reliably determine, where the panic came from. The name should still be printed in the panic message (unless you turn this off), using the same name lookup as stack tracing uses. If stack traces are disabled, then you normally shouldn't disable names in the panic message. Disabling them would normally not disable the deduplication, but deduplication could be controlled by another runtime option. > Finally, you can turn the names on and off with one central switch. A runtime switch works much better: - no code bloat for function names in all cases - no need to recompile to change the option - more control at runtime. Name lookup from the return address is broken for inline functions and for other optimizations like tail calls, but much more is broken for stack traces. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130209195417.C1753>