public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] perf: Make perf stat/record print fatal signals of the target program
@ 2011-09-15 21:31 Andi Kleen
  2011-09-15 21:31 ` [PATCH 2/3] perf: Support setting the disassembler style Andi Kleen
  2011-09-15 21:31 ` [PATCH 3/3] perf: Clarify -c help text Andi Kleen
  0 siblings, 2 replies; 4+ messages in thread
From: Andi Kleen @ 2011-09-15 21:31 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, fweisbec, eranian, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

When a program crashes under perf there is no message about it,
unlike when running it from bash. This can be confusing and lead
to wrong actions during debugging.

Print fatal signals in perf stat/record.

Thanks to Furat Afram for finding the problem originally

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/builtin-record.c |   19 +++++++++++++++++--
 tools/perf/builtin-stat.c   |    2 ++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6b0519f..042117f 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -73,6 +73,7 @@ static off_t			post_processing_offset;
 
 static struct perf_session	*session;
 static const char		*cpu_list;
+static const char               *progname;
 
 static void advance_output(size_t size)
 {
@@ -137,17 +138,29 @@ static void mmap_read(struct perf_mmap *md)
 
 static volatile int done = 0;
 static volatile int signr = -1;
+static volatile int child_finished = 0;
 
 static void sig_handler(int sig)
 {
+	if (sig == SIGCHLD)
+		child_finished = 1;
+
 	done = 1;
 	signr = sig;
 }
 
 static void sig_atexit(void)
 {
-	if (child_pid > 0)
-		kill(child_pid, SIGTERM);
+	int status;
+
+	if (child_pid > 0) {
+		if (!child_finished)
+			kill(child_pid, SIGTERM);
+
+		wait(&status);
+		if (WIFSIGNALED(status))
+			psignal(WTERMSIG(status), progname);
+	}
 
 	if (signr == -1 || signr == SIGUSR1)
 		return;
@@ -445,6 +458,8 @@ static int __cmd_record(int argc, const char **argv)
 	char buf;
 	struct machine *machine;
 
+	progname = argv[0];
+
 	page_size = sysconf(_SC_PAGE_SIZE);
 
 	atexit(sig_atexit);
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 5deb17d..69becc3 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -487,6 +487,8 @@ static int run_perf_stat(int argc __used, const char **argv)
 	if (forks) {
 		close(go_pipe[1]);
 		wait(&status);
+		if (WIFSIGNALED(status))
+			psignal(WTERMSIG(status), argv[0]);
 	} else {
 		while(!done) sleep(1);
 	}
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] perf: Support setting the disassembler style
  2011-09-15 21:31 [PATCH 1/3] perf: Make perf stat/record print fatal signals of the target program Andi Kleen
@ 2011-09-15 21:31 ` Andi Kleen
  2011-09-16 14:27   ` Arnaldo Carvalho de Melo
  2011-09-15 21:31 ` [PATCH 3/3] perf: Clarify -c help text Andi Kleen
  1 sibling, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2011-09-15 21:31 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, fweisbec, eranian, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Add -M option to report/annotate to pass directly to objdump.
This allows to use -M intel for intel style disassembler syntax,
which is useful for people who are very used to the Intel syntax.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/Documentation/perf-annotate.txt |    3 +++
 tools/perf/Documentation/perf-report.txt   |    3 +++
 tools/perf/builtin-annotate.c              |    2 ++
 tools/perf/builtin-report.c                |    2 ++
 tools/perf/util/annotate.c                 |    6 +++++-
 tools/perf/util/annotate.h                 |    2 ++
 6 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 85c5f02..4a42c31 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -72,6 +72,9 @@ OPTIONS
 	CPUs are specified with -: 0-2. Default is to report samples on all
 	CPUs.
 
+-M::
+--disassembler-style=:: Set disassembler style for objdump.
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 04253c0..0407c8c 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -134,6 +134,9 @@ OPTIONS
 	CPUs are specified with -: 0-2. Default is to report samples on all
 	CPUs.
 
+-m::
+--disassembler-style=:: Set disassembler style for objdump.
+
 SEE ALSO
 --------
 linkperf:perf-stat[1]
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 555aefd..5b0a0ac 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -267,6 +267,8 @@ static const struct option options[] = {
 	OPT_BOOLEAN('P', "full-paths", &full_paths,
 		    "Don't shorten the displayed pathnames"),
 	OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
+	OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
+		   "Specify disassembler style (e.g. -M intel for intel syntax)"),
 	OPT_END()
 };
 
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d7ff277..a0673ee 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -487,6 +487,8 @@ static const struct option options[] = {
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
 		    "Look for files with symbols relative to this directory"),
 	OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
+	OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
+		   "Specify disassembler style (e.g. -M intel for intel syntax)"),
 	OPT_END()
 };
 
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e01af2b..6495966 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -16,6 +16,8 @@
 #include "annotate.h"
 #include <pthread.h>
 
+const char 	*disassembler_style;
+
 int symbol__annotate_init(struct map *map __used, struct symbol *sym)
 {
 	struct annotation *notes = symbol__annotation(sym);
@@ -323,8 +325,10 @@ fallback:
 		 dso, dso->long_name, sym, sym->name);
 
 	snprintf(command, sizeof(command),
-		 "objdump --start-address=0x%016" PRIx64
+		 "objdump %s%s --start-address=0x%016" PRIx64
 		 " --stop-address=0x%016" PRIx64 " -dS -C %s|grep -v %s|expand",
+		 disassembler_style ? "-M " : "",
+		 disassembler_style ? disassembler_style : "",
 		 map__rip_2objdump(map, sym->start),
 		 map__rip_2objdump(map, sym->end),
 		 symfs_filename, filename);
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index c2c2868..6ede128 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -100,4 +100,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
 			 int refresh);
 #endif
 
+extern const char	*disassembler_style;
+
 #endif	/* __PERF_ANNOTATE_H */
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] perf: Clarify -c help text
  2011-09-15 21:31 [PATCH 1/3] perf: Make perf stat/record print fatal signals of the target program Andi Kleen
  2011-09-15 21:31 ` [PATCH 2/3] perf: Support setting the disassembler style Andi Kleen
@ 2011-09-15 21:31 ` Andi Kleen
  1 sibling, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2011-09-15 21:31 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, fweisbec, eranian, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Clarify what perf record/top -c actually does in the help text.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 tools/perf/Documentation/perf-record.txt |    6 +++---
 tools/perf/Documentation/perf-top.txt    |    2 +-
 tools/perf/builtin-record.c              |    2 +-
 tools/perf/builtin-top.c                 |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 5a520f8..f636cc8 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -72,9 +72,9 @@ OPTIONS
 --force::
 	Overwrite existing data file. (deprecated)
 
--c::
---count=::
-	Event period to sample.
+-cN::
+--count=N::
+	Sample event every N occurrences.
 
 -o::
 --output=::
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index f6eb1cd..b6043b0 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -23,7 +23,7 @@ OPTIONS
 
 -c <count>::
 --count=<count>::
-	Event period to sample.
+	Sample event every COUNT occurrences.
 
 -C <cpu-list>::
 --cpu=<cpu>::
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 042117f..22a9a27 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -761,7 +761,7 @@ const struct option record_options[] = {
 		    "list of cpus to monitor"),
 	OPT_BOOLEAN('f', "force", &force,
 			"overwrite existing data file (deprecated)"),
-	OPT_U64('c', "count", &user_interval, "event period to sample"),
+	OPT_U64('c', "count", &user_interval, "sample every COUNTS events"),
 	OPT_STRING('o', "output", &output_name, "file",
 		    "output file name"),
 	OPT_BOOLEAN('i', "no-inherit", &no_inherit,
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index a43433f..79bfb5d 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -992,7 +992,7 @@ static const struct option options[] = {
 		     "event selector. use 'perf list' to list available events",
 		     parse_events_option),
 	OPT_INTEGER('c', "count", &default_interval,
-		    "event period to sample"),
+		    "sample event every N occurrences"),
 	OPT_INTEGER('p', "pid", &top.target_pid,
 		    "profile events on existing process id"),
 	OPT_INTEGER('t', "tid", &top.target_tid,
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] perf: Support setting the disassembler style
  2011-09-15 21:31 ` [PATCH 2/3] perf: Support setting the disassembler style Andi Kleen
@ 2011-09-16 14:27   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2011-09-16 14:27 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel, fweisbec, eranian, Andi Kleen

Em Thu, Sep 15, 2011 at 02:31:41PM -0700, Andi Kleen escreveu:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Add -M option to report/annotate to pass directly to objdump.
> This allows to use -M intel for intel style disassembler syntax,
> which is useful for people who are very used to the Intel syntax.
 
>  linkperf:perf-record[1], linkperf:perf-report[1]
> diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
> index 04253c0..0407c8c 100644
> --- a/tools/perf/Documentation/perf-report.txt
> +++ b/tools/perf/Documentation/perf-report.txt
> @@ -134,6 +134,9 @@ OPTIONS
>  	CPUs are specified with -: 0-2. Default is to report samples on all
>  	CPUs.
>  
> +-m::
> +--disassembler-style=:: Set disassembler style for objdump.
> +

s/-m/-M/g

And adjusted it to cope with what is in perf/core, namely:

https://github.com/acmel/linux/commit/3e6a2a7f3b9d0e521bb3284573b696d0cbe1952c

<quote>
perf annotate: Make output more readable
This patch adds two new options to perf annotate:
	- --no-asm-raw : Do not display raw instruction encodings
	- --no-source  : Do not interleave source code with assembly
	  code

We believe those options make the output of annotate more readable.
</>

- Arnaldo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-16 14:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-15 21:31 [PATCH 1/3] perf: Make perf stat/record print fatal signals of the target program Andi Kleen
2011-09-15 21:31 ` [PATCH 2/3] perf: Support setting the disassembler style Andi Kleen
2011-09-16 14:27   ` Arnaldo Carvalho de Melo
2011-09-15 21:31 ` [PATCH 3/3] perf: Clarify -c help text Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox