probe-event.c (3099c026002e97b8c173d9d0bbdfc39257d14402) probe-event.c (b6a896438b3275df434a8f99bee58292b31693bd)
1/*
2 * probe-event.c : perf-probe definition to probe_events format converter
3 *
4 * Written by Masami Hiramatsu <mhiramat@redhat.com>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 2132 unchanged lines hidden (view full) ---

2141 pr_info(" %s", buf);
2142 }
2143 }
2144 pr_info(")\n");
2145 free(place);
2146 return ret;
2147}
2148
1/*
2 * probe-event.c : perf-probe definition to probe_events format converter
3 *
4 * Written by Masami Hiramatsu <mhiramat@redhat.com>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 2132 unchanged lines hidden (view full) ---

2141 pr_info(" %s", buf);
2142 }
2143 }
2144 pr_info(")\n");
2145 free(place);
2146 return ret;
2147}
2148
2149static int __show_perf_probe_events(int fd, bool is_kprobe)
2149static bool filter_probe_trace_event(struct probe_trace_event *tev,
2150 struct strfilter *filter)
2150{
2151{
2152 char tmp[128];
2153
2154 /* At first, check the event name itself */
2155 if (strfilter__compare(filter, tev->event))
2156 return true;
2157
2158 /* Next, check the combination of name and group */
2159 if (e_snprintf(tmp, 128, "%s:%s", tev->group, tev->event) < 0)
2160 return false;
2161 return strfilter__compare(filter, tmp);
2162}
2163
2164static int __show_perf_probe_events(int fd, bool is_kprobe,
2165 struct strfilter *filter)
2166{
2151 int ret = 0;
2152 struct probe_trace_event tev;
2153 struct perf_probe_event pev;
2154 struct strlist *rawlist;
2155 struct str_node *ent;
2156
2157 memset(&tev, 0, sizeof(tev));
2158 memset(&pev, 0, sizeof(pev));
2159
2160 rawlist = get_probe_trace_command_rawlist(fd);
2161 if (!rawlist)
2162 return -ENOMEM;
2163
2164 strlist__for_each(ent, rawlist) {
2165 ret = parse_probe_trace_command(ent->s, &tev);
2166 if (ret >= 0) {
2167 int ret = 0;
2168 struct probe_trace_event tev;
2169 struct perf_probe_event pev;
2170 struct strlist *rawlist;
2171 struct str_node *ent;
2172
2173 memset(&tev, 0, sizeof(tev));
2174 memset(&pev, 0, sizeof(pev));
2175
2176 rawlist = get_probe_trace_command_rawlist(fd);
2177 if (!rawlist)
2178 return -ENOMEM;
2179
2180 strlist__for_each(ent, rawlist) {
2181 ret = parse_probe_trace_command(ent->s, &tev);
2182 if (ret >= 0) {
2183 if (!filter_probe_trace_event(&tev, filter))
2184 goto next;
2167 ret = convert_to_perf_probe_event(&tev, &pev,
2168 is_kprobe);
2169 if (ret >= 0)
2170 ret = show_perf_probe_event(&pev,
2171 tev.point.module);
2172 }
2185 ret = convert_to_perf_probe_event(&tev, &pev,
2186 is_kprobe);
2187 if (ret >= 0)
2188 ret = show_perf_probe_event(&pev,
2189 tev.point.module);
2190 }
2191next:
2173 clear_perf_probe_event(&pev);
2174 clear_probe_trace_event(&tev);
2175 if (ret < 0)
2176 break;
2177 }
2178 strlist__delete(rawlist);
2179
2180 return ret;
2181}
2182
2183/* List up current perf-probe events */
2192 clear_perf_probe_event(&pev);
2193 clear_probe_trace_event(&tev);
2194 if (ret < 0)
2195 break;
2196 }
2197 strlist__delete(rawlist);
2198
2199 return ret;
2200}
2201
2202/* List up current perf-probe events */
2184int show_perf_probe_events(void)
2203int show_perf_probe_events(struct strfilter *filter)
2185{
2186 int kp_fd, up_fd, ret;
2187
2188 setup_pager();
2189
2190 ret = init_symbol_maps(false);
2191 if (ret < 0)
2192 return ret;
2193
2194 kp_fd = open_kprobe_events(false);
2195 if (kp_fd >= 0) {
2204{
2205 int kp_fd, up_fd, ret;
2206
2207 setup_pager();
2208
2209 ret = init_symbol_maps(false);
2210 if (ret < 0)
2211 return ret;
2212
2213 kp_fd = open_kprobe_events(false);
2214 if (kp_fd >= 0) {
2196 ret = __show_perf_probe_events(kp_fd, true);
2215 ret = __show_perf_probe_events(kp_fd, true, filter);
2197 close(kp_fd);
2198 if (ret < 0)
2199 goto out;
2200 }
2201
2202 up_fd = open_uprobe_events(false);
2203 if (kp_fd < 0 && up_fd < 0) {
2204 print_both_open_warning(kp_fd, up_fd);
2205 ret = kp_fd;
2206 goto out;
2207 }
2208
2209 if (up_fd >= 0) {
2216 close(kp_fd);
2217 if (ret < 0)
2218 goto out;
2219 }
2220
2221 up_fd = open_uprobe_events(false);
2222 if (kp_fd < 0 && up_fd < 0) {
2223 print_both_open_warning(kp_fd, up_fd);
2224 ret = kp_fd;
2225 goto out;
2226 }
2227
2228 if (up_fd >= 0) {
2210 ret = __show_perf_probe_events(up_fd, false);
2229 ret = __show_perf_probe_events(up_fd, false, filter);
2211 close(up_fd);
2212 }
2213out:
2214 exit_symbol_maps();
2215 return ret;
2216}
2217
2218/* Get current perf-probe event names */

--- 671 unchanged lines hidden ---
2230 close(up_fd);
2231 }
2232out:
2233 exit_symbol_maps();
2234 return ret;
2235}
2236
2237/* Get current perf-probe event names */

--- 671 unchanged lines hidden ---