probe-event.c (f6eb0518f325ef0d6557fbef5c7ebe48a81e74db) | probe-event.c (36a009fe07bdecd201335f982babb8af34b603e2) |
---|---|
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 --- 1183 unchanged lines hidden (view full) --- 1192 } 1193 1194 return 0; 1195err: 1196 free(name); 1197 return err; 1198} 1199 | 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 --- 1183 unchanged lines hidden (view full) --- 1192 } 1193 1194 return 0; 1195err: 1196 free(name); 1197 return err; 1198} 1199 |
1200static int parse_perf_probe_event_name(char **arg, struct perf_probe_event *pev) 1201{ 1202 char *ptr; 1203 1204 ptr = strchr(*arg, ':'); 1205 if (ptr) { 1206 *ptr = '\0'; 1207 if (!is_c_func_name(*arg)) 1208 goto ng_name; 1209 pev->group = strdup(*arg); 1210 if (!pev->group) 1211 return -ENOMEM; 1212 *arg = ptr + 1; 1213 } else 1214 pev->group = NULL; 1215 if (!is_c_func_name(*arg)) { 1216ng_name: 1217 semantic_error("%s is bad for event name -it must " 1218 "follow C symbol-naming rule.\n", *arg); 1219 return -EINVAL; 1220 } 1221 pev->event = strdup(*arg); 1222 if (pev->event == NULL) 1223 return -ENOMEM; 1224 1225 return 0; 1226} 1227 |
|
1200/* Parse probepoint definition. */ 1201static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) 1202{ 1203 struct perf_probe_point *pp = &pev->point; 1204 char *ptr, *tmp; 1205 char c, nc = 0; 1206 bool file_spec = false; | 1228/* Parse probepoint definition. */ 1229static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev) 1230{ 1231 struct perf_probe_point *pp = &pev->point; 1232 char *ptr, *tmp; 1233 char c, nc = 0; 1234 bool file_spec = false; |
1235 int ret; 1236 |
|
1207 /* 1208 * <Syntax> 1209 * perf probe [GRP:][EVENT=]SRC[:LN|;PTN] 1210 * perf probe [GRP:][EVENT=]FUNC[@SRC][+OFFS|%return|:LN|;PAT] | 1237 /* 1238 * <Syntax> 1239 * perf probe [GRP:][EVENT=]SRC[:LN|;PTN] 1240 * perf probe [GRP:][EVENT=]FUNC[@SRC][+OFFS|%return|:LN|;PAT] |
1241 * perf probe %[GRP:]SDT_EVENT |
|
1211 */ 1212 if (!arg) 1213 return -EINVAL; 1214 | 1242 */ 1243 if (!arg) 1244 return -EINVAL; 1245 |
1246 if (arg[0] == '%') { 1247 pev->sdt = true; 1248 arg++; 1249 } 1250 |
|
1215 ptr = strpbrk(arg, ";=@+%"); | 1251 ptr = strpbrk(arg, ";=@+%"); |
1216 if (ptr && *ptr == '=') { /* Event name */ 1217 *ptr = '\0'; 1218 tmp = ptr + 1; 1219 ptr = strchr(arg, ':'); | 1252 if (pev->sdt) { |
1220 if (ptr) { | 1253 if (ptr) { |
1221 *ptr = '\0'; 1222 if (!is_c_func_name(arg)) 1223 goto not_fname; 1224 pev->group = strdup(arg); 1225 if (!pev->group) 1226 return -ENOMEM; 1227 arg = ptr + 1; 1228 } else 1229 pev->group = NULL; 1230 if (!is_c_func_name(arg)) { 1231not_fname: 1232 semantic_error("%s is bad for event name -it must " 1233 "follow C symbol-naming rule.\n", arg); | 1254 semantic_error("%s must contain only an SDT event name.\n", arg); |
1234 return -EINVAL; 1235 } | 1255 return -EINVAL; 1256 } |
1236 pev->event = strdup(arg); 1237 if (pev->event == NULL) 1238 return -ENOMEM; | 1257 ret = parse_perf_probe_event_name(&arg, pev); 1258 if (ret == 0) { 1259 if (asprintf(&pev->point.function, "%%%s", pev->event) < 0) 1260 ret = -errno; 1261 } 1262 return ret; 1263 } 1264 1265 if (ptr && *ptr == '=') { /* Event name */ 1266 *ptr = '\0'; 1267 tmp = ptr + 1; 1268 ret = parse_perf_probe_event_name(&arg, pev); 1269 if (ret < 0) 1270 return ret; 1271 |
1239 arg = tmp; 1240 } 1241 1242 /* 1243 * Check arg is function or file name and copy it. 1244 * 1245 * We consider arg to be a file spec if and only if it satisfies 1246 * all of the below criteria:: --- 1624 unchanged lines hidden (view full) --- 2871 int ret, i; 2872 2873 cache = probe_cache__new(pev->target); 2874 if (!cache) 2875 return 0; 2876 2877 entry = probe_cache__find(cache, pev); 2878 if (!entry) { | 1272 arg = tmp; 1273 } 1274 1275 /* 1276 * Check arg is function or file name and copy it. 1277 * 1278 * We consider arg to be a file spec if and only if it satisfies 1279 * all of the below criteria:: --- 1624 unchanged lines hidden (view full) --- 2904 int ret, i; 2905 2906 cache = probe_cache__new(pev->target); 2907 if (!cache) 2908 return 0; 2909 2910 entry = probe_cache__find(cache, pev); 2911 if (!entry) { |
2879 ret = 0; | 2912 /* SDT must be in the cache */ 2913 ret = pev->sdt ? -ENOENT : 0; |
2880 goto out; 2881 } 2882 2883 ret = strlist__nr_entries(entry->tevlist); 2884 if (ret > probe_conf.max_probes) { 2885 pr_debug("Too many entries matched in the cache of %s\n", 2886 pev->target ? : "kernel"); 2887 ret = -E2BIG; --- 22 unchanged lines hidden (view full) --- 2910 return ret; 2911} 2912 2913static int convert_to_probe_trace_events(struct perf_probe_event *pev, 2914 struct probe_trace_event **tevs) 2915{ 2916 int ret; 2917 | 2914 goto out; 2915 } 2916 2917 ret = strlist__nr_entries(entry->tevlist); 2918 if (ret > probe_conf.max_probes) { 2919 pr_debug("Too many entries matched in the cache of %s\n", 2920 pev->target ? : "kernel"); 2921 ret = -E2BIG; --- 22 unchanged lines hidden (view full) --- 2944 return ret; 2945} 2946 2947static int convert_to_probe_trace_events(struct perf_probe_event *pev, 2948 struct probe_trace_event **tevs) 2949{ 2950 int ret; 2951 |
2918 if (!pev->group) { | 2952 if (!pev->group && !pev->sdt) { |
2919 /* Set group name if not given */ 2920 if (!pev->uprobes) { 2921 pev->group = strdup(PERFPROBE_GROUP); 2922 ret = pev->group ? 0 : -ENOMEM; 2923 } else 2924 ret = convert_exec_to_group(pev->target, &pev->group); 2925 if (ret != 0) { 2926 pr_warning("Failed to make a group name.\n"); 2927 return ret; 2928 } 2929 } 2930 2931 ret = try_to_find_absolute_address(pev, tevs); 2932 if (ret > 0) 2933 return ret; 2934 2935 /* At first, we need to lookup cache entry */ 2936 ret = find_probe_trace_events_from_cache(pev, tevs); | 2953 /* Set group name if not given */ 2954 if (!pev->uprobes) { 2955 pev->group = strdup(PERFPROBE_GROUP); 2956 ret = pev->group ? 0 : -ENOMEM; 2957 } else 2958 ret = convert_exec_to_group(pev->target, &pev->group); 2959 if (ret != 0) { 2960 pr_warning("Failed to make a group name.\n"); 2961 return ret; 2962 } 2963 } 2964 2965 ret = try_to_find_absolute_address(pev, tevs); 2966 if (ret > 0) 2967 return ret; 2968 2969 /* At first, we need to lookup cache entry */ 2970 ret = find_probe_trace_events_from_cache(pev, tevs); |
2937 if (ret > 0) 2938 return ret; /* Found in probe cache */ | 2971 if (ret > 0 || pev->sdt) /* SDT can be found only in the cache */ 2972 return ret == 0 ? -ENOENT : ret; /* Found in probe cache */ |
2939 2940 if (arch__prefers_symtab() && !perf_probe_event_need_dwarf(pev)) { 2941 ret = find_probe_trace_events_from_map(pev, tevs); 2942 if (ret > 0) 2943 return ret; /* Found in symbol table */ 2944 } 2945 2946 /* Convert perf_probe_event with debuginfo */ --- 185 unchanged lines hidden --- | 2973 2974 if (arch__prefers_symtab() && !perf_probe_event_need_dwarf(pev)) { 2975 ret = find_probe_trace_events_from_map(pev, tevs); 2976 if (ret > 0) 2977 return ret; /* Found in symbol table */ 2978 } 2979 2980 /* Convert perf_probe_event with debuginfo */ --- 185 unchanged lines hidden --- |