diff options
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r-- | tools/perf/util/probe-finder.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index b7c85ce466a1..3b9d0b800d5c 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -1471,6 +1471,38 @@ static int find_probe_point_by_func(struct probe_finder *pf) | |||
1471 | return _param.retval; | 1471 | return _param.retval; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | struct pubname_callback_param { | ||
1475 | char *function; | ||
1476 | char *file; | ||
1477 | Dwarf_Die *cu_die; | ||
1478 | Dwarf_Die *sp_die; | ||
1479 | int found; | ||
1480 | }; | ||
1481 | |||
1482 | static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data) | ||
1483 | { | ||
1484 | struct pubname_callback_param *param = data; | ||
1485 | |||
1486 | if (dwarf_offdie(dbg, gl->die_offset, param->sp_die)) { | ||
1487 | if (dwarf_tag(param->sp_die) != DW_TAG_subprogram) | ||
1488 | return DWARF_CB_OK; | ||
1489 | |||
1490 | if (die_compare_name(param->sp_die, param->function)) { | ||
1491 | if (!dwarf_offdie(dbg, gl->cu_offset, param->cu_die)) | ||
1492 | return DWARF_CB_OK; | ||
1493 | |||
1494 | if (param->file && | ||
1495 | strtailcmp(param->file, dwarf_decl_file(param->sp_die))) | ||
1496 | return DWARF_CB_OK; | ||
1497 | |||
1498 | param->found = 1; | ||
1499 | return DWARF_CB_ABORT; | ||
1500 | } | ||
1501 | } | ||
1502 | |||
1503 | return DWARF_CB_OK; | ||
1504 | } | ||
1505 | |||
1474 | /* Find probe points from debuginfo */ | 1506 | /* Find probe points from debuginfo */ |
1475 | static int find_probes(int fd, struct probe_finder *pf) | 1507 | static int find_probes(int fd, struct probe_finder *pf) |
1476 | { | 1508 | { |
@@ -1498,6 +1530,28 @@ static int find_probes(int fd, struct probe_finder *pf) | |||
1498 | 1530 | ||
1499 | off = 0; | 1531 | off = 0; |
1500 | line_list__init(&pf->lcache); | 1532 | line_list__init(&pf->lcache); |
1533 | |||
1534 | /* Fastpath: lookup by function name from .debug_pubnames section */ | ||
1535 | if (pp->function) { | ||
1536 | struct pubname_callback_param pubname_param = { | ||
1537 | .function = pp->function, | ||
1538 | .file = pp->file, | ||
1539 | .cu_die = &pf->cu_die, | ||
1540 | .sp_die = &pf->sp_die, | ||
1541 | .found = 0, | ||
1542 | }; | ||
1543 | struct dwarf_callback_param probe_param = { | ||
1544 | .data = pf, | ||
1545 | }; | ||
1546 | |||
1547 | dwarf_getpubnames(dbg, pubname_search_cb, &pubname_param, 0); | ||
1548 | if (pubname_param.found) { | ||
1549 | ret = probe_point_search_cb(&pf->sp_die, &probe_param); | ||
1550 | if (ret) | ||
1551 | goto found; | ||
1552 | } | ||
1553 | } | ||
1554 | |||
1501 | /* Loop on CUs (Compilation Unit) */ | 1555 | /* Loop on CUs (Compilation Unit) */ |
1502 | while (!dwarf_nextcu(dbg, off, &noff, &cuhl, NULL, NULL, NULL)) { | 1556 | while (!dwarf_nextcu(dbg, off, &noff, &cuhl, NULL, NULL, NULL)) { |
1503 | /* Get the DIE(Debugging Information Entry) of this CU */ | 1557 | /* Get the DIE(Debugging Information Entry) of this CU */ |
@@ -1525,6 +1579,8 @@ static int find_probes(int fd, struct probe_finder *pf) | |||
1525 | } | 1579 | } |
1526 | off = noff; | 1580 | off = noff; |
1527 | } | 1581 | } |
1582 | |||
1583 | found: | ||
1528 | line_list__free(&pf->lcache); | 1584 | line_list__free(&pf->lcache); |
1529 | if (dwfl) | 1585 | if (dwfl) |
1530 | dwfl_end(dwfl); | 1586 | dwfl_end(dwfl); |
@@ -1946,6 +2002,22 @@ int find_line_range(int fd, struct line_range *lr) | |||
1946 | return -EBADF; | 2002 | return -EBADF; |
1947 | } | 2003 | } |
1948 | 2004 | ||
2005 | /* Fastpath: lookup by function name from .debug_pubnames section */ | ||
2006 | if (lr->function) { | ||
2007 | struct pubname_callback_param pubname_param = { | ||
2008 | .function = lr->function, .file = lr->file, | ||
2009 | .cu_die = &lf.cu_die, .sp_die = &lf.sp_die, .found = 0}; | ||
2010 | struct dwarf_callback_param line_range_param = { | ||
2011 | .data = (void *)&lf, .retval = 0}; | ||
2012 | |||
2013 | dwarf_getpubnames(dbg, pubname_search_cb, &pubname_param, 0); | ||
2014 | if (pubname_param.found) { | ||
2015 | line_range_search_cb(&lf.sp_die, &line_range_param); | ||
2016 | if (lf.found) | ||
2017 | goto found; | ||
2018 | } | ||
2019 | } | ||
2020 | |||
1949 | /* Loop on CUs (Compilation Unit) */ | 2021 | /* Loop on CUs (Compilation Unit) */ |
1950 | while (!lf.found && ret >= 0) { | 2022 | while (!lf.found && ret >= 0) { |
1951 | if (dwarf_nextcu(dbg, off, &noff, &cuhl, NULL, NULL, NULL) != 0) | 2023 | if (dwarf_nextcu(dbg, off, &noff, &cuhl, NULL, NULL, NULL) != 0) |
@@ -1974,6 +2046,7 @@ int find_line_range(int fd, struct line_range *lr) | |||
1974 | off = noff; | 2046 | off = noff; |
1975 | } | 2047 | } |
1976 | 2048 | ||
2049 | found: | ||
1977 | /* Store comp_dir */ | 2050 | /* Store comp_dir */ |
1978 | if (lf.found) { | 2051 | if (lf.found) { |
1979 | comp_dir = cu_get_comp_dir(&lf.cu_die); | 2052 | comp_dir = cu_get_comp_dir(&lf.cu_die); |