mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyeongmin Cho <korea.drzix@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Kyeongmin Cho <korea.drzix@gmail.com>
Subject: [PATCH v2] perf gtk: Print dlerror() and reverse the loading order
Date: Sun,  1 May 2016 01:14:14 +0900	[thread overview]
Message-ID: <1462032854-16200-1-git-send-email-korea.drzix@gmail.com> (raw)

This patch applies two changes below:

* When dlopen() returns NULL, the string from dlerror() is printed
  to tell why it has failed.
* The loading order was reversed. It used to try to load LIBDIR
  second, but it's reasonable to look around LIBDIR first and fall
  back to system directory.

Signed-off-by: Kyeongmin Cho <korea.drzix@gmail.com>
---
This patch refers to the previous discussion
Re: [PATCH 1/2] perf report: Find lib path correctly for gtk option
>From Namhyung Kim

AFAIK this fallback code is only needed if perf was not installed in
the standard directory (and system has no perf package installed
also).  Anyway I think it's better to add a debug message when loading
is failed (preferably with dlerror() or so).

In addition, I think the loading order should be reversed.  It
currently tries to load libperf-gtk.so in the system directory and
then LIBDIR/libperf-gtk.so.  But it'd be better to try LIBDIR first
and then falls back to system directory IMHO.

 tools/perf/ui/setup.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index ba51fa8..17e87da 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -12,18 +12,23 @@ void *perf_gtk_handle;
 static int setup_gtk_browser(void)
 {
 	int (*perf_ui_init)(void);
+	char buf[PATH_MAX];
 
 	if (perf_gtk_handle)
 		return 0;
 
-	perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
+	scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
+	perf_gtk_handle = dlopen(buf, RTLD_LAZY);
+
 	if (perf_gtk_handle == NULL) {
-		char buf[PATH_MAX];
-		scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
-		perf_gtk_handle = dlopen(buf, RTLD_LAZY);
+		printf("%s\n", dlerror());
+		perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
 	}
-	if (perf_gtk_handle == NULL)
+
+	if (perf_gtk_handle == NULL) {
+		printf("%s\n", dlerror());
 		return -1;
+	}
 
 	perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
 	if (perf_ui_init == NULL)
-- 
2.5.5

                 reply	other threads:[~2016-04-30 16:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462032854-16200-1-git-send-email-korea.drzix@gmail.com \
    --to=korea.drzix@gmail.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®