aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/Makefile1
-rw-r--r--tools/perf/builtin-stat.c1
-rw-r--r--tools/perf/config/feature-tests.mak2
-rw-r--r--tools/perf/util/dwarf-aux.c25
-rw-r--r--tools/perf/util/dwarf-aux.h6
-rw-r--r--tools/perf/util/header.c12
-rw-r--r--tools/perf/util/probe-finder.c49
-rw-r--r--tools/perf/util/session.c4
8 files changed, 77 insertions, 23 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 3a0ff7fb71b6..64c043b7a438 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -770,6 +770,7 @@ check: $(OUTPUT)common-cmds.h
770install-bin: all 770install-bin: all
771 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' 771 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
772 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)' 772 $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
773 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
773 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)' 774 $(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
774ifndef NO_LIBPERL 775ifndef NO_LIBPERL
775 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace' 776 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f686d5ff594e..5098f144b92d 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -457,6 +457,7 @@ static int __run_perf_stat(int argc, const char **argv)
457 perror("failed to prepare workload"); 457 perror("failed to prepare workload");
458 return -1; 458 return -1;
459 } 459 }
460 child_pid = evsel_list->workload.pid;
460 } 461 }
461 462
462 if (group) 463 if (group)
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
index d5a8dd44945f..f79305739ecc 100644
--- a/tools/perf/config/feature-tests.mak
+++ b/tools/perf/config/feature-tests.mak
@@ -219,7 +219,7 @@ define SOURCE_LIBAUDIT
219 219
220int main(void) 220int main(void)
221{ 221{
222 printf(\"error message: %s\n\", audit_errno_to_name(0)); 222 printf(\"error message: %s\", audit_errno_to_name(0));
223 return audit_open(); 223 return audit_open();
224} 224}
225endef 225endef
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index e23bde19d590..7defd77105d0 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -426,7 +426,7 @@ static int __die_search_func_cb(Dwarf_Die *fn_die, void *data)
426 * @die_mem: a buffer for result DIE 426 * @die_mem: a buffer for result DIE
427 * 427 *
428 * Search a non-inlined function DIE which includes @addr. Stores the 428 * Search a non-inlined function DIE which includes @addr. Stores the
429 * DIE to @die_mem and returns it if found. Returns NULl if failed. 429 * DIE to @die_mem and returns it if found. Returns NULL if failed.
430 */ 430 */
431Dwarf_Die *die_find_realfunc(Dwarf_Die *cu_die, Dwarf_Addr addr, 431Dwarf_Die *die_find_realfunc(Dwarf_Die *cu_die, Dwarf_Addr addr,
432 Dwarf_Die *die_mem) 432 Dwarf_Die *die_mem)
@@ -454,15 +454,32 @@ static int __die_find_inline_cb(Dwarf_Die *die_mem, void *data)
454} 454}
455 455
456/** 456/**
457 * die_find_top_inlinefunc - Search the top inlined function at given address
458 * @sp_die: a subprogram DIE which including @addr
459 * @addr: target address
460 * @die_mem: a buffer for result DIE
461 *
462 * Search an inlined function DIE which includes @addr. Stores the
463 * DIE to @die_mem and returns it if found. Returns NULL if failed.
464 * Even if several inlined functions are expanded recursively, this
465 * doesn't trace it down, and returns the topmost one.
466 */
467Dwarf_Die *die_find_top_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr,
468 Dwarf_Die *die_mem)
469{
470 return die_find_child(sp_die, __die_find_inline_cb, &addr, die_mem);
471}
472
473/**
457 * die_find_inlinefunc - Search an inlined function at given address 474 * die_find_inlinefunc - Search an inlined function at given address
458 * @cu_die: a CU DIE which including @addr 475 * @sp_die: a subprogram DIE which including @addr
459 * @addr: target address 476 * @addr: target address
460 * @die_mem: a buffer for result DIE 477 * @die_mem: a buffer for result DIE
461 * 478 *
462 * Search an inlined function DIE which includes @addr. Stores the 479 * Search an inlined function DIE which includes @addr. Stores the
463 * DIE to @die_mem and returns it if found. Returns NULl if failed. 480 * DIE to @die_mem and returns it if found. Returns NULL if failed.
464 * If several inlined functions are expanded recursively, this trace 481 * If several inlined functions are expanded recursively, this trace
465 * it and returns deepest one. 482 * it down and returns deepest one.
466 */ 483 */
467Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr, 484Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr,
468 Dwarf_Die *die_mem) 485 Dwarf_Die *die_mem)
diff --git a/tools/perf/util/dwarf-aux.h b/tools/perf/util/dwarf-aux.h
index 8658d41697d2..b4fe90c6cb2d 100644
--- a/tools/perf/util/dwarf-aux.h
+++ b/tools/perf/util/dwarf-aux.h
@@ -79,7 +79,11 @@ extern Dwarf_Die *die_find_child(Dwarf_Die *rt_die,
79extern Dwarf_Die *die_find_realfunc(Dwarf_Die *cu_die, Dwarf_Addr addr, 79extern Dwarf_Die *die_find_realfunc(Dwarf_Die *cu_die, Dwarf_Addr addr,
80 Dwarf_Die *die_mem); 80 Dwarf_Die *die_mem);
81 81
82/* Search an inlined function including given address */ 82/* Search the top inlined function including given address */
83extern Dwarf_Die *die_find_top_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr,
84 Dwarf_Die *die_mem);
85
86/* Search the deepest inlined function including given address */
83extern Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr, 87extern Dwarf_Die *die_find_inlinefunc(Dwarf_Die *sp_die, Dwarf_Addr addr,
84 Dwarf_Die *die_mem); 88 Dwarf_Die *die_mem);
85 89
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index ce69901176d8..c3e5a3b817ab 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2768,6 +2768,18 @@ int perf_session__read_header(struct perf_session *session)
2768 if (perf_file_header__read(&f_header, header, fd) < 0) 2768 if (perf_file_header__read(&f_header, header, fd) < 0)
2769 return -EINVAL; 2769 return -EINVAL;
2770 2770
2771 /*
2772 * Sanity check that perf.data was written cleanly; data size is
2773 * initialized to 0 and updated only if the on_exit function is run.
2774 * If data size is still 0 then the file contains only partial
2775 * information. Just warn user and process it as much as it can.
2776 */
2777 if (f_header.data.size == 0) {
2778 pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n"
2779 "Was the 'perf record' command properly terminated?\n",
2780 session->filename);
2781 }
2782
2771 nr_attrs = f_header.attrs.size / f_header.attr_size; 2783 nr_attrs = f_header.attrs.size / f_header.attr_size;
2772 lseek(fd, f_header.attrs.offset, SEEK_SET); 2784 lseek(fd, f_header.attrs.offset, SEEK_SET);
2773 2785
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 371476cb8ddc..c09e0a9fdf4c 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1327,8 +1327,8 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
1327 struct perf_probe_point *ppt) 1327 struct perf_probe_point *ppt)
1328{ 1328{
1329 Dwarf_Die cudie, spdie, indie; 1329 Dwarf_Die cudie, spdie, indie;
1330 Dwarf_Addr _addr, baseaddr; 1330 Dwarf_Addr _addr = 0, baseaddr = 0;
1331 const char *fname = NULL, *func = NULL, *tmp; 1331 const char *fname = NULL, *func = NULL, *basefunc = NULL, *tmp;
1332 int baseline = 0, lineno = 0, ret = 0; 1332 int baseline = 0, lineno = 0, ret = 0;
1333 1333
1334 /* Adjust address with bias */ 1334 /* Adjust address with bias */
@@ -1349,27 +1349,36 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
1349 /* Find a corresponding function (name, baseline and baseaddr) */ 1349 /* Find a corresponding function (name, baseline and baseaddr) */
1350 if (die_find_realfunc(&cudie, (Dwarf_Addr)addr, &spdie)) { 1350 if (die_find_realfunc(&cudie, (Dwarf_Addr)addr, &spdie)) {
1351 /* Get function entry information */ 1351 /* Get function entry information */
1352 tmp = dwarf_diename(&spdie); 1352 func = basefunc = dwarf_diename(&spdie);
1353 if (!tmp || 1353 if (!func ||
1354 dwarf_entrypc(&spdie, &baseaddr) != 0 || 1354 dwarf_entrypc(&spdie, &baseaddr) != 0 ||
1355 dwarf_decl_line(&spdie, &baseline) != 0) 1355 dwarf_decl_line(&spdie, &baseline) != 0) {
1356 lineno = 0;
1356 goto post; 1357 goto post;
1357 func = tmp; 1358 }
1358 1359
1359 if (addr == (unsigned long)baseaddr) 1360 if (addr == (unsigned long)baseaddr) {
1360 /* Function entry - Relative line number is 0 */ 1361 /* Function entry - Relative line number is 0 */
1361 lineno = baseline; 1362 lineno = baseline;
1362 else if (die_find_inlinefunc(&spdie, (Dwarf_Addr)addr, 1363 fname = dwarf_decl_file(&spdie);
1363 &indie)) { 1364 goto post;
1365 }
1366
1367 /* Track down the inline functions step by step */
1368 while (die_find_top_inlinefunc(&spdie, (Dwarf_Addr)addr,
1369 &indie)) {
1370 /* There is an inline function */
1364 if (dwarf_entrypc(&indie, &_addr) == 0 && 1371 if (dwarf_entrypc(&indie, &_addr) == 0 &&
1365 _addr == addr) 1372 _addr == addr) {
1366 /* 1373 /*
1367 * addr is at an inline function entry. 1374 * addr is at an inline function entry.
1368 * In this case, lineno should be the call-site 1375 * In this case, lineno should be the call-site
1369 * line number. 1376 * line number. (overwrite lineinfo)
1370 */ 1377 */
1371 lineno = die_get_call_lineno(&indie); 1378 lineno = die_get_call_lineno(&indie);
1372 else { 1379 fname = die_get_call_file(&indie);
1380 break;
1381 } else {
1373 /* 1382 /*
1374 * addr is in an inline function body. 1383 * addr is in an inline function body.
1375 * Since lineno points one of the lines 1384 * Since lineno points one of the lines
@@ -1377,19 +1386,27 @@ int debuginfo__find_probe_point(struct debuginfo *self, unsigned long addr,
1377 * be the entry line of the inline function. 1386 * be the entry line of the inline function.
1378 */ 1387 */
1379 tmp = dwarf_diename(&indie); 1388 tmp = dwarf_diename(&indie);
1380 if (tmp && 1389 if (!tmp ||
1381 dwarf_decl_line(&spdie, &baseline) == 0) 1390 dwarf_decl_line(&indie, &baseline) != 0)
1382 func = tmp; 1391 break;
1392 func = tmp;
1393 spdie = indie;
1383 } 1394 }
1384 } 1395 }
1396 /* Verify the lineno and baseline are in a same file */
1397 tmp = dwarf_decl_file(&spdie);
1398 if (!tmp || strcmp(tmp, fname) != 0)
1399 lineno = 0;
1385 } 1400 }
1386 1401
1387post: 1402post:
1388 /* Make a relative line number or an offset */ 1403 /* Make a relative line number or an offset */
1389 if (lineno) 1404 if (lineno)
1390 ppt->line = lineno - baseline; 1405 ppt->line = lineno - baseline;
1391 else if (func) 1406 else if (basefunc) {
1392 ppt->offset = addr - (unsigned long)baseaddr; 1407 ppt->offset = addr - (unsigned long)baseaddr;
1408 func = basefunc;
1409 }
1393 1410
1394 /* Duplicate strings */ 1411 /* Duplicate strings */
1395 if (func) { 1412 if (func) {
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 70ffa41518f3..568b750c01f6 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -256,6 +256,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
256 tool->sample = process_event_sample_stub; 256 tool->sample = process_event_sample_stub;
257 if (tool->mmap == NULL) 257 if (tool->mmap == NULL)
258 tool->mmap = process_event_stub; 258 tool->mmap = process_event_stub;
259 if (tool->mmap2 == NULL)
260 tool->mmap2 = process_event_stub;
259 if (tool->comm == NULL) 261 if (tool->comm == NULL)
260 tool->comm = process_event_stub; 262 tool->comm = process_event_stub;
261 if (tool->fork == NULL) 263 if (tool->fork == NULL)
@@ -1310,7 +1312,7 @@ int __perf_session__process_events(struct perf_session *session,
1310 file_offset = page_offset; 1312 file_offset = page_offset;
1311 head = data_offset - page_offset; 1313 head = data_offset - page_offset;
1312 1314
1313 if (data_offset + data_size < file_size) 1315 if (data_size && (data_offset + data_size < file_size))
1314 file_size = data_offset + data_size; 1316 file_size = data_offset + data_size;
1315 1317
1316 progress_next = file_size / 16; 1318 progress_next = file_size / 16;