From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752437AbbC0Keg (ORCPT ); Fri, 27 Mar 2015 06:34:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43694 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbbC0Kee (ORCPT ); Fri, 27 Mar 2015 06:34:34 -0400 Date: Fri, 27 Mar 2015 11:32:43 +0100 From: Borislav Petkov To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Don Zickus , Frederic Weisbecker , Namhyung Kim , Stephane Eranian Subject: Re: [PATCH 14/25] perf symbols: Save DSO loading errno to better report errors Message-ID: <20150327103243.GA18931@pd.tnic> References: <1427213980-9015-1-git-send-email-acme@kernel.org> <1427213980-9015-15-git-send-email-acme@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1427213980-9015-15-git-send-email-acme@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2015 at 01:19:29PM -0300, Arnaldo Carvalho de Melo wrote: > From: Arnaldo Carvalho de Melo > > Before, when some problem happened while trying to load the kernel > symtab, 'perf top' would show: > > ┌─Warning:───────────────────────────┐ > │The vmlinux file can't be used. │ > │Kernel samples will not be resolved.│ > │ │ > │ │ > │Press any key... │ > └────────────────────────────────────┘ > > Now, it reports: > > # perf top --vmlinux /dev/null > > ┌─Warning:───────────────────────────────────────────┐ > │The /tmp/passwd file can't be used: Invalid ELF file│ > │Kernel samples will not be resolved. │ > │ │ > │ │ > │Press any key... │ > └────────────────────────────────────────────────────┘ > > This is possible because we now register the reason for not being able > to load the symtab in the dso->load_errno member, and provide a > dso__strerror_load() routine to format this error into a strerror like > string with a short reason for the error while loading. > > That can be just forwarding the dso__strerror_load() call to > strerror_r(), or, for a separate errno range providing a custom message. > > Reported-by: Ingo Molnar > Acked-by: Jiri Olsa > Cc: Adrian Hunter > Cc: Borislav Petkov > Cc: David Ahern > Cc: Don Zickus > Cc: Frederic Weisbecker > Cc: Namhyung Kim > Cc: Stephane Eranian > Link: http://lkml.kernel.org/n/tip-u5rb5uq63xqhkfb8uv2lxd5u@git.kernel.org > Signed-off-by: Arnaldo Carvalho de Melo ... > @@ -1137,3 +1137,36 @@ enum dso_type dso__type(struct dso *dso, struct machine *machine) > > return dso__type_fd(fd); > } > + > +int dso__strerror_load(struct dso *dso, char *buf, size_t buflen) > +{ > + int idx, errnum = dso->load_errno; > + /* > + * This must have a same ordering as the enum dso_load_errno. > + */ > + static const char *dso_load__error_str[] = { > + "Internal tools/perf/ library error", > + "Invalid ELF file", > + "Can not read build id", > + "Mismatching build id", > + "Decompression failure", > + }; You could define this str array by using the dso_load_errno defines so that they're always in sync: static const char *dso_load__error_str[] = { [DSO_LOAD_ERRNO__INTERNAL_ERROR - __DSO_LOAD_ERRNO__START] = "Internal tools/perf/ library error", [DSO_LOAD_ERRNO__INVALID_ELF - __DSO_LOAD_ERRNO__START] = "Invalid ELF file", ... and even use a small macro to hide the __DSO_LOAD_ERRNO__START thing. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --