]>
Commit | Line | Data |
---|---|---|
93646f4d JS |
1 | // task finder for user tapsets |
2 | // Copyright (C) 2005-2009 Red Hat Inc. | |
3 | // Copyright (C) 2005-2007 Intel Corporation. | |
93646f4d JS |
4 | // |
5 | // This file is part of systemtap, and is free software. You can | |
6 | // redistribute it and/or modify it under the terms of the GNU General | |
7 | // Public License (GPL); either version 2, or (at your option) any | |
8 | // later version. | |
9 | ||
10 | ||
11 | #include "session.h" | |
12 | #include "tapsets.h" | |
13 | #include "task_finder.h" | |
14 | #include "translate.h" | |
15 | #include "util.h" | |
16 | ||
17 | #include <cstring> | |
18 | #include <string> | |
19 | ||
20 | ||
21 | using namespace std; | |
22 | using namespace __gnu_cxx; | |
23 | ||
24 | ||
25 | // ------------------------------------------------------------------------ | |
4df6689a SA |
26 | // task_finder and vma tracker derived 'probes': These don't really exist. |
27 | // The purpose of these is to ensure that _stp_vma_init()/_stp_vma_done() | |
28 | // and stap_start_task_finder()/stap_stop_task_finder() get called only | |
93646f4d JS |
29 | // once and in the right place. |
30 | // ------------------------------------------------------------------------ | |
31 | ||
32 | struct task_finder_derived_probe: public derived_probe | |
33 | { | |
34 | // Dummy constructor for gcc 3.4 compatibility | |
1c9bce2d | 35 | task_finder_derived_probe (): derived_probe (0, 0) { assert(0); } |
93646f4d JS |
36 | }; |
37 | ||
4df6689a SA |
38 | struct vma_tracker_derived_probe: public derived_probe |
39 | { | |
40 | // Dummy constructor for gcc 3.4 compatibility | |
41 | vma_tracker_derived_probe (): derived_probe (0, 0) { assert(0); } | |
42 | }; | |
43 | ||
93646f4d JS |
44 | |
45 | struct task_finder_derived_probe_group: public generic_dpg<task_finder_derived_probe> | |
46 | { | |
47 | public: | |
48 | void emit_module_decls (systemtap_session& ) { } | |
49 | void emit_module_init (systemtap_session& s); | |
f346b8b3 | 50 | void emit_module_post_init (systemtap_session& s); |
93646f4d | 51 | void emit_module_exit (systemtap_session& s); |
4df6689a | 52 | }; |
a057c85c | 53 | |
4df6689a SA |
54 | struct vma_tracker_derived_probe_group: public generic_dpg<vma_tracker_derived_probe> |
55 | { | |
56 | public: | |
57 | void emit_module_decls (systemtap_session& ) { } | |
58 | void emit_module_init (systemtap_session& s); | |
59 | void emit_module_exit (systemtap_session& s); | |
93646f4d JS |
60 | }; |
61 | ||
62 | ||
63 | void | |
64 | task_finder_derived_probe_group::emit_module_init (systemtap_session& s) | |
65 | { | |
66 | s.op->newline(); | |
67 | s.op->newline() << "/* ---- task finder ---- */"; | |
4df6689a | 68 | s.op->newline() << "rc = stap_start_task_finder();"; |
93646f4d JS |
69 | } |
70 | ||
71 | ||
f346b8b3 DS |
72 | void |
73 | task_finder_derived_probe_group::emit_module_post_init (systemtap_session& s) | |
74 | { | |
75 | s.op->newline() << "/* ---- task finder ---- */"; | |
76 | s.op->newline() << "stap_task_finder_post_init();"; | |
77 | } | |
78 | ||
79 | ||
93646f4d JS |
80 | void |
81 | task_finder_derived_probe_group::emit_module_exit (systemtap_session& s) | |
82 | { | |
83 | s.op->newline(); | |
84 | s.op->newline() << "/* ---- task finder ---- */"; | |
85 | s.op->newline() << "stap_stop_task_finder();"; | |
4df6689a SA |
86 | } |
87 | ||
88 | ||
89 | void | |
90 | vma_tracker_derived_probe_group::emit_module_init (systemtap_session& s) | |
91 | { | |
92 | s.op->newline(); | |
93 | s.op->newline() << "/* ---- vma tracker ---- */"; | |
94 | s.op->newline() << "rc = _stp_vma_init();"; | |
95 | } | |
96 | ||
14fc9001 | 97 | |
4df6689a SA |
98 | void |
99 | vma_tracker_derived_probe_group::emit_module_exit (systemtap_session& s) | |
100 | { | |
101 | s.op->newline(); | |
102 | s.op->newline() << "/* ---- vma tracker ---- */"; | |
103 | s.op->newline() << "_stp_vma_done();"; | |
93646f4d JS |
104 | } |
105 | ||
106 | ||
107 | // Declare that task_finder is needed in this session | |
108 | void | |
109 | enable_task_finder(systemtap_session& s) | |
110 | { | |
111 | if (! s.task_finder_derived_probes) | |
4df6689a | 112 | s.task_finder_derived_probes = new task_finder_derived_probe_group(); |
a057c85c MW |
113 | } |
114 | ||
115 | // Declare that vma tracker is needed in this session, | |
116 | // implies that the task_finder is needed. | |
117 | void | |
118 | enable_vma_tracker(systemtap_session& s) | |
119 | { | |
120 | enable_task_finder(s); | |
4df6689a SA |
121 | if (! s.vma_tracker_derived_probes) |
122 | s.vma_tracker_derived_probes = new vma_tracker_derived_probe_group(); | |
a057c85c MW |
123 | } |
124 | ||
125 | // Whether the vma tracker is needed in this session. | |
126 | bool | |
127 | vma_tracker_enabled(systemtap_session& s) | |
128 | { | |
4df6689a | 129 | return s.vma_tracker_derived_probes; |
93646f4d JS |
130 | } |
131 | ||
93646f4d | 132 | /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ |