Lines Matching full:pf

557 static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf)  in convert_variable()  argument
565 ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops, in convert_variable()
566 &pf->sp_die, pf->machine, pf->tvar); in convert_variable()
567 if (ret == -ENOENT && pf->skip_empty_arg) in convert_variable()
571 print_var_not_found(pf->pvar->var); in convert_variable()
574 else if (ret == 0 && pf->pvar->field) { in convert_variable()
575 ret = convert_variable_fields(vr_die, pf->pvar->var, in convert_variable()
576 pf->pvar->field, &pf->tvar->ref, in convert_variable()
577 &die_mem, pf->pvar->user_access); in convert_variable()
581 ret = convert_variable_type(vr_die, pf->tvar, pf->pvar->type, in convert_variable()
582 pf->pvar->user_access); in convert_variable()
588 static int find_variable(Dwarf_Die *sc_die, struct probe_finder *pf) in find_variable() argument
595 if (!is_c_varname(pf->pvar->var)) in find_variable()
596 return copy_to_probe_trace_arg(pf->tvar, pf->pvar); in find_variable()
598 if (pf->pvar->name) in find_variable()
599 pf->tvar->name = strdup(pf->pvar->name); in find_variable()
601 buf = synthesize_perf_probe_arg(pf->pvar); in find_variable()
607 pf->tvar->name = buf; in find_variable()
609 if (pf->tvar->name == NULL) in find_variable()
612 pr_debug("Searching '%s' variable in context.\n", pf->pvar->var); in find_variable()
614 if (!die_find_variable_at(sc_die, pf->pvar->var, pf->addr, &vr_die)) { in find_variable()
616 if (!die_find_variable_at(&pf->cu_die, pf->pvar->var, in find_variable()
618 if (pf->skip_empty_arg) in find_variable()
621 pf->pvar->var); in find_variable()
626 ret = convert_variable(&vr_die, pf); in find_variable()
684 static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf) in call_probe_finder() argument
698 if (!die_find_realfunc(&pf->cu_die, pf->addr, &pf->sp_die)) { in call_probe_finder()
699 if (die_find_tailfunc(&pf->cu_die, pf->addr, &pf->sp_die)) { in call_probe_finder()
701 dwarf_diename(&pf->sp_die)); in call_probe_finder()
710 memcpy(&pf->sp_die, sc_die, sizeof(Dwarf_Die)); in call_probe_finder()
713 dwarf_attr(&pf->sp_die, DW_AT_frame_base, &fb_attr); in call_probe_finder()
714 ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1); in call_probe_finder()
716 pf->fb_ops = NULL; in call_probe_finder()
718 } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa && in call_probe_finder()
719 (pf->cfi_eh != NULL || pf->cfi_dbg != NULL)) { in call_probe_finder()
720 if ((dwarf_cfi_addrframe(pf->cfi_eh, pf->addr, &frame) != 0 && in call_probe_finder()
721 (dwarf_cfi_addrframe(pf->cfi_dbg, pf->addr, &frame) != 0)) || in call_probe_finder()
722 dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) { in call_probe_finder()
724 (uintmax_t)pf->addr); in call_probe_finder()
732 ret = pf->callback(sc_die, pf); in call_probe_finder()
734 /* Since *pf->fb_ops can be a part of frame. we should free it here. */ in call_probe_finder()
736 pf->fb_ops = NULL; in call_probe_finder()
793 static Dwarf_Die *find_best_scope(struct probe_finder *pf, Dwarf_Die *die_mem) in find_best_scope() argument
796 .function = pf->pev->point.function, in find_best_scope()
797 .file = pf->fname, in find_best_scope()
798 .line = pf->lno, in find_best_scope()
805 ret = cu_walk_functions_at(&pf->cu_die, pf->addr, find_best_scope_cb, in find_best_scope()
808 cu_walk_functions_at(&pf->cu_die, pf->addr, in find_best_scope()
814 static int verify_representive_line(struct probe_finder *pf, const char *fname, in verify_representive_line() argument
822 if (cu_find_lineinfo(&pf->cu_die, addr, &__fname, &__lineno) < 0) in verify_representive_line()
831 if (pf->pev->point.function) { in verify_representive_line()
833 pf->addr = addr; in verify_representive_line()
834 if (find_best_scope(pf, &die_mem) in verify_representive_line()
835 && die_match_name(&die_mem, pf->pev->point.function) in verify_representive_line()
850 struct probe_finder *pf = data; in probe_point_line_walker() local
854 if (lineno != pf->lno || strtailcmp(fname, pf->fname) != 0) in probe_point_line_walker()
857 if (verify_representive_line(pf, fname, lineno, addr)) in probe_point_line_walker()
860 pf->addr = addr; in probe_point_line_walker()
861 sc_die = find_best_scope(pf, &die_mem); in probe_point_line_walker()
867 ret = call_probe_finder(sc_die, pf); in probe_point_line_walker()
874 static int find_probe_point_by_line(struct probe_finder *pf) in find_probe_point_by_line() argument
876 return die_walk_lines(&pf->cu_die, probe_point_line_walker, pf); in find_probe_point_by_line()
922 struct probe_finder *pf = data; in probe_point_lazy_walker() local
926 if (!intlist__has_entry(pf->lcache, lineno) || in probe_point_lazy_walker()
927 strtailcmp(fname, pf->fname) != 0) in probe_point_lazy_walker()
932 pf->addr = addr; in probe_point_lazy_walker()
933 pf->lno = lineno; in probe_point_lazy_walker()
934 sc_die = find_best_scope(pf, &die_mem); in probe_point_lazy_walker()
940 ret = call_probe_finder(sc_die, pf); in probe_point_lazy_walker()
950 static int find_probe_point_lazy(Dwarf_Die *sp_die, struct probe_finder *pf) in find_probe_point_lazy() argument
957 if (intlist__empty(pf->lcache)) { in find_probe_point_lazy()
960 comp_dir = cu_get_comp_dir(&pf->cu_die); in find_probe_point_lazy()
961 if (pf->dbg->build_id) { in find_probe_point_lazy()
962 build_id__init(&bid, pf->dbg->build_id, BUILD_ID_SIZE); in find_probe_point_lazy()
965 ret = find_source_path(pf->fname, sbuild_id, comp_dir, &fpath); in find_probe_point_lazy()
972 ret = find_lazy_match_lines(pf->lcache, fpath, in find_probe_point_lazy()
973 pf->pev->point.lazy_line); in find_probe_point_lazy()
979 return die_walk_lines(sp_die, probe_point_lazy_walker, pf); in find_probe_point_lazy()
982 static void skip_prologue(Dwarf_Die *sp_die, struct probe_finder *pf) in skip_prologue() argument
984 struct perf_probe_point *pp = &pf->pev->point; in skip_prologue()
987 if (!pf->pev->uprobes) in skip_prologue()
991 if (die_is_optimized_target(&pf->cu_die)) in skip_prologue()
995 if (!pf->addr) in skip_prologue()
1004 if (!perf_probe_with_var(pf->pev)) in skip_prologue()
1009 pf->addr); in skip_prologue()
1011 die_skip_prologue(sp_die, &pf->cu_die, &pf->addr); in skip_prologue()
1016 struct probe_finder *pf = data; in probe_point_inline_cb() local
1017 struct perf_probe_point *pp = &pf->pev->point; in probe_point_inline_cb()
1022 ret = find_probe_point_lazy(in_die, pf); in probe_point_inline_cb()
1035 pf->addr = addr; in probe_point_inline_cb()
1036 pf->addr += pp->offset; in probe_point_inline_cb()
1038 (uintmax_t)pf->addr); in probe_point_inline_cb()
1040 ret = call_probe_finder(in_die, pf); in probe_point_inline_cb()
1056 struct probe_finder *pf = param->data; in probe_point_search_cb() local
1057 struct perf_probe_point *pp = &pf->pev->point; in probe_point_search_cb()
1070 pf->fname = dwarf_decl_file(sp_die); in probe_point_search_cb()
1072 dwarf_decl_line(sp_die, &pf->lno); in probe_point_search_cb()
1073 pf->lno += pp->line; in probe_point_search_cb()
1074 param->retval = find_probe_point_by_line(pf); in probe_point_search_cb()
1077 die_entrypc(sp_die, &pf->addr); in probe_point_search_cb()
1079 if (pf->addr == 0) { in probe_point_search_cb()
1085 param->retval = find_probe_point_lazy(sp_die, pf); in probe_point_search_cb()
1087 skip_prologue(sp_die, pf); in probe_point_search_cb()
1088 pf->addr += pp->offset; in probe_point_search_cb()
1090 param->retval = call_probe_finder(sp_die, pf); in probe_point_search_cb()
1095 probe_point_inline_cb, (void *)pf); in probe_point_search_cb()
1110 static int find_probe_point_by_func(struct probe_finder *pf) in find_probe_point_by_func() argument
1112 struct dwarf_callback_param _param = {.data = (void *)pf, in find_probe_point_by_func()
1114 dwarf_getfuncs(&pf->cu_die, probe_point_search_cb, &_param, 0); in find_probe_point_by_func()
1151 struct probe_finder *pf) in debuginfo__find_probe_location() argument
1153 struct perf_probe_point *pp = &pf->pev->point; in debuginfo__find_probe_location()
1160 pf->lcache = intlist__new(NULL); in debuginfo__find_probe_location()
1161 if (!pf->lcache) in debuginfo__find_probe_location()
1169 .cu_die = &pf->cu_die, in debuginfo__find_probe_location()
1170 .sp_die = &pf->sp_die, in debuginfo__find_probe_location()
1174 .data = pf, in debuginfo__find_probe_location()
1180 ret = probe_point_search_cb(&pf->sp_die, &probe_param); in debuginfo__find_probe_location()
1189 diep = dwarf_offdie(dbg->dbg, off + cuhl, &pf->cu_die); in debuginfo__find_probe_location()
1195 pf->fname = cu_find_realpath(&pf->cu_die, pp->file); in debuginfo__find_probe_location()
1197 pf->fname = NULL; in debuginfo__find_probe_location()
1199 if (!pp->file || pf->fname) { in debuginfo__find_probe_location()
1201 ret = find_probe_point_by_func(pf); in debuginfo__find_probe_location()
1203 ret = find_probe_point_lazy(&pf->cu_die, pf); in debuginfo__find_probe_location()
1205 pf->lno = pp->line; in debuginfo__find_probe_location()
1206 ret = find_probe_point_by_line(pf); in debuginfo__find_probe_location()
1215 intlist__delete(pf->lcache); in debuginfo__find_probe_location()
1216 pf->lcache = NULL; in debuginfo__find_probe_location()
1223 struct probe_finder *pf) in debuginfo__find_probes() argument
1229 if (pf->cfi_eh || pf->cfi_dbg) in debuginfo__find_probes()
1230 return debuginfo__find_probe_location(dbg, pf); in debuginfo__find_probes()
1240 pf->machine = ehdr.e_machine; in debuginfo__find_probes()
1248 pf->cfi_eh = dwarf_getcfi_elf(elf); in debuginfo__find_probes()
1250 pf->cfi_dbg = dwarf_getcfi(dbg->dbg); in debuginfo__find_probes()
1254 ret = debuginfo__find_probe_location(dbg, pf); in debuginfo__find_probes()
1259 struct probe_finder *pf; member
1271 struct probe_finder *pf = vf->pf; in copy_variables_cb() local
1277 if (convert_variable_location(die_mem, vf->pf->addr, in copy_variables_cb()
1278 vf->pf->fb_ops, &pf->sp_die, in copy_variables_cb()
1279 pf->machine, NULL) == 0) { in copy_variables_cb()
1290 if (dwarf_haspc(die_mem, vf->pf->addr)) in copy_variables_cb()
1296 static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf, in expand_probe_args() argument
1302 struct local_vars_finder vf = {.pf = pf, .args = args, .vars = false, in expand_probe_args()
1305 for (i = 0; i < pf->pev->nargs; i++) { in expand_probe_args()
1307 if (strcmp(pf->pev->args[i].var, PROBE_ARG_VARS) == 0) in expand_probe_args()
1309 else if (strcmp(pf->pev->args[i].var, PROBE_ARG_PARAMS) != 0) { in expand_probe_args()
1311 args[n] = pf->pev->args[i]; in expand_probe_args()
1315 pr_debug("Expanding %s into:", pf->pev->args[i].var); in expand_probe_args()
1333 if (tf->pf.addr == tf->tevs[i].point.address) in trace_event_finder_overlap()
1340 static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf) in add_probe_trace_event() argument
1343 container_of(pf, struct trace_event_finder, pf); in add_probe_trace_event()
1344 struct perf_probe_point *pp = &pf->pev->point; in add_probe_trace_event()
1366 ret = convert_to_trace_point(&pf->sp_die, tf->mod, pf->addr, in add_probe_trace_event()
1387 ret = expand_probe_args(sc_die, pf, args); in add_probe_trace_event()
1400 pf->pvar = &args[i]; in add_probe_trace_event()
1401 pf->tvar = &tev->args[i]; in add_probe_trace_event()
1403 ret = find_variable(sc_die, pf); in add_probe_trace_event()
1464 .pf = {.pev = pev, .dbg = dbg, .callback = add_probe_trace_event}, in debuginfo__find_trace_events()
1477 tf.pf.skip_empty_arg = true; in debuginfo__find_trace_events()
1479 ret = debuginfo__find_probes(dbg, &tf.pf); in debuginfo__find_trace_events()
1480 if (ret >= 0 && tf.pf.skip_empty_arg) in debuginfo__find_trace_events()
1506 ret = convert_variable_location(die_mem, af->pf.addr, in collect_variables_cb()
1507 af->pf.fb_ops, &af->pf.sp_die, in collect_variables_cb()
1508 af->pf.machine, NULL); in collect_variables_cb()
1532 ret2 = die_get_var_range(&af->pf.sp_die, in collect_variables_cb()
1545 if (af->child && dwarf_haspc(die_mem, af->pf.addr)) in collect_variables_cb()
1560 if (af->pf.addr == af->vls[i].point.address) in available_var_finder_overlap()
1568 static int add_available_vars(Dwarf_Die *sc_die, struct probe_finder *pf) in add_available_vars() argument
1571 container_of(pf, struct available_var_finder, pf); in add_available_vars()
1572 struct perf_probe_point *pp = &pf->pev->point; in add_available_vars()
1593 ret = convert_to_trace_point(&pf->sp_die, af->mod, pf->addr, in add_available_vars()
1613 die_find_child(&pf->cu_die, collect_variables_cb, (void *)af, &die_mem); in add_available_vars()
1634 .pf = {.pev = pev, .dbg = dbg, .callback = add_available_vars}, in debuginfo__find_available_vars_at()
1647 ret = debuginfo__find_probes(dbg, &af.pf); in debuginfo__find_available_vars_at()