probe-event.c (190b57fcb9c5fed5414935a174094f534fc510bc) | probe-event.c (14a8fd7ceea6915c613746203d6e9a2bf273f16c) |
---|---|
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 --- 103 unchanged lines hidden (view full) --- 112 NULL); 113} 114 115static struct map *kernel_get_module_map(const char *module) 116{ 117 struct rb_node *nd; 118 struct map_groups *grp = &machine.kmaps; 119 | 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 --- 103 unchanged lines hidden (view full) --- 112 NULL); 113} 114 115static struct map *kernel_get_module_map(const char *module) 116{ 117 struct rb_node *nd; 118 struct map_groups *grp = &machine.kmaps; 119 |
120 /* A file path -- this is an offline module */ 121 if (module && strchr(module, '/')) 122 return machine__new_module(&machine, 0, module); 123 |
|
120 if (!module) 121 module = "kernel"; 122 123 for (nd = rb_first(&grp->maps[MAP__FUNCTION]); nd; nd = rb_next(nd)) { 124 struct map *pos = rb_entry(nd, struct map, rb_node); 125 if (strncmp(pos->dso->short_name + 1, module, 126 pos->dso->short_name_len - 2) == 0) { 127 return pos; --- 40 unchanged lines hidden (view full) --- 168 struct dso *dso = kernel_get_module_dso(module); 169 return (dso) ? dso->long_name : NULL; 170} 171 172#ifdef DWARF_SUPPORT 173/* Open new debuginfo of given module */ 174static struct debuginfo *open_debuginfo(const char *module) 175{ | 124 if (!module) 125 module = "kernel"; 126 127 for (nd = rb_first(&grp->maps[MAP__FUNCTION]); nd; nd = rb_next(nd)) { 128 struct map *pos = rb_entry(nd, struct map, rb_node); 129 if (strncmp(pos->dso->short_name + 1, module, 130 pos->dso->short_name_len - 2) == 0) { 131 return pos; --- 40 unchanged lines hidden (view full) --- 172 struct dso *dso = kernel_get_module_dso(module); 173 return (dso) ? dso->long_name : NULL; 174} 175 176#ifdef DWARF_SUPPORT 177/* Open new debuginfo of given module */ 178static struct debuginfo *open_debuginfo(const char *module) 179{ |
176 const char *path = kernel_get_module_path(module); | 180 const char *path; |
177 | 181 |
178 if (!path) { 179 pr_err("Failed to find path of %s module.\n", 180 module ?: "kernel"); 181 return NULL; | 182 /* A file path -- this is an offline module */ 183 if (module && strchr(module, '/')) 184 path = module; 185 else { 186 path = kernel_get_module_path(module); 187 188 if (!path) { 189 pr_err("Failed to find path of %s module.\n", 190 module ?: "kernel"); 191 return NULL; 192 } |
182 } 183 return debuginfo__new(path); 184} 185 186/* 187 * Convert trace point to probe point with debuginfo 188 * Currently only handles kprobes. 189 */ --- 34 unchanged lines hidden (view full) --- 224 pp->retprobe = tp->retprobe; 225 226 return 0; 227} 228 229static int add_module_to_probe_trace_events(struct probe_trace_event *tevs, 230 int ntevs, const char *module) 231{ | 193 } 194 return debuginfo__new(path); 195} 196 197/* 198 * Convert trace point to probe point with debuginfo 199 * Currently only handles kprobes. 200 */ --- 34 unchanged lines hidden (view full) --- 235 pp->retprobe = tp->retprobe; 236 237 return 0; 238} 239 240static int add_module_to_probe_trace_events(struct probe_trace_event *tevs, 241 int ntevs, const char *module) 242{ |
232 int i; | 243 int i, ret = 0; 244 char *tmp; 245 246 if (!module) 247 return 0; 248 249 tmp = strrchr(module, '/'); 250 if (tmp) { 251 /* This is a module path -- get the module name */ 252 module = strdup(tmp + 1); 253 if (!module) 254 return -ENOMEM; 255 tmp = strchr(module, '.'); 256 if (tmp) 257 *tmp = '\0'; 258 tmp = (char *)module; /* For free() */ 259 } 260 |
233 for (i = 0; i < ntevs; i++) { 234 tevs[i].point.module = strdup(module); | 261 for (i = 0; i < ntevs; i++) { 262 tevs[i].point.module = strdup(module); |
235 if (!tevs[i].point.module) 236 return -ENOMEM; | 263 if (!tevs[i].point.module) { 264 ret = -ENOMEM; 265 break; 266 } |
237 } | 267 } |
238 return 0; | 268 269 if (tmp) 270 free(tmp); 271 272 return ret; |
239} 240 241/* Try to find perf_probe_event with debuginfo */ 242static int try_to_find_probe_trace_events(struct perf_probe_event *pev, 243 struct probe_trace_event **tevs, 244 int max_tevs, const char *module) 245{ 246 bool need_dwarf = perf_probe_event_need_dwarf(pev); --- 1808 unchanged lines hidden --- | 273} 274 275/* Try to find perf_probe_event with debuginfo */ 276static int try_to_find_probe_trace_events(struct perf_probe_event *pev, 277 struct probe_trace_event **tevs, 278 int max_tevs, const char *module) 279{ 280 bool need_dwarf = perf_probe_event_need_dwarf(pev); --- 1808 unchanged lines hidden --- |