Skip to contentSkip to conversation

perf trace/scripting: A couple bugfixes

PATCH Applied Tom Zanussi 3 participants 9 messages Dec 7, 2009 perf events

lore
Share & tools
lore
#0 lore raw

cover perf trace/scripting: A couple bugfixes

One fixes a compile error when libperl isn't installed, the other fixes an annoying message about scripting being unsupported even when the perf trace cmd isn't trying to use scripting.

Tom Zanussi (2):
perf trace/scripting: Fix compile err when libperl not installed perf trace/scripting: Don't display 'scripting unsupported' msg
unnecessarily

 tools/perf/util/trace-event-perl.c |   67 +++++++++++++++++++++++++++++------
 tools/perf/util/trace-event-perl.h |    4 ++
 2 files changed, 59 insertions(+), 12 deletions(-)
#1 lore raw

PATCH 1/2 perf trace/scripting: Fix compile err when libperl not installed

When I added the xs callbacks into perf, I forgot to re-check the no-libperl case. This patch fixes the undefined reference error for that.

---
 tools/perf/util/trace-event-perl.c |    3 ---
 tools/perf/util/trace-event-perl.h |    4 ++++
 2 files changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/trace-event-perl.c +0 -3
index 51e833f..59564b2 100644
@@ -32,9 +32,6 @@
 
 void xs_init(pTHX);
 
-void boot_Perf__Trace__Context(pTHX_ CV *cv);
-void boot_DynaLoader(pTHX_ CV *cv);
-
 void xs_init(pTHX)
 {
 	const char *file = __FILE__;
tools/perf/util/trace-event-perl.h +4 -0
index 8fe0d86..e88fb26 100644
@@ -34,9 +34,13 @@ typedef int INTERP;
 #define dXSUB_SYS
 #define pTHX_
 static inline void newXS(const char *a, void *b, const char *c) {}
+static void boot_Perf__Trace__Context(pTHX_ CV *cv) {}
+static void boot_DynaLoader(pTHX_ CV *cv) {}
 #else
 #include <EXTERN.h>
 #include <perl.h>
+void boot_Perf__Trace__Context(pTHX_ CV *cv);
+void boot_DynaLoader(pTHX_ CV *cv);
 typedef PerlInterpreter * INTERP;
 #endif
 
Signature · 1 line
1.6.4.GIT
#2 lore raw

PATCH 2/2 perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

In reply to Tom Zanussi

The 'scripting unsupported' message should only be displayed when the -s or -g options are used, and not when they aren't, as the current code does.

---
 tools/perf/util/trace-event-perl.c |   64 +++++++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 9 deletions(-)
tools/perf/util/trace-event-perl.c +55 -9
index 59564b2..a5ffe60 100644
@@ -570,26 +570,72 @@ struct scripting_ops perl_scripting_ops = {
 	.generate_script = perl_generate_script,
 };
 
-#ifdef NO_LIBPERL
-void setup_perl_scripting(void)
+static void print_unsupported_msg(void)
 {
 	fprintf(stderr, "Perl scripting not supported."
-		"  Install libperl and rebuild perf to enable it.  e.g. "
-		"apt-get install libperl-dev (ubuntu), yum install "
-		"perl-ExtUtils-Embed (Fedora), etc.\n");
+		"  Install libperl and rebuild perf to enable it.\n"
+		"For example:\n  # apt-get install libperl-dev (ubuntu)"
+		"\n  # yum install perl-ExtUtils-Embed (Fedora)"
+		"\n  etc.\n");
 }
-#else
-void setup_perl_scripting(void)
+
+static int perl_start_script_unsupported(const char *script __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+static int perl_stop_script_unsupported(void)
+{
+	return 0;
+}
+
+static void perl_process_event_unsupported(int cpu __unused,
+					   void *data __unused,
+					   int size __unused,
+					   unsigned long long nsecs __unused,
+					   char *comm __unused)
+{
+}
+
+static int perl_generate_script_unsupported(const char *outfile __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+struct scripting_ops perl_scripting_unsupported_ops = {
+	.name = "Perl",
+	.start_script = perl_start_script_unsupported,
+	.stop_script = perl_stop_script_unsupported,
+	.process_event = perl_process_event_unsupported,
+	.generate_script = perl_generate_script_unsupported,
+};
+
+static void register_perl_scripting(struct scripting_ops *scripting_ops)
 {
 	int err;
-	err = script_spec_register("Perl", &perl_scripting_ops);
+	err = script_spec_register("Perl", scripting_ops);
 	if (err)
 		die("error registering Perl script extension");
 
-	err = script_spec_register("pl", &perl_scripting_ops);
+	err = script_spec_register("pl", scripting_ops);
 	if (err)
 		die("error registering pl script extension");
 
 	scripting_context = malloc(sizeof(struct scripting_context));
 }
+
+#ifdef NO_LIBPERL
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_unsupported_ops);
+}
+#else
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_ops);
+}
 #endif
Signature · 1 line
1.6.4.GIT
#3 lore raw

Re: [PATCH 2/2] perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

Quoted 20 lines · Tom Zanussi

The 'scripting unsupported' message should only be displayed when the -s or -g options are used, and not when they aren't, as the current code does.

---
 tools/perf/util/trace-event-perl.c |   64 +++++++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 9 deletions(-)
tools/perf/util/trace-event-perl.c +1 -2
index 59564b2..a5ffe60 100644
@@ -570,26 +570,72 @@ struct scripting_ops perl_scripting_ops = {
 	.generate_script = perl_generate_script,
 };
 
-#ifdef NO_LIBPERL
-void setup_perl_scripting(void)
+static void print_unsupported_msg(void)

tools/perf/util/trace-event-perl.c struct scripting_ops perl_scripting_ops = { · line 580

Quoted 10 lines
tools/perf/util/trace-event-perl.c +4 -3
 {
 	fprintf(stderr, "Perl scripting not supported."
-		"  Install libperl and rebuild perf to enable it.  e.g. "
-		"apt-get install libperl-dev (ubuntu), yum install "
-		"perl-ExtUtils-Embed (Fedora), etc.\n");
+		"  Install libperl and rebuild perf to enable it.\n"
+		"For example:\n  # apt-get install libperl-dev (ubuntu)"
+		"\n  # yum install perl-ExtUtils-Embed (Fedora)"
+		"\n  etc.\n");
 }

I have one question about how to compile c program that embedded perl function:

$cat foo.c
#include <EXTERN.h>
#include <perl.h>
int main(void)

{
        perl_alloc();
        return 0;
}

$gcc -x c foo.c perl -MExtUtils::Embed -e ccopts 2>/dev/null -o foo perl -MExtUtils::Embed -e ldopts 2>/dev/null /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a:1: error: expected identifier or '(' before '!' token /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a:2: error: stray '`' in program
...

About thousand of error.
I'm using ubuntu 8.04. Above error leads "tools/perl/Makefile" can't find the libperl-dev and define "NO_LIBPERL", but I have installed "libperl-dev".

Did you ever encounter this error?
Thanks.

Liming Wang

Quoted 65 lines
tools/perf/util/trace-event-perl.c +50 -4
-#else
-void setup_perl_scripting(void)
+
+static int perl_start_script_unsupported(const char *script __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+static int perl_stop_script_unsupported(void)
+{
+	return 0;
+}
+
+static void perl_process_event_unsupported(int cpu __unused,
+					   void *data __unused,
+					   int size __unused,
+					   unsigned long long nsecs __unused,
+					   char *comm __unused)
+{
+}
+
+static int perl_generate_script_unsupported(const char *outfile __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+struct scripting_ops perl_scripting_unsupported_ops = {
+	.name = "Perl",
+	.start_script = perl_start_script_unsupported,
+	.stop_script = perl_stop_script_unsupported,
+	.process_event = perl_process_event_unsupported,
+	.generate_script = perl_generate_script_unsupported,
+};
+
+static void register_perl_scripting(struct scripting_ops *scripting_ops)
 {
 	int err;
-	err = script_spec_register("Perl", &perl_scripting_ops);
+	err = script_spec_register("Perl", scripting_ops);
 	if (err)
 		die("error registering Perl script extension");
 
-	err = script_spec_register("pl", &perl_scripting_ops);
+	err = script_spec_register("pl", scripting_ops);
 	if (err)
 		die("error registering pl script extension");
 
 	scripting_context = malloc(sizeof(struct scripting_context));
 }
+
+#ifdef NO_LIBPERL
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_unsupported_ops);
+}
+#else
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_ops);
+}
 #endif
#4 lore raw

Re: [PATCH 2/2] perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

Hi,

Quoted 50 lines · Wang Liming
Quoted 20 lines · Tom Zanussi

The 'scripting unsupported' message should only be displayed when the -s or -g options are used, and not when they aren't, as the current code does.

---
 tools/perf/util/trace-event-perl.c |   64 +++++++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 9 deletions(-)
tools/perf/util/trace-event-perl.c +1 -2
index 59564b2..a5ffe60 100644
@@ -570,26 +570,72 @@ struct scripting_ops perl_scripting_ops = {
 	.generate_script = perl_generate_script,
 };
 
-#ifdef NO_LIBPERL
-void setup_perl_scripting(void)
+static void print_unsupported_msg(void)

tools/perf/util/trace-event-perl.c struct scripting_ops perl_scripting_ops = { · line 580

Quoted 10 lines
tools/perf/util/trace-event-perl.c +4 -3
 {
 	fprintf(stderr, "Perl scripting not supported."
-		"  Install libperl and rebuild perf to enable it.  e.g. "
-		"apt-get install libperl-dev (ubuntu), yum install "
-		"perl-ExtUtils-Embed (Fedora), etc.\n");
+		"  Install libperl and rebuild perf to enable it.\n"
+		"For example:\n  # apt-get install libperl-dev (ubuntu)"
+		"\n  # yum install perl-ExtUtils-Embed (Fedora)"
+		"\n  etc.\n");
 }

I have one question about how to compile c program that embedded perl function:

$cat foo.c
#include <EXTERN.h>
#include <perl.h>
int main(void)

{
         perl_alloc();
         return 0;
}

$gcc -x c foo.c perl -MExtUtils::Embed -e ccopts 2>/dev/null -o foo perl -MExtUtils::Embed -e ldopts 2>/dev/null /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a:1: error: expected identifier or '(' before '!' token /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a:2: error: stray '`' in program
...

Quoted 6 lines

About thousand of error.
I'm using ubuntu 8.04. Above error leads "tools/perl/Makefile" can't find the libperl-dev and define "NO_LIBPERL", but I have installed "libperl-dev".

Did you ever encounter this error?
Thanks.

No, I haven't seen it, but I'm using ubuntu 8.10, which has perl v5.10.0.

ubuntu 8.04 uses what's apparently an ancient version of perl, 5.8, which is I'm guessing where the problem is - I'll have to look into getting things working with 5.8 in any case...

Tom

Quoted 68 lines

Liming Wang

Quoted 65 lines
tools/perf/util/trace-event-perl.c +50 -4
-#else
-void setup_perl_scripting(void)
+
+static int perl_start_script_unsupported(const char *script __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+static int perl_stop_script_unsupported(void)
+{
+	return 0;
+}
+
+static void perl_process_event_unsupported(int cpu __unused,
+					   void *data __unused,
+					   int size __unused,
+					   unsigned long long nsecs __unused,
+					   char *comm __unused)
+{
+}
+
+static int perl_generate_script_unsupported(const char *outfile __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+struct scripting_ops perl_scripting_unsupported_ops = {
+	.name = "Perl",
+	.start_script = perl_start_script_unsupported,
+	.stop_script = perl_stop_script_unsupported,
+	.process_event = perl_process_event_unsupported,
+	.generate_script = perl_generate_script_unsupported,
+};
+
+static void register_perl_scripting(struct scripting_ops *scripting_ops)
 {
 	int err;
-	err = script_spec_register("Perl", &perl_scripting_ops);
+	err = script_spec_register("Perl", scripting_ops);
 	if (err)
 		die("error registering Perl script extension");
 
-	err = script_spec_register("pl", &perl_scripting_ops);
+	err = script_spec_register("pl", scripting_ops);
 	if (err)
 		die("error registering pl script extension");
 
 	scripting_context = malloc(sizeof(struct scripting_context));
 }
+
+#ifdef NO_LIBPERL
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_unsupported_ops);
+}
+#else
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_ops);
+}
 #endif
#5 lore raw

Re: [PATCH 2/2] perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

Quoted 54 lines · Tom Zanussi

Hi,

Quoted 51 lines · Wang Liming
Quoted 20 lines · Tom Zanussi

The 'scripting unsupported' message should only be displayed when the -s or -g options are used, and not when they aren't, as the current code does.

---
 tools/perf/util/trace-event-perl.c |   64 +++++++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 9 deletions(-)
tools/perf/util/trace-event-perl.c +1 -2
index 59564b2..a5ffe60 100644
@@ -570,26 +570,72 @@ struct scripting_ops perl_scripting_ops = {
 	.generate_script = perl_generate_script,
 };
 
-#ifdef NO_LIBPERL
-void setup_perl_scripting(void)
+static void print_unsupported_msg(void)

tools/perf/util/trace-event-perl.c struct scripting_ops perl_scripting_ops = { · line 580

Quoted 10 lines
tools/perf/util/trace-event-perl.c +4 -3
 {
 	fprintf(stderr, "Perl scripting not supported."
-		"  Install libperl and rebuild perf to enable it.  e.g. "
-		"apt-get install libperl-dev (ubuntu), yum install "
-		"perl-ExtUtils-Embed (Fedora), etc.\n");
+		"  Install libperl and rebuild perf to enable it.\n"
+		"For example:\n  # apt-get install libperl-dev (ubuntu)"
+		"\n  # yum install perl-ExtUtils-Embed (Fedora)"
+		"\n  etc.\n");
 }

I have one question about how to compile c program that embedded perl function:

$cat foo.c
#include <EXTERN.h>
#include <perl.h>
int main(void)

{
         perl_alloc();
         return 0;
}

$gcc -x c foo.c perl -MExtUtils::Embed -e ccopts 2>/dev/null -o foo perl -MExtUtils::Embed -e ldopts 2>/dev/null /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a:1: error: expected identifier or '(' before '!' token /usr/lib/perl/5.8/auto/DynaLoader/DynaLoader.a:2: error: stray '`' in program
...

About thousand of error.
I'm using ubuntu 8.04. Above error leads "tools/perl/Makefile" can't find the libperl-dev and define "NO_LIBPERL", but I have installed "libperl-dev".

Quoted 7 lines
Quoted 2 lines

Did you ever encounter this error?
Thanks.

No, I haven't seen it, but I'm using ubuntu 8.10, which has perl v5.10.0.

ubuntu 8.04 uses what's apparently an ancient version of perl, 5.8,

Yes, it uses perl 5.8.

Quoted 2 lines

which is I'm guessing where the problem is - I'll have to look into getting things working with 5.8 in any case...

Another compile error:

CC util/trace-event-perl.o
cc1: warnings being treated as errors
util/trace-event-perl.c: In function 'xs_init':
util/trace-event-perl.c:43: warning: passing argument 2 of 'Perl_newXS' discards qualifiers from pointer target type util/trace-event-perl.c:43: warning: passing argument 4 of 'Perl_newXS' discards qualifiers from pointer target type util/trace-event-perl.c:45: warning: passing argument 2 of 'Perl_newXS' discards qualifiers from pointer target type util/trace-event-perl.c:45: warning: passing argument 4 of 'Perl_newXS' discards qualifiers from pointer target type
make: *** [util/trace-event-perl.o] Error 1

Liming Wang

Quoted 3 lines

Tom

#6 lore raw

[tip:perf/urgent] perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

In reply to Tom Zanussi
Commit-ID:  67a6259ec97b8408f86f2fe8459d2233f0b0987d
Gitweb:     http://git.kernel.org/tip/67a6259ec97b8408f86f2fe8459d2233f0b0987d
Author:     Tom Zanussi <[email protected]>
AuthorDate: Sun, 6 Dec 2009 23:31:59 -0600
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 08:05:07 +0100

perf trace/scripting: Don't display 'scripting unsupported' msg unnecessarily

The 'scripting unsupported' message should only be displayed when the -s or -g options are used, and not when they aren't, as the current code does.

Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/util/trace-event-perl.c |   64 +++++++++++++++++++++++++++++++-----
 1 files changed, 55 insertions(+), 9 deletions(-)
tools/perf/util/trace-event-perl.c +55 -9
index 59564b2..a5ffe60 100644
@@ -570,26 +570,72 @@ struct scripting_ops perl_scripting_ops = {
 	.generate_script = perl_generate_script,
 };
 
-#ifdef NO_LIBPERL
-void setup_perl_scripting(void)
+static void print_unsupported_msg(void)
 {
 	fprintf(stderr, "Perl scripting not supported."
-		"  Install libperl and rebuild perf to enable it.  e.g. "
-		"apt-get install libperl-dev (ubuntu), yum install "
-		"perl-ExtUtils-Embed (Fedora), etc.\n");
+		"  Install libperl and rebuild perf to enable it.\n"
+		"For example:\n  # apt-get install libperl-dev (ubuntu)"
+		"\n  # yum install perl-ExtUtils-Embed (Fedora)"
+		"\n  etc.\n");
 }
-#else
-void setup_perl_scripting(void)
+
+static int perl_start_script_unsupported(const char *script __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+static int perl_stop_script_unsupported(void)
+{
+	return 0;
+}
+
+static void perl_process_event_unsupported(int cpu __unused,
+					   void *data __unused,
+					   int size __unused,
+					   unsigned long long nsecs __unused,
+					   char *comm __unused)
+{
+}
+
+static int perl_generate_script_unsupported(const char *outfile __unused)
+{
+	print_unsupported_msg();
+
+	return -1;
+}
+
+struct scripting_ops perl_scripting_unsupported_ops = {
+	.name = "Perl",
+	.start_script = perl_start_script_unsupported,
+	.stop_script = perl_stop_script_unsupported,
+	.process_event = perl_process_event_unsupported,
+	.generate_script = perl_generate_script_unsupported,
+};
+
+static void register_perl_scripting(struct scripting_ops *scripting_ops)
 {
 	int err;
-	err = script_spec_register("Perl", &perl_scripting_ops);
+	err = script_spec_register("Perl", scripting_ops);
 	if (err)
 		die("error registering Perl script extension");
 
-	err = script_spec_register("pl", &perl_scripting_ops);
+	err = script_spec_register("pl", scripting_ops);
 	if (err)
 		die("error registering pl script extension");
 
 	scripting_context = malloc(sizeof(struct scripting_context));
 }
+
+#ifdef NO_LIBPERL
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_unsupported_ops);
+}
+#else
+void setup_perl_scripting(void)
+{
+	register_perl_scripting(&perl_scripting_ops);
+}
 #endif
Applied
#7 lore raw
In reply to Tom Zanussi
Quoted 4 lines · Tom Zanussi

One fixes a compile error when libperl isn't installed, the other fixes an annoying message about scripting being unsupported even when the perf trace cmd isn't trying to use scripting.

Quoted 8 lines

Tom Zanussi (2):
perf trace/scripting: Fix compile err when libperl not installed perf trace/scripting: Don't display 'scripting unsupported' msg
unnecessarily

 tools/perf/util/trace-event-perl.c |   67 +++++++++++++++++++++++++++++------
 tools/perf/util/trace-event-perl.h |    4 ++
 2 files changed, 59 insertions(+), 12 deletions(-)

Applied, thanks a lot Tom!

( Note, i already applied patch #1 out of your previous email - this
version has the same content, right? )

Ingo

#8 lore raw
Quoted 11 lines · Ingo Molnar
Quoted 9 lines · Tom Zanussi

One fixes a compile error when libperl isn't installed, the other fixes an annoying message about scripting being unsupported even when the perf trace cmd isn't trying to use scripting.

Tom Zanussi (2):
perf trace/scripting: Fix compile err when libperl not installed perf trace/scripting: Don't display 'scripting unsupported' msg
unnecessarily

Quoted 9 lines
Quoted 3 lines
 tools/perf/util/trace-event-perl.c |   67 +++++++++++++++++++++++++++++------
 tools/perf/util/trace-event-perl.h |    4 ++
 2 files changed, 59 insertions(+), 12 deletions(-)

Applied, thanks a lot Tom!

( Note, i already applied patch #1 out of your previous email - this
version has the same content, right? )

Yeah, it's the same.

Thanks,

Tom

Quoted 1 line

Ingo