Blame view

include/linux/kallsyms.h 3.32 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
  /* Rewritten and vastly simplified by Rusty Russell for in-kernel
   * module loader:
   *   Copyright 2002 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
   */
  #ifndef _LINUX_KALLSYMS_H
  #define _LINUX_KALLSYMS_H
40e48eed8   Adrian Bunk   include/linux/kal...
7
  #include <linux/errno.h>
2711b793e   Vegard Nossum   kallsyms: unify 3...
8
  #include <linux/kernel.h>
5a75983ee   Kamalesh Babulal   Missing include f...
9
  #include <linux/stddef.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10

9281acea6   Tejun Heo   kallsyms: make KS...
11
12
13
  #define KSYM_NAME_LEN 128
  #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
  			 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14

75a66614d   Anders Kaseorg   Ksplice: Add func...
15
  struct module;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
18
  #ifdef CONFIG_KALLSYMS
  /* Lookup the address for a symbol. Returns 0 if not found. */
  unsigned long kallsyms_lookup_name(const char *name);
75a66614d   Anders Kaseorg   Ksplice: Add func...
19
20
21
22
  /* Call a function on each kallsyms symbol in the core kernel */
  int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
  				      unsigned long),
  			    void *data);
ffc508919   Franck Bui-Huu   [PATCH] Create ka...
23
24
25
  extern int kallsyms_lookup_size_offset(unsigned long addr,
  				  unsigned long *symbolsize,
  				  unsigned long *offset);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
27
28
29
30
  /* Lookup an address.  modname is set to NULL if it's in the kernel. */
  const char *kallsyms_lookup(unsigned long addr,
  			    unsigned long *symbolsize,
  			    unsigned long *offset,
  			    char **modname, char *namebuf);
42e380832   Robert Peterson   Extend print_symb...
31
32
  /* Look up a kernel symbol and return it in a text buffer. */
  extern int sprint_symbol(char *buffer, unsigned long address);
0f77a8d37   Namhyung Kim   vsprintf: Introdu...
33
  extern int sprint_backtrace(char *buffer, unsigned long address);
42e380832   Robert Peterson   Extend print_symb...
34
35
  
  /* Look up a kernel symbol and print it to the kernel messages. */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
  extern void __print_symbol(const char *fmt, unsigned long address);
9d65cb4a1   Alexey Dobriyan   Fix race between ...
37
  int lookup_symbol_name(unsigned long addr, char *symname);
a5c43dae7   Alexey Dobriyan   Fix race between ...
38
  int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
9d65cb4a1   Alexey Dobriyan   Fix race between ...
39

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
44
45
  #else /* !CONFIG_KALLSYMS */
  
  static inline unsigned long kallsyms_lookup_name(const char *name)
  {
  	return 0;
  }
75a66614d   Anders Kaseorg   Ksplice: Add func...
46
47
48
49
50
51
52
  static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  						    struct module *,
  						    unsigned long),
  					  void *data)
  {
  	return 0;
  }
ffc508919   Franck Bui-Huu   [PATCH] Create ka...
53
54
55
56
57
58
  static inline int kallsyms_lookup_size_offset(unsigned long addr,
  					      unsigned long *symbolsize,
  					      unsigned long *offset)
  {
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
61
62
63
64
65
  static inline const char *kallsyms_lookup(unsigned long addr,
  					  unsigned long *symbolsize,
  					  unsigned long *offset,
  					  char **modname, char *namebuf)
  {
  	return NULL;
  }
42e380832   Robert Peterson   Extend print_symb...
66
67
68
69
70
  static inline int sprint_symbol(char *buffer, unsigned long addr)
  {
  	*buffer = '\0';
  	return 0;
  }
0f77a8d37   Namhyung Kim   vsprintf: Introdu...
71
72
73
74
75
  static inline int sprint_backtrace(char *buffer, unsigned long addr)
  {
  	*buffer = '\0';
  	return 0;
  }
9d65cb4a1   Alexey Dobriyan   Fix race between ...
76
77
78
79
  static inline int lookup_symbol_name(unsigned long addr, char *symname)
  {
  	return -ERANGE;
  }
a5c43dae7   Alexey Dobriyan   Fix race between ...
80
81
82
83
  static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
  {
  	return -ERANGE;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
85
86
87
88
89
90
91
92
93
  /* Stupid that this does nothing, but I didn't create this mess. */
  #define __print_symbol(fmt, addr)
  #endif /*CONFIG_KALLSYMS*/
  
  /* This macro allows us to keep printk typechecking */
  static void __check_printsym_format(const char *fmt, ...)
  __attribute__((format(printf,1,2)));
  static inline void __check_printsym_format(const char *fmt, ...)
  {
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94

b02454f43   Heiko Carstens   [PATCH] lockdep: ...
95
96
97
98
99
100
  static inline void print_symbol(const char *fmt, unsigned long addr)
  {
  	__check_printsym_format(fmt, "");
  	__print_symbol(fmt, (unsigned long)
  		       __builtin_extract_return_addr((void *)addr));
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101

2711b793e   Vegard Nossum   kallsyms: unify 3...
102
103
  static inline void print_ip_sym(unsigned long ip)
  {
3f1712bac   Vegard Nossum   print_ip_sym(): u...
104
105
  	printk("[<%p>] %pS
  ", (void *) ip, (void *) ip);
2711b793e   Vegard Nossum   kallsyms: unify 3...
106
  }
8d8fdf5c7   Heiko Carstens   [PATCH] lockdep: ...
107

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
  #endif /*_LINUX_KALLSYMS_H*/