probe-finder.c (f1bbbb6912662b9f6070c5bfc4ca9eb1f06a9d5b) | probe-finder.c (9ed7e1b85cd55dc46cb9410a23086bdaa2ff3eb9) |
---|---|
1/* 2 * probe-finder.c : C expression to kprobe event 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 --- 23 unchanged lines hidden (view full) --- 32#include <stdarg.h> 33#include <ctype.h> 34#include <dwarf-regs.h> 35 36#include "string.h" 37#include "event.h" 38#include "debug.h" 39#include "util.h" | 1/* 2 * probe-finder.c : C expression to kprobe event 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 --- 23 unchanged lines hidden (view full) --- 32#include <stdarg.h> 33#include <ctype.h> 34#include <dwarf-regs.h> 35 36#include "string.h" 37#include "event.h" 38#include "debug.h" 39#include "util.h" |
40#include "symbol.h" |
|
40#include "probe-finder.h" 41 42/* Kprobe tracer basic type is up to u64 */ 43#define MAX_BASIC_TYPE_BITS 64 44 45/* 46 * Compare the tail of two strings. 47 * Return 0 if whole of either string is same as another's tail part. --- 4 unchanged lines hidden (view full) --- 52 int i2 = strlen(s2); 53 while (--i1 >= 0 && --i2 >= 0) { 54 if (s1[i1] != s2[i2]) 55 return s1[i1] - s2[i2]; 56 } 57 return 0; 58} 59 | 41#include "probe-finder.h" 42 43/* Kprobe tracer basic type is up to u64 */ 44#define MAX_BASIC_TYPE_BITS 64 45 46/* 47 * Compare the tail of two strings. 48 * Return 0 if whole of either string is same as another's tail part. --- 4 unchanged lines hidden (view full) --- 53 int i2 = strlen(s2); 54 while (--i1 >= 0 && --i2 >= 0) { 55 if (s1[i1] != s2[i2]) 56 return s1[i1] - s2[i2]; 57 } 58 return 0; 59} 60 |
61/* 62 * Find a src file from a DWARF tag path. Prepend optional source path prefix 63 * and chop off leading directories that do not exist. Result is passed back as 64 * a newly allocated path on success. 65 * Return 0 if file was found and readable, -errno otherwise. 66 */ 67static int get_real_path(const char *raw_path, char **new_path) 68{ 69 if (!symbol_conf.source_prefix) { 70 if (access(raw_path, R_OK) == 0) { 71 *new_path = strdup(raw_path); 72 return 0; 73 } else 74 return -errno; 75 } 76 77 *new_path = malloc((strlen(symbol_conf.source_prefix) + 78 strlen(raw_path) + 2)); 79 if (!*new_path) 80 return -ENOMEM; 81 82 for (;;) { 83 sprintf(*new_path, "%s/%s", symbol_conf.source_prefix, 84 raw_path); 85 86 if (access(*new_path, R_OK) == 0) 87 return 0; 88 89 switch (errno) { 90 case ENAMETOOLONG: 91 case ENOENT: 92 case EROFS: 93 case EFAULT: 94 raw_path = strchr(++raw_path, '/'); 95 if (!raw_path) { 96 free(*new_path); 97 *new_path = NULL; 98 return -ENOENT; 99 } 100 continue; 101 102 default: 103 free(*new_path); 104 *new_path = NULL; 105 return -errno; 106 } 107 } 108} 109 |
|
60/* Line number list operations */ 61 62/* Add a line to line number list */ 63static int line_list__add_line(struct list_head *head, int line) 64{ 65 struct line_node *ln; 66 struct list_head *p; 67 --- 1023 unchanged lines hidden (view full) --- 1091 ret = found ? 1 : 0; 1092 return ret; 1093} 1094 1095/* Add a line and store the src path */ 1096static int line_range_add_line(const char *src, unsigned int lineno, 1097 struct line_range *lr) 1098{ | 110/* Line number list operations */ 111 112/* Add a line to line number list */ 113static int line_list__add_line(struct list_head *head, int line) 114{ 115 struct line_node *ln; 116 struct list_head *p; 117 --- 1023 unchanged lines hidden (view full) --- 1141 ret = found ? 1 : 0; 1142 return ret; 1143} 1144 1145/* Add a line and store the src path */ 1146static int line_range_add_line(const char *src, unsigned int lineno, 1147 struct line_range *lr) 1148{ |
1149 int ret; 1150 |
|
1099 /* Copy real path */ 1100 if (!lr->path) { | 1151 /* Copy real path */ 1152 if (!lr->path) { |
1101 lr->path = strdup(src); 1102 if (lr->path == NULL) 1103 return -ENOMEM; | 1153 ret = get_real_path(src, &lr->path); 1154 if (ret != 0) 1155 return ret; |
1104 } 1105 return line_list__add_line(&lr->line_list, lineno); 1106} 1107 1108/* Search function declaration lines */ 1109static int line_range_funcdecl_cb(Dwarf_Die *sp_die, void *data) 1110{ 1111 struct dwarf_callback_param *param = data; --- 195 unchanged lines hidden --- | 1156 } 1157 return line_list__add_line(&lr->line_list, lineno); 1158} 1159 1160/* Search function declaration lines */ 1161static int line_range_funcdecl_cb(Dwarf_Die *sp_die, void *data) 1162{ 1163 struct dwarf_callback_param *param = data; --- 195 unchanged lines hidden --- |