1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SystemTap: probes.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>probes.c</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* -*- linux-c -*- */</span>
00002 <span class="comment"></span>
00003 <span class="comment">/** Create a new map.</span>
00004 <span class="comment"> * Maps must be created at module initialization time.</span>
00005 <span class="comment"> * @param max_entries The maximum number of entries allowed. Currently that </span>
00006 <span class="comment"> * will be allocated dynamically.</span>
00007 <span class="comment"> * @param type Type of values stored in this map. </span>
00008 <span class="comment"> * @return A MAP on success or NULL on failure.</span>
00009 <span class="comment"> */</span>
00010
00011
00012 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> long (*_stp_lookup_name)(<span class="keywordtype">char</span> *name)=(<span class="keywordtype">void</span> *)KALLSYMS_LOOKUP_NAME;
00013
00014 <span class="keywordtype">void</span> _stp_unregister_jprobes (<span class="keyword">struct</span> jprobe *probes, <span class="keywordtype">int</span> num_probes)
00015 {
00016 <span class="keywordtype">int</span> i;
00017 <span class="keywordflow">for</span> (i = 0; i < num_probes; i++)
00018 unregister_jprobe(&probes[i]);
00019 dlog ("All jprobes removed\n");
00020 }
00021
00022 <span class="keywordtype">int</span> _stp_register_jprobes (struct jprobe *probes, <span class="keywordtype">int</span> num_probes)
00023 {
00024 <span class="keywordtype">int</span> i, ret ;
00025 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> addr;
00026
00027 <span class="keywordflow">for</span> (i = 0; i < num_probes; i++) {
00028 addr =_stp_lookup_name((<span class="keywordtype">char</span> *)probes[i].kp.addr);
00029 <span class="keywordflow">if</span> (addr == 0) {
00030 dlog (<span class="stringliteral">"ERROR: function %s not found!\n"</span>,
00031 (<span class="keywordtype">char</span> *)probes[i].kp.addr);
00032 ret = -1; <span class="comment">/* FIXME */</span>
00033 <span class="keywordflow">goto</span> out;
00034 }
00035 dlog(<span class="stringliteral">"inserting jprobe at %s (%p)\n"</span>, probes[i].kp.addr, addr);
00036 probes[i].kp.addr = (kprobe_opcode_t *)addr;
00037 ret = register_jprobe(&probes[i]);
00038 <span class="keywordflow">if</span> (ret)
00039 goto out;
00040 }
00041 return 0;
00042 out:
00043 dlog ("probe module initialization failed. Exiting...\n");
00044 _stp_unregister_jprobes(probes, i);
00045 return ret;
00046 }
00047
00048 <span class="keywordtype">void</span> _stp_unregister_kprobes (struct kprobe *probes, <span class="keywordtype">int</span> num_probes)
00049 {
00050 <span class="keywordtype">int</span> i;
00051 <span class="keywordflow">for</span> (i = 0; i < num_probes; i++)
00052 unregister_kprobe(&probes[i]);
00053 dlog ("All kprobes removed\n");
00054 }
00055
00056 <span class="keywordtype">int</span> _stp_register_kprobes (struct kprobe *probes, <span class="keywordtype">int</span> num_probes)
00057 {
00058 <span class="keywordtype">int</span> i, ret ;
00059 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> addr;
00060
00061 <span class="keywordflow">for</span> (i = 0; i < num_probes; i++) {
00062 addr =_stp_lookup_name((<span class="keywordtype">char</span> *)probes[i].addr);
00063 <span class="keywordflow">if</span> (addr == 0) {
00064 dlog (<span class="stringliteral">"ERROR: function %s not found!\n"</span>,
00065 (<span class="keywordtype">char</span> *)probes[i].addr);
00066 ret = -1; <span class="comment">/* FIXME */</span>
00067 <span class="keywordflow">goto</span> out;
00068 }
00069 dlog(<span class="stringliteral">"inserting kprobe at %s (%p)\n"</span>, probes[i].addr, addr);
00070 probes[i].addr = (kprobe_opcode_t *)addr;
00071 ret = register_kprobe(&probes[i]);
00072 <span class="keywordflow">if</span> (ret)
00073 goto out;
00074 }
00075 return 0;
00076 out:
00077 dlog ("probe module initialization failed. Exiting...\n");
00078 _stp_unregister_kprobes(probes, i);
00079 return ret;
00080 }
00081
</pre></div><hr size="1"><address style="align: right;"><small>
Generated on Tue Mar 22 00:32:02 2005 for SystemTap.</small></body>
</html>
|