[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <afa25468e62ae3259878d8a95e9ac96f6be9f88a.camel@perches.com>
Date: Wed, 01 Aug 2018 00:03:50 -0700
From: Joe Perches <joe@...ches.com>
To: Christophe LEROY <christophe.leroy@....fr>,
Murilo Opsfelder Araujo <muriloo@...ux.ibm.com>,
linux-kernel@...r.kernel.org
Cc: Alastair D'Silva <alastair@...ilva.org>,
Andrew Donnellan <andrew.donnellan@....ibm.com>,
Balbir Singh <bsingharora@...il.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Cyril Bur <cyrilbur@...il.com>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
Michael Ellerman <mpe@...erman.id.au>,
Michael Neuling <mikey@...ling.org>,
Nicholas Piggin <npiggin@...il.com>,
Paul Mackerras <paulus@...ba.org>,
Simon Guo <wei.guo.simon@...il.com>,
Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>,
"Tobin C . Harding" <me@...in.cc>, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v3 5/9] powerpc/traps: Print signal name for unhandled
signals
On Wed, 2018-08-01 at 08:37 +0200, Christophe LEROY wrote:
> Le 31/07/2018 à 16:50, Murilo Opsfelder Araujo a écrit :
> > This adds a human-readable name in the unhandled signal message.
> > Before this patch, a page fault looked like:
> > pandafault[6303]: unhandled signal 11 at 100007d0 nip 1000061c lr 7fff93c55100 code 2 in pandafault[10000000+10000]
> > After this patch, a page fault looks like:
> > pandafault[6352]: segfault (11) at 13a2a09f8 nip 13a2a086c lr 7fffb63e5100 code 2 in pandafault[13a2a0000+10000]
]]
> > diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
[]
> > @@ -96,6 +96,41 @@ EXPORT_SYMBOL(__debugger_fault_handler);
> > #define TM_DEBUG(x...) do { } while(0)
> > #endif
> >
> > +static const char *signames[SIGRTMIN + 1] = {
> > + "UNKNOWN",
> > + "SIGHUP", // 1
> > + "SIGINT", // 2
[]
> I don't think is is worth having that full table when we only use a few
> of them. (As discussed in v1 https://patchwork.ozlabs.org/patch/948802/)
>
> I would suggest to instead use a function like this:
>
> static const char *signame(int signr)
> {
> if (signr == SIGBUS)
> return "bus error";
> if (signr == SIGFPE)
> return "floating point exception";
> if (signr == SIGILL)
> return "illegal instruction";
> if (signr == SIGILL)
> return "segfault";
> if (signr == SIGTRAP)
> return "unhandled trap";
> return "unknown signal";
> }
trivia:
Unless the if tests are ordered most to least likely,
perhaps it would be better to use a switch/case and
let the compiler decide.
switch (signr) {
case SIGBUS: return "bus error";
case SIGFPE: return "floating point exception";
case SIGILL: return "illegal instruction";
case SIGSEGV: return "segfault";
case SIGTRAP: return "unhandled trap";
}
return "unknown signal";
}
Powered by blists - more mailing lists