aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@sw.ru>2007-05-08 03:28:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:08 -0400
commitffb45122766db220d0bf3d01848d575fbbcb6430 (patch)
treea8fedf0518407ad12578a7c03aa2c3344f11ff3c
parentea07890a680273b25127129fb555aac0d9324bea (diff)
Simplify kallsyms_lookup()
Several kallsyms_lookup() pass dummy arguments but only need, say, module's name. Make kallsyms_lookup() accept NULLs where possible. Also, makes picture clearer about what interfaces are needed for all symbol resolving business. Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru> Cc: Rusty Russell <rusty@rustcorp.com.au> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/parisc/kernel/unwind.c5
-rw-r--r--arch/powerpc/xmon/xmon.c3
-rw-r--r--arch/sh64/kernel/unwind.c6
-rw-r--r--fs/proc/base.c5
-rw-r--r--kernel/kallsyms.c6
-rw-r--r--kernel/kprobes.c4
-rw-r--r--kernel/lockdep.c5
-rw-r--r--kernel/module.c6
-rw-r--r--kernel/time/timer_list.c4
-rw-r--r--kernel/time/timer_stats.c4
10 files changed, 20 insertions, 28 deletions
diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c
index 5f75b3e65986..89c03707eccc 100644
--- a/arch/parisc/kernel/unwind.c
+++ b/arch/parisc/kernel/unwind.c
@@ -216,11 +216,8 @@ static void unwind_frame_regs(struct unwind_frame_info *info)
216 /* Handle some frequent special cases.... */ 216 /* Handle some frequent special cases.... */
217 { 217 {
218 char symname[KSYM_NAME_LEN+1]; 218 char symname[KSYM_NAME_LEN+1];
219 char *modname;
220 unsigned long symsize, offset;
221 219
222 kallsyms_lookup(info->ip, &symsize, &offset, 220 kallsyms_lookup(info->ip, NULL, NULL, NULL, symname);
223 &modname, symname);
224 221
225 dbg("info->ip = 0x%lx, name = %s\n", info->ip, symname); 222 dbg("info->ip = 0x%lx, name = %s\n", info->ip, symname);
226 223
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index b481db1dacb4..28fdf4f50c27 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1217,7 +1217,6 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
1217{ 1217{
1218 unsigned long size, offset; 1218 unsigned long size, offset;
1219 const char *name; 1219 const char *name;
1220 char *modname;
1221 1220
1222 *startp = *endp = 0; 1221 *startp = *endp = 0;
1223 if (pc == 0) 1222 if (pc == 0)
@@ -1225,7 +1224,7 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
1225 if (setjmp(bus_error_jmp) == 0) { 1224 if (setjmp(bus_error_jmp) == 0) {
1226 catch_memory_errors = 1; 1225 catch_memory_errors = 1;
1227 sync(); 1226 sync();
1228 name = kallsyms_lookup(pc, &size, &offset, &modname, tmpstr); 1227 name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
1229 if (name != NULL) { 1228 if (name != NULL) {
1230 *startp = pc - offset; 1229 *startp = pc - offset;
1231 *endp = pc - offset + size; 1230 *endp = pc - offset + size;
diff --git a/arch/sh64/kernel/unwind.c b/arch/sh64/kernel/unwind.c
index f934f97f9f9c..1214c78e3584 100644
--- a/arch/sh64/kernel/unwind.c
+++ b/arch/sh64/kernel/unwind.c
@@ -46,15 +46,15 @@ static int lookup_prev_stack_frame(unsigned long fp, unsigned long pc,
46 struct pt_regs *regs) 46 struct pt_regs *regs)
47{ 47{
48 const char *sym; 48 const char *sym;
49 char *modname, namebuf[128]; 49 char namebuf[128];
50 unsigned long offset, size; 50 unsigned long offset;
51 unsigned long prologue = 0; 51 unsigned long prologue = 0;
52 unsigned long fp_displacement = 0; 52 unsigned long fp_displacement = 0;
53 unsigned long fp_prev = 0; 53 unsigned long fp_prev = 0;
54 unsigned long offset_r14 = 0, offset_r18 = 0; 54 unsigned long offset_r14 = 0, offset_r18 = 0;
55 int i, found_prologue_end = 0; 55 int i, found_prologue_end = 0;
56 56
57 sym = kallsyms_lookup(pc, &size, &offset, &modname, namebuf); 57 sym = kallsyms_lookup(pc, NULL, &offset, NULL, namebuf);
58 if (!sym) 58 if (!sym)
59 return -EINVAL; 59 return -EINVAL;
60 60
diff --git a/fs/proc/base.c b/fs/proc/base.c
index a3e77fb867ea..3b4fe21c7e94 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -278,14 +278,13 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
278 */ 278 */
279static int proc_pid_wchan(struct task_struct *task, char *buffer) 279static int proc_pid_wchan(struct task_struct *task, char *buffer)
280{ 280{
281 char *modname;
282 const char *sym_name; 281 const char *sym_name;
283 unsigned long wchan, size, offset; 282 unsigned long wchan;
284 char namebuf[KSYM_NAME_LEN+1]; 283 char namebuf[KSYM_NAME_LEN+1];
285 284
286 wchan = get_wchan(task); 285 wchan = get_wchan(task);
287 286
288 sym_name = kallsyms_lookup(wchan, &size, &offset, &modname, namebuf); 287 sym_name = kallsyms_lookup(wchan, NULL, NULL, NULL, namebuf);
289 if (sym_name) 288 if (sym_name)
290 return sprintf(buffer, "%s", sym_name); 289 return sprintf(buffer, "%s", sym_name);
291 return sprintf(buffer, "%lu", wchan); 290 return sprintf(buffer, "%lu", wchan);
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index f1ea6f66ac6c..f66da025cb7f 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -214,8 +214,10 @@ static unsigned long get_symbol_pos(unsigned long addr,
214 symbol_end = (unsigned long)_etext; 214 symbol_end = (unsigned long)_etext;
215 } 215 }
216 216
217 *symbolsize = symbol_end - symbol_start; 217 if (symbolsize)
218 *offset = addr - symbol_start; 218 *symbolsize = symbol_end - symbol_start;
219 if (offset)
220 *offset = addr - symbol_start;
219 221
220 return low; 222 return low;
221} 223}
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 0207045b4f6f..bee29bde6adf 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -868,13 +868,13 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
868 struct kprobe *p, *kp; 868 struct kprobe *p, *kp;
869 const char *sym = NULL; 869 const char *sym = NULL;
870 unsigned int i = *(loff_t *) v; 870 unsigned int i = *(loff_t *) v;
871 unsigned long size, offset = 0; 871 unsigned long offset = 0;
872 char *modname, namebuf[128]; 872 char *modname, namebuf[128];
873 873
874 head = &kprobe_table[i]; 874 head = &kprobe_table[i];
875 preempt_disable(); 875 preempt_disable();
876 hlist_for_each_entry_rcu(p, node, head, hlist) { 876 hlist_for_each_entry_rcu(p, node, head, hlist) {
877 sym = kallsyms_lookup((unsigned long)p->addr, &size, 877 sym = kallsyms_lookup((unsigned long)p->addr, NULL,
878 &offset, &modname, namebuf); 878 &offset, &modname, namebuf);
879 if (p->pre_handler == aggr_pre_handler) { 879 if (p->pre_handler == aggr_pre_handler) {
880 list_for_each_entry_rcu(kp, &p->list, list) 880 list_for_each_entry_rcu(kp, &p->list, list)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index c1e308a080b8..7f573136a905 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -340,10 +340,7 @@ static const char *usage_str[] =
340 340
341const char * __get_key_name(struct lockdep_subclass_key *key, char *str) 341const char * __get_key_name(struct lockdep_subclass_key *key, char *str)
342{ 342{
343 unsigned long offs, size; 343 return kallsyms_lookup((unsigned long)key, NULL, NULL, NULL, str);
344 char *modname;
345
346 return kallsyms_lookup((unsigned long)key, &size, &offs, &modname, str);
347} 344}
348 345
349void 346void
diff --git a/kernel/module.c b/kernel/module.c
index 5ee65994a3bc..bf4dccadf7b8 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2098,8 +2098,10 @@ static const char *get_ksymbol(struct module *mod,
2098 if (!best) 2098 if (!best)
2099 return NULL; 2099 return NULL;
2100 2100
2101 *size = nextval - mod->symtab[best].st_value; 2101 if (size)
2102 *offset = addr - mod->symtab[best].st_value; 2102 *size = nextval - mod->symtab[best].st_value;
2103 if (offset)
2104 *offset = addr - mod->symtab[best].st_value;
2103 return mod->strtab + mod->symtab[best].st_name; 2105 return mod->strtab + mod->symtab[best].st_name;
2104} 2106}
2105 2107
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index 59df5e8555a8..fe9314a89f20 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -40,11 +40,9 @@ static void print_name_offset(struct seq_file *m, void *sym)
40{ 40{
41 unsigned long addr = (unsigned long)sym; 41 unsigned long addr = (unsigned long)sym;
42 char namebuf[KSYM_NAME_LEN+1]; 42 char namebuf[KSYM_NAME_LEN+1];
43 unsigned long size, offset;
44 const char *sym_name; 43 const char *sym_name;
45 char *modname;
46 44
47 sym_name = kallsyms_lookup(addr, &size, &offset, &modname, namebuf); 45 sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf);
48 if (sym_name) 46 if (sym_name)
49 SEQ_printf(m, "%s", sym_name); 47 SEQ_printf(m, "%s", sym_name);
50 else 48 else
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index 1bc4882e28e0..946ed45f7d2f 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -258,11 +258,9 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
258static void print_name_offset(struct seq_file *m, unsigned long addr) 258static void print_name_offset(struct seq_file *m, unsigned long addr)
259{ 259{
260 char namebuf[KSYM_NAME_LEN+1]; 260 char namebuf[KSYM_NAME_LEN+1];
261 unsigned long size, offset;
262 const char *sym_name; 261 const char *sym_name;
263 char *modname;
264 262
265 sym_name = kallsyms_lookup(addr, &size, &offset, &modname, namebuf); 263 sym_name = kallsyms_lookup(addr, NULL, NULL, NULL, namebuf);
266 if (sym_name) 264 if (sym_name)
267 seq_printf(m, "%s", sym_name); 265 seq_printf(m, "%s", sym_name);
268 else 266 else