diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Makefile | 40 | ||||
-rw-r--r-- | tools/perf/arch/arm/Makefile | 4 | ||||
-rw-r--r-- | tools/perf/arch/arm/util/dwarf-regs.c | 64 | ||||
-rw-r--r-- | tools/perf/arch/sparc/Makefile | 4 | ||||
-rw-r--r-- | tools/perf/arch/sparc/util/dwarf-regs.c | 43 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 2 | ||||
-rwxr-xr-x | tools/perf/util/PERF-VERSION-GEN | 17 | ||||
-rw-r--r-- | tools/perf/util/callchain.c | 35 | ||||
-rw-r--r-- | tools/perf/util/callchain.h | 5 | ||||
-rw-r--r-- | tools/perf/util/event.c | 4 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 29 | ||||
-rw-r--r-- | tools/perf/util/newt.c | 15 | ||||
-rw-r--r-- | tools/perf/util/session.c | 11 | ||||
-rw-r--r-- | tools/perf/util/session.h | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 17 | ||||
-rw-r--r-- | tools/perf/util/thread.c | 11 | ||||
-rw-r--r-- | tools/perf/util/thread.h | 5 |
18 files changed, 244 insertions, 66 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 3d8f31ed771d..d75c28a825f5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile | |||
@@ -600,30 +600,32 @@ endif | |||
600 | 600 | ||
601 | ifdef NO_DEMANGLE | 601 | ifdef NO_DEMANGLE |
602 | BASIC_CFLAGS += -DNO_DEMANGLE | 602 | BASIC_CFLAGS += -DNO_DEMANGLE |
603 | else ifdef HAVE_CPLUS_DEMANGLE | ||
604 | EXTLIBS += -liberty | ||
605 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | ||
606 | else | 603 | else |
607 | has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") | 604 | ifdef HAVE_CPLUS_DEMANGLE |
608 | 605 | EXTLIBS += -liberty | |
609 | ifeq ($(has_bfd),y) | 606 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE |
610 | EXTLIBS += -lbfd | ||
611 | else | 607 | else |
612 | has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") | 608 | has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd "$(QUIET_STDERR)" && echo y") |
613 | ifeq ($(has_bfd_iberty),y) | 609 | |
614 | EXTLIBS += -lbfd -liberty | 610 | ifeq ($(has_bfd),y) |
611 | EXTLIBS += -lbfd | ||
615 | else | 612 | else |
616 | has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") | 613 | has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty "$(QUIET_STDERR)" && echo y") |
617 | ifeq ($(has_bfd_iberty_z),y) | 614 | ifeq ($(has_bfd_iberty),y) |
618 | EXTLIBS += -lbfd -liberty -lz | 615 | EXTLIBS += -lbfd -liberty |
619 | else | 616 | else |
620 | has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") | 617 | has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -lbfd -liberty -lz "$(QUIET_STDERR)" && echo y") |
621 | ifeq ($(has_cplus_demangle),y) | 618 | ifeq ($(has_bfd_iberty_z),y) |
622 | EXTLIBS += -liberty | 619 | EXTLIBS += -lbfd -liberty -lz |
623 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | ||
624 | else | 620 | else |
625 | msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) | 621 | has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o $(BITBUCKET) $(ALL_LDFLAGS) $(EXTLIBS) -liberty "$(QUIET_STDERR)" && echo y") |
626 | BASIC_CFLAGS += -DNO_DEMANGLE | 622 | ifeq ($(has_cplus_demangle),y) |
623 | EXTLIBS += -liberty | ||
624 | BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE | ||
625 | else | ||
626 | msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) | ||
627 | BASIC_CFLAGS += -DNO_DEMANGLE | ||
628 | endif | ||
627 | endif | 629 | endif |
628 | endif | 630 | endif |
629 | endif | 631 | endif |
diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile new file mode 100644 index 000000000000..15130b50dfe3 --- /dev/null +++ b/tools/perf/arch/arm/Makefile | |||
@@ -0,0 +1,4 @@ | |||
1 | ifndef NO_DWARF | ||
2 | PERF_HAVE_DWARF_REGS := 1 | ||
3 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o | ||
4 | endif | ||
diff --git a/tools/perf/arch/arm/util/dwarf-regs.c b/tools/perf/arch/arm/util/dwarf-regs.c new file mode 100644 index 000000000000..fff6450c8c99 --- /dev/null +++ b/tools/perf/arch/arm/util/dwarf-regs.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * Mapping of DWARF debug register numbers into register names. | ||
3 | * | ||
4 | * Copyright (C) 2010 Will Deacon, ARM Ltd. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <libio.h> | ||
12 | #include <dwarf-regs.h> | ||
13 | |||
14 | struct pt_regs_dwarfnum { | ||
15 | const char *name; | ||
16 | unsigned int dwarfnum; | ||
17 | }; | ||
18 | |||
19 | #define STR(s) #s | ||
20 | #define REG_DWARFNUM_NAME(r, num) {.name = r, .dwarfnum = num} | ||
21 | #define GPR_DWARFNUM_NAME(num) \ | ||
22 | {.name = STR(%r##num), .dwarfnum = num} | ||
23 | #define REG_DWARFNUM_END {.name = NULL, .dwarfnum = 0} | ||
24 | |||
25 | /* | ||
26 | * Reference: | ||
27 | * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040a/IHI0040A_aadwarf.pdf | ||
28 | */ | ||
29 | static const struct pt_regs_dwarfnum regdwarfnum_table[] = { | ||
30 | GPR_DWARFNUM_NAME(0), | ||
31 | GPR_DWARFNUM_NAME(1), | ||
32 | GPR_DWARFNUM_NAME(2), | ||
33 | GPR_DWARFNUM_NAME(3), | ||
34 | GPR_DWARFNUM_NAME(4), | ||
35 | GPR_DWARFNUM_NAME(5), | ||
36 | GPR_DWARFNUM_NAME(6), | ||
37 | GPR_DWARFNUM_NAME(7), | ||
38 | GPR_DWARFNUM_NAME(8), | ||
39 | GPR_DWARFNUM_NAME(9), | ||
40 | GPR_DWARFNUM_NAME(10), | ||
41 | REG_DWARFNUM_NAME("%fp", 11), | ||
42 | REG_DWARFNUM_NAME("%ip", 12), | ||
43 | REG_DWARFNUM_NAME("%sp", 13), | ||
44 | REG_DWARFNUM_NAME("%lr", 14), | ||
45 | REG_DWARFNUM_NAME("%pc", 15), | ||
46 | REG_DWARFNUM_END, | ||
47 | }; | ||
48 | |||
49 | /** | ||
50 | * get_arch_regstr() - lookup register name from it's DWARF register number | ||
51 | * @n: the DWARF register number | ||
52 | * | ||
53 | * get_arch_regstr() returns the name of the register in struct | ||
54 | * regdwarfnum_table from it's DWARF register number. If the register is not | ||
55 | * found in the table, this returns NULL; | ||
56 | */ | ||
57 | const char *get_arch_regstr(unsigned int n) | ||
58 | { | ||
59 | const struct pt_regs_dwarfnum *roff; | ||
60 | for (roff = regdwarfnum_table; roff->name != NULL; roff++) | ||
61 | if (roff->dwarfnum == n) | ||
62 | return roff->name; | ||
63 | return NULL; | ||
64 | } | ||
diff --git a/tools/perf/arch/sparc/Makefile b/tools/perf/arch/sparc/Makefile new file mode 100644 index 000000000000..15130b50dfe3 --- /dev/null +++ b/tools/perf/arch/sparc/Makefile | |||
@@ -0,0 +1,4 @@ | |||
1 | ifndef NO_DWARF | ||
2 | PERF_HAVE_DWARF_REGS := 1 | ||
3 | LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o | ||
4 | endif | ||
diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c new file mode 100644 index 000000000000..0ab88483720c --- /dev/null +++ b/tools/perf/arch/sparc/util/dwarf-regs.c | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Mapping of DWARF debug register numbers into register names. | ||
3 | * | ||
4 | * Copyright (C) 2010 David S. Miller <davem@davemloft.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <libio.h> | ||
13 | #include <dwarf-regs.h> | ||
14 | |||
15 | #define SPARC_MAX_REGS 96 | ||
16 | |||
17 | const char *sparc_regs_table[SPARC_MAX_REGS] = { | ||
18 | "%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", | ||
19 | "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", | ||
20 | "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", | ||
21 | "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", | ||
22 | "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", | ||
23 | "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", | ||
24 | "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", | ||
25 | "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", | ||
26 | "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", | ||
27 | "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", | ||
28 | "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", | ||
29 | "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", | ||
30 | }; | ||
31 | |||
32 | /** | ||
33 | * get_arch_regstr() - lookup register name from it's DWARF register number | ||
34 | * @n: the DWARF register number | ||
35 | * | ||
36 | * get_arch_regstr() returns the name of the register in struct | ||
37 | * regdwarfnum_table from it's DWARF register number. If the register is not | ||
38 | * found in the table, this returns NULL; | ||
39 | */ | ||
40 | const char *get_arch_regstr(unsigned int n) | ||
41 | { | ||
42 | return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL; | ||
43 | } | ||
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index dc3435e18bde..711745f56bba 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -193,7 +193,7 @@ static void sig_handler(int sig) | |||
193 | 193 | ||
194 | static void sig_atexit(void) | 194 | static void sig_atexit(void) |
195 | { | 195 | { |
196 | if (child_pid != -1) | 196 | if (child_pid > 0) |
197 | kill(child_pid, SIGTERM); | 197 | kill(child_pid, SIGTERM); |
198 | 198 | ||
199 | if (signr == -1) | 199 | if (signr == -1) |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 359205782964..fd7407c7205c 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -107,7 +107,7 @@ static int perf_session__add_hist_entry(struct perf_session *self, | |||
107 | goto out_free_syms; | 107 | goto out_free_syms; |
108 | err = 0; | 108 | err = 0; |
109 | if (symbol_conf.use_callchain) { | 109 | if (symbol_conf.use_callchain) { |
110 | err = append_chain(he->callchain, data->callchain, syms); | 110 | err = append_chain(he->callchain, data->callchain, syms, data->period); |
111 | if (err) | 111 | if (err) |
112 | goto out_free_syms; | 112 | goto out_free_syms; |
113 | } | 113 | } |
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 49ece7921914..97d76562a1a0 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN | |||
@@ -5,17 +5,13 @@ if [ $# -eq 1 ] ; then | |||
5 | fi | 5 | fi |
6 | 6 | ||
7 | GVF=${OUTPUT}PERF-VERSION-FILE | 7 | GVF=${OUTPUT}PERF-VERSION-FILE |
8 | DEF_VER=v0.0.2.PERF | ||
9 | 8 | ||
10 | LF=' | 9 | LF=' |
11 | ' | 10 | ' |
12 | 11 | ||
13 | # First see if there is a version file (included in release tarballs), | 12 | # First check if there is a .git to get the version from git describe |
14 | # then try git-describe, then default. | 13 | # otherwise try to get the version from the kernel makefile |
15 | if test -f version | 14 | if test -d ../../.git -o -f ../../.git && |
16 | then | ||
17 | VN=$(cat version) || VN="$DEF_VER" | ||
18 | elif test -d .git -o -f .git && | ||
19 | VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && | 15 | VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && |
20 | case "$VN" in | 16 | case "$VN" in |
21 | *$LF*) (exit 1) ;; | 17 | *$LF*) (exit 1) ;; |
@@ -27,7 +23,12 @@ elif test -d .git -o -f .git && | |||
27 | then | 23 | then |
28 | VN=$(echo "$VN" | sed -e 's/-/./g'); | 24 | VN=$(echo "$VN" | sed -e 's/-/./g'); |
29 | else | 25 | else |
30 | VN="$DEF_VER" | 26 | eval `grep '^VERSION\s*=' ../../Makefile|tr -d ' '` |
27 | eval `grep '^PATCHLEVEL\s*=' ../../Makefile|tr -d ' '` | ||
28 | eval `grep '^SUBLEVEL\s*=' ../../Makefile|tr -d ' '` | ||
29 | eval `grep '^EXTRAVERSION\s*=' ../../Makefile|tr -d ' '` | ||
30 | |||
31 | VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}" | ||
31 | fi | 32 | fi |
32 | 33 | ||
33 | VN=$(expr "$VN" : v*'\(.*\)') | 34 | VN=$(expr "$VN" : v*'\(.*\)') |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 62b69ad4aa73..52c777e451ed 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -230,7 +230,7 @@ fill_node(struct callchain_node *node, struct resolved_chain *chain, int start) | |||
230 | 230 | ||
231 | static void | 231 | static void |
232 | add_child(struct callchain_node *parent, struct resolved_chain *chain, | 232 | add_child(struct callchain_node *parent, struct resolved_chain *chain, |
233 | int start) | 233 | int start, u64 period) |
234 | { | 234 | { |
235 | struct callchain_node *new; | 235 | struct callchain_node *new; |
236 | 236 | ||
@@ -238,7 +238,7 @@ add_child(struct callchain_node *parent, struct resolved_chain *chain, | |||
238 | fill_node(new, chain, start); | 238 | fill_node(new, chain, start); |
239 | 239 | ||
240 | new->children_hit = 0; | 240 | new->children_hit = 0; |
241 | new->hit = 1; | 241 | new->hit = period; |
242 | } | 242 | } |
243 | 243 | ||
244 | /* | 244 | /* |
@@ -248,7 +248,8 @@ add_child(struct callchain_node *parent, struct resolved_chain *chain, | |||
248 | */ | 248 | */ |
249 | static void | 249 | static void |
250 | split_add_child(struct callchain_node *parent, struct resolved_chain *chain, | 250 | split_add_child(struct callchain_node *parent, struct resolved_chain *chain, |
251 | struct callchain_list *to_split, int idx_parents, int idx_local) | 251 | struct callchain_list *to_split, int idx_parents, int idx_local, |
252 | u64 period) | ||
252 | { | 253 | { |
253 | struct callchain_node *new; | 254 | struct callchain_node *new; |
254 | struct list_head *old_tail; | 255 | struct list_head *old_tail; |
@@ -275,41 +276,41 @@ split_add_child(struct callchain_node *parent, struct resolved_chain *chain, | |||
275 | /* create a new child for the new branch if any */ | 276 | /* create a new child for the new branch if any */ |
276 | if (idx_total < chain->nr) { | 277 | if (idx_total < chain->nr) { |
277 | parent->hit = 0; | 278 | parent->hit = 0; |
278 | add_child(parent, chain, idx_total); | 279 | add_child(parent, chain, idx_total, period); |
279 | parent->children_hit++; | 280 | parent->children_hit += period; |
280 | } else { | 281 | } else { |
281 | parent->hit = 1; | 282 | parent->hit = period; |
282 | } | 283 | } |
283 | } | 284 | } |
284 | 285 | ||
285 | static int | 286 | static int |
286 | __append_chain(struct callchain_node *root, struct resolved_chain *chain, | 287 | __append_chain(struct callchain_node *root, struct resolved_chain *chain, |
287 | unsigned int start); | 288 | unsigned int start, u64 period); |
288 | 289 | ||
289 | static void | 290 | static void |
290 | __append_chain_children(struct callchain_node *root, | 291 | __append_chain_children(struct callchain_node *root, |
291 | struct resolved_chain *chain, | 292 | struct resolved_chain *chain, |
292 | unsigned int start) | 293 | unsigned int start, u64 period) |
293 | { | 294 | { |
294 | struct callchain_node *rnode; | 295 | struct callchain_node *rnode; |
295 | 296 | ||
296 | /* lookup in childrens */ | 297 | /* lookup in childrens */ |
297 | chain_for_each_child(rnode, root) { | 298 | chain_for_each_child(rnode, root) { |
298 | unsigned int ret = __append_chain(rnode, chain, start); | 299 | unsigned int ret = __append_chain(rnode, chain, start, period); |
299 | 300 | ||
300 | if (!ret) | 301 | if (!ret) |
301 | goto inc_children_hit; | 302 | goto inc_children_hit; |
302 | } | 303 | } |
303 | /* nothing in children, add to the current node */ | 304 | /* nothing in children, add to the current node */ |
304 | add_child(root, chain, start); | 305 | add_child(root, chain, start, period); |
305 | 306 | ||
306 | inc_children_hit: | 307 | inc_children_hit: |
307 | root->children_hit++; | 308 | root->children_hit += period; |
308 | } | 309 | } |
309 | 310 | ||
310 | static int | 311 | static int |
311 | __append_chain(struct callchain_node *root, struct resolved_chain *chain, | 312 | __append_chain(struct callchain_node *root, struct resolved_chain *chain, |
312 | unsigned int start) | 313 | unsigned int start, u64 period) |
313 | { | 314 | { |
314 | struct callchain_list *cnode; | 315 | struct callchain_list *cnode; |
315 | unsigned int i = start; | 316 | unsigned int i = start; |
@@ -345,18 +346,18 @@ __append_chain(struct callchain_node *root, struct resolved_chain *chain, | |||
345 | 346 | ||
346 | /* we match only a part of the node. Split it and add the new chain */ | 347 | /* we match only a part of the node. Split it and add the new chain */ |
347 | if (i - start < root->val_nr) { | 348 | if (i - start < root->val_nr) { |
348 | split_add_child(root, chain, cnode, start, i - start); | 349 | split_add_child(root, chain, cnode, start, i - start, period); |
349 | return 0; | 350 | return 0; |
350 | } | 351 | } |
351 | 352 | ||
352 | /* we match 100% of the path, increment the hit */ | 353 | /* we match 100% of the path, increment the hit */ |
353 | if (i - start == root->val_nr && i == chain->nr) { | 354 | if (i - start == root->val_nr && i == chain->nr) { |
354 | root->hit++; | 355 | root->hit += period; |
355 | return 0; | 356 | return 0; |
356 | } | 357 | } |
357 | 358 | ||
358 | /* We match the node and still have a part remaining */ | 359 | /* We match the node and still have a part remaining */ |
359 | __append_chain_children(root, chain, i); | 360 | __append_chain_children(root, chain, i, period); |
360 | 361 | ||
361 | return 0; | 362 | return 0; |
362 | } | 363 | } |
@@ -380,7 +381,7 @@ static void filter_context(struct ip_callchain *old, struct resolved_chain *new, | |||
380 | 381 | ||
381 | 382 | ||
382 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, | 383 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, |
383 | struct map_symbol *syms) | 384 | struct map_symbol *syms, u64 period) |
384 | { | 385 | { |
385 | struct resolved_chain *filtered; | 386 | struct resolved_chain *filtered; |
386 | 387 | ||
@@ -397,7 +398,7 @@ int append_chain(struct callchain_node *root, struct ip_callchain *chain, | |||
397 | if (!filtered->nr) | 398 | if (!filtered->nr) |
398 | goto end; | 399 | goto end; |
399 | 400 | ||
400 | __append_chain_children(root, filtered, 0); | 401 | __append_chain_children(root, filtered, 0, period); |
401 | end: | 402 | end: |
402 | free(filtered); | 403 | free(filtered); |
403 | 404 | ||
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 1ca73e4a2723..f2e9ee164bd8 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
@@ -49,6 +49,9 @@ static inline void callchain_init(struct callchain_node *node) | |||
49 | INIT_LIST_HEAD(&node->brothers); | 49 | INIT_LIST_HEAD(&node->brothers); |
50 | INIT_LIST_HEAD(&node->children); | 50 | INIT_LIST_HEAD(&node->children); |
51 | INIT_LIST_HEAD(&node->val); | 51 | INIT_LIST_HEAD(&node->val); |
52 | |||
53 | node->parent = NULL; | ||
54 | node->hit = 0; | ||
52 | } | 55 | } |
53 | 56 | ||
54 | static inline u64 cumul_hits(struct callchain_node *node) | 57 | static inline u64 cumul_hits(struct callchain_node *node) |
@@ -58,7 +61,7 @@ static inline u64 cumul_hits(struct callchain_node *node) | |||
58 | 61 | ||
59 | int register_callchain_param(struct callchain_param *param); | 62 | int register_callchain_param(struct callchain_param *param); |
60 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, | 63 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, |
61 | struct map_symbol *syms); | 64 | struct map_symbol *syms, u64 period); |
62 | 65 | ||
63 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); | 66 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); |
64 | #endif /* __PERF_CALLCHAIN_H */ | 67 | #endif /* __PERF_CALLCHAIN_H */ |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 1f08f008d289..2fbf6a463c81 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -538,8 +538,10 @@ int event__process_task(event_t *self, struct perf_session *session) | |||
538 | dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, | 538 | dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid, |
539 | self->fork.ppid, self->fork.ptid); | 539 | self->fork.ppid, self->fork.ptid); |
540 | 540 | ||
541 | if (self->header.type == PERF_RECORD_EXIT) | 541 | if (self->header.type == PERF_RECORD_EXIT) { |
542 | perf_session__remove_thread(session, thread); | ||
542 | return 0; | 543 | return 0; |
544 | } | ||
543 | 545 | ||
544 | if (thread == NULL || parent == NULL || | 546 | if (thread == NULL || parent == NULL || |
545 | thread__fork(thread, parent) < 0) { | 547 | thread__fork(thread, parent) < 0) { |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 07f89b66b318..784ee0bdda77 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -631,9 +631,14 @@ int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists, | |||
631 | u64 session_total) | 631 | u64 session_total) |
632 | { | 632 | { |
633 | char bf[512]; | 633 | char bf[512]; |
634 | hist_entry__snprintf(self, bf, sizeof(bf), pair_hists, | 634 | int ret; |
635 | show_displacement, displacement, | 635 | |
636 | true, session_total); | 636 | ret = hist_entry__snprintf(self, bf, sizeof(bf), pair_hists, |
637 | show_displacement, displacement, | ||
638 | true, session_total); | ||
639 | if (!ret) | ||
640 | return 0; | ||
641 | |||
637 | return fprintf(fp, "%s\n", bf); | 642 | return fprintf(fp, "%s\n", bf); |
638 | } | 643 | } |
639 | 644 | ||
@@ -762,6 +767,7 @@ size_t hists__fprintf(struct hists *self, struct hists *pair, | |||
762 | print_entries: | 767 | print_entries: |
763 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { | 768 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { |
764 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 769 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
770 | int cnt; | ||
765 | 771 | ||
766 | if (show_displacement) { | 772 | if (show_displacement) { |
767 | if (h->pair != NULL) | 773 | if (h->pair != NULL) |
@@ -771,8 +777,13 @@ print_entries: | |||
771 | displacement = 0; | 777 | displacement = 0; |
772 | ++position; | 778 | ++position; |
773 | } | 779 | } |
774 | ret += hist_entry__fprintf(h, pair, show_displacement, | 780 | cnt = hist_entry__fprintf(h, pair, show_displacement, |
775 | displacement, fp, self->stats.total_period); | 781 | displacement, fp, self->stats.total_period); |
782 | /* Ignore those that didn't match the parent filter */ | ||
783 | if (!cnt) | ||
784 | continue; | ||
785 | |||
786 | ret += cnt; | ||
776 | 787 | ||
777 | if (symbol_conf.use_callchain) | 788 | if (symbol_conf.use_callchain) |
778 | ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period); | 789 | ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period); |
@@ -965,13 +976,17 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file, | |||
965 | * Parse hexa addresses followed by ':' | 976 | * Parse hexa addresses followed by ':' |
966 | */ | 977 | */ |
967 | line_ip = strtoull(tmp, &tmp2, 16); | 978 | line_ip = strtoull(tmp, &tmp2, 16); |
968 | if (*tmp2 != ':' || tmp == tmp2) | 979 | if (*tmp2 != ':' || tmp == tmp2 || tmp2[1] == '\0') |
969 | line_ip = -1; | 980 | line_ip = -1; |
970 | } | 981 | } |
971 | 982 | ||
972 | if (line_ip != -1) { | 983 | if (line_ip != -1) { |
973 | u64 start = map__rip_2objdump(self->ms.map, sym->start); | 984 | u64 start = map__rip_2objdump(self->ms.map, sym->start), |
985 | end = map__rip_2objdump(self->ms.map, sym->end); | ||
986 | |||
974 | offset = line_ip - start; | 987 | offset = line_ip - start; |
988 | if (offset < 0 || (u64)line_ip > end) | ||
989 | offset = -1; | ||
975 | } | 990 | } |
976 | 991 | ||
977 | objdump_line = objdump_line__new(offset, line); | 992 | objdump_line = objdump_line__new(offset, line); |
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index cf182ca132fe..7537ca15900b 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -43,6 +43,9 @@ struct ui_progress *ui_progress__new(const char *title, u64 total) | |||
43 | 43 | ||
44 | if (self != NULL) { | 44 | if (self != NULL) { |
45 | int cols; | 45 | int cols; |
46 | |||
47 | if (use_browser <= 0) | ||
48 | return self; | ||
46 | newtGetScreenSize(&cols, NULL); | 49 | newtGetScreenSize(&cols, NULL); |
47 | cols -= 4; | 50 | cols -= 4; |
48 | newtCenteredWindow(cols, 1, title); | 51 | newtCenteredWindow(cols, 1, title); |
@@ -67,14 +70,22 @@ out_free_self: | |||
67 | 70 | ||
68 | void ui_progress__update(struct ui_progress *self, u64 curr) | 71 | void ui_progress__update(struct ui_progress *self, u64 curr) |
69 | { | 72 | { |
73 | /* | ||
74 | * FIXME: We should have a per UI backend way of showing progress, | ||
75 | * stdio will just show a percentage as NN%, etc. | ||
76 | */ | ||
77 | if (use_browser <= 0) | ||
78 | return; | ||
70 | newtScaleSet(self->scale, curr); | 79 | newtScaleSet(self->scale, curr); |
71 | newtRefresh(); | 80 | newtRefresh(); |
72 | } | 81 | } |
73 | 82 | ||
74 | void ui_progress__delete(struct ui_progress *self) | 83 | void ui_progress__delete(struct ui_progress *self) |
75 | { | 84 | { |
76 | newtFormDestroy(self->form); | 85 | if (use_browser > 0) { |
77 | newtPopWindow(); | 86 | newtFormDestroy(self->form); |
87 | newtPopWindow(); | ||
88 | } | ||
78 | free(self); | 89 | free(self); |
79 | } | 90 | } |
80 | 91 | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 8f83a1835766..c422cd676313 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -90,6 +90,7 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc | |||
90 | 90 | ||
91 | memcpy(self->filename, filename, len); | 91 | memcpy(self->filename, filename, len); |
92 | self->threads = RB_ROOT; | 92 | self->threads = RB_ROOT; |
93 | INIT_LIST_HEAD(&self->dead_threads); | ||
93 | self->hists_tree = RB_ROOT; | 94 | self->hists_tree = RB_ROOT; |
94 | self->last_match = NULL; | 95 | self->last_match = NULL; |
95 | self->mmap_window = 32; | 96 | self->mmap_window = 32; |
@@ -131,6 +132,16 @@ void perf_session__delete(struct perf_session *self) | |||
131 | free(self); | 132 | free(self); |
132 | } | 133 | } |
133 | 134 | ||
135 | void perf_session__remove_thread(struct perf_session *self, struct thread *th) | ||
136 | { | ||
137 | rb_erase(&th->rb_node, &self->threads); | ||
138 | /* | ||
139 | * We may have references to this thread, for instance in some hist_entry | ||
140 | * instances, so just move them to a separate list. | ||
141 | */ | ||
142 | list_add_tail(&th->node, &self->dead_threads); | ||
143 | } | ||
144 | |||
134 | static bool symbol__match_parent_regex(struct symbol *sym) | 145 | static bool symbol__match_parent_regex(struct symbol *sym) |
135 | { | 146 | { |
136 | if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0)) | 147 | if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0)) |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 55c6881b218d..9fa0fc2a863f 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -26,6 +26,7 @@ struct perf_session { | |||
26 | unsigned long size; | 26 | unsigned long size; |
27 | unsigned long mmap_window; | 27 | unsigned long mmap_window; |
28 | struct rb_root threads; | 28 | struct rb_root threads; |
29 | struct list_head dead_threads; | ||
29 | struct thread *last_match; | 30 | struct thread *last_match; |
30 | struct machine host_machine; | 31 | struct machine host_machine; |
31 | struct rb_root machines; | 32 | struct rb_root machines; |
@@ -99,6 +100,7 @@ int perf_session__create_kernel_maps(struct perf_session *self); | |||
99 | 100 | ||
100 | int do_read(int fd, void *buf, size_t size); | 101 | int do_read(int fd, void *buf, size_t size); |
101 | void perf_session__update_sample_type(struct perf_session *self); | 102 | void perf_session__update_sample_type(struct perf_session *self); |
103 | void perf_session__remove_thread(struct perf_session *self, struct thread *th); | ||
102 | 104 | ||
103 | static inline | 105 | static inline |
104 | struct machine *perf_session__find_host_machine(struct perf_session *self) | 106 | struct machine *perf_session__find_host_machine(struct perf_session *self) |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b63e5713849f..5b276833e2bf 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, | |||
1443 | { | 1443 | { |
1444 | struct dirent *dent; | 1444 | struct dirent *dent; |
1445 | DIR *dir = opendir(dir_name); | 1445 | DIR *dir = opendir(dir_name); |
1446 | int ret = 0; | ||
1446 | 1447 | ||
1447 | if (!dir) { | 1448 | if (!dir) { |
1448 | pr_debug("%s: cannot open %s dir\n", __func__, dir_name); | 1449 | pr_debug("%s: cannot open %s dir\n", __func__, dir_name); |
@@ -1465,8 +1466,9 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, | |||
1465 | 1466 | ||
1466 | snprintf(path, sizeof(path), "%s/%s", | 1467 | snprintf(path, sizeof(path), "%s/%s", |
1467 | dir_name, dent->d_name); | 1468 | dir_name, dent->d_name); |
1468 | if (map_groups__set_modules_path_dir(self, path) < 0) | 1469 | ret = map_groups__set_modules_path_dir(self, path); |
1469 | goto failure; | 1470 | if (ret < 0) |
1471 | goto out; | ||
1470 | } else { | 1472 | } else { |
1471 | char *dot = strrchr(dent->d_name, '.'), | 1473 | char *dot = strrchr(dent->d_name, '.'), |
1472 | dso_name[PATH_MAX]; | 1474 | dso_name[PATH_MAX]; |
@@ -1487,17 +1489,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, | |||
1487 | dir_name, dent->d_name); | 1489 | dir_name, dent->d_name); |
1488 | 1490 | ||
1489 | long_name = strdup(path); | 1491 | long_name = strdup(path); |
1490 | if (long_name == NULL) | 1492 | if (long_name == NULL) { |
1491 | goto failure; | 1493 | ret = -1; |
1494 | goto out; | ||
1495 | } | ||
1492 | dso__set_long_name(map->dso, long_name); | 1496 | dso__set_long_name(map->dso, long_name); |
1493 | dso__kernel_module_get_build_id(map->dso, ""); | 1497 | dso__kernel_module_get_build_id(map->dso, ""); |
1494 | } | 1498 | } |
1495 | } | 1499 | } |
1496 | 1500 | ||
1497 | return 0; | 1501 | out: |
1498 | failure: | ||
1499 | closedir(dir); | 1502 | closedir(dir); |
1500 | return -1; | 1503 | return ret; |
1501 | } | 1504 | } |
1502 | 1505 | ||
1503 | static char *get_kernel_version(const char *root_dir) | 1506 | static char *get_kernel_version(const char *root_dir) |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 1f7ecd47f499..9a448b47400c 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -7,6 +7,15 @@ | |||
7 | #include "util.h" | 7 | #include "util.h" |
8 | #include "debug.h" | 8 | #include "debug.h" |
9 | 9 | ||
10 | /* Skip "." and ".." directories */ | ||
11 | static int filter(const struct dirent *dir) | ||
12 | { | ||
13 | if (dir->d_name[0] == '.') | ||
14 | return 0; | ||
15 | else | ||
16 | return 1; | ||
17 | } | ||
18 | |||
10 | int find_all_tid(int pid, pid_t ** all_tid) | 19 | int find_all_tid(int pid, pid_t ** all_tid) |
11 | { | 20 | { |
12 | char name[256]; | 21 | char name[256]; |
@@ -16,7 +25,7 @@ int find_all_tid(int pid, pid_t ** all_tid) | |||
16 | int i; | 25 | int i; |
17 | 26 | ||
18 | sprintf(name, "/proc/%d/task", pid); | 27 | sprintf(name, "/proc/%d/task", pid); |
19 | items = scandir(name, &namelist, NULL, NULL); | 28 | items = scandir(name, &namelist, filter, NULL); |
20 | if (items <= 0) | 29 | if (items <= 0) |
21 | return -ENOENT; | 30 | return -ENOENT; |
22 | *all_tid = malloc(sizeof(pid_t) * items); | 31 | *all_tid = malloc(sizeof(pid_t) * items); |
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 1dfd9ff8bdcd..ee6bbcf277ca 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -6,7 +6,10 @@ | |||
6 | #include "symbol.h" | 6 | #include "symbol.h" |
7 | 7 | ||
8 | struct thread { | 8 | struct thread { |
9 | struct rb_node rb_node; | 9 | union { |
10 | struct rb_node rb_node; | ||
11 | struct list_head node; | ||
12 | }; | ||
10 | struct map_groups mg; | 13 | struct map_groups mg; |
11 | pid_t pid; | 14 | pid_t pid; |
12 | char shortname[3]; | 15 | char shortname[3]; |