]> sourceware.org Git - systemtap.git/blame - task_finder.cxx
tracepoints: Work with the tracequery's .o rather than .ko
[systemtap.git] / task_finder.cxx
CommitLineData
93646f4d
JS
1// task finder for user tapsets
2// Copyright (C) 2005-2009 Red Hat Inc.
3// Copyright (C) 2005-2007 Intel Corporation.
4// Copyright (C) 2008 James.Bottomley@HansenPartnership.com
5//
6// This file is part of systemtap, and is free software. You can
7// redistribute it and/or modify it under the terms of the GNU General
8// Public License (GPL); either version 2, or (at your option) any
9// later version.
10
11
12#include "session.h"
13#include "tapsets.h"
14#include "task_finder.h"
15#include "translate.h"
16#include "util.h"
17
18#include <cstring>
19#include <string>
20
21
22using namespace std;
23using namespace __gnu_cxx;
24
25
26// ------------------------------------------------------------------------
27// task_finder derived 'probes': These don't really exist. The whole
28// purpose of the task_finder_derived_probe_group is to make sure that
29// stap_start_task_finder()/stap_stop_task_finder() get called only
30// once and in the right place.
31// ------------------------------------------------------------------------
32
33struct task_finder_derived_probe: public derived_probe
34{
35 // Dummy constructor for gcc 3.4 compatibility
1c9bce2d 36 task_finder_derived_probe (): derived_probe (0, 0) { assert(0); }
93646f4d
JS
37};
38
39
40struct task_finder_derived_probe_group: public generic_dpg<task_finder_derived_probe>
41{
42public:
43 void emit_module_decls (systemtap_session& ) { }
44 void emit_module_init (systemtap_session& s);
45 void emit_module_exit (systemtap_session& s);
a057c85c
MW
46
47 // Whether or not to initialize the vma tracker
48 bool need_vma_tracker;
93646f4d
JS
49};
50
51
52void
53task_finder_derived_probe_group::emit_module_init (systemtap_session& s)
54{
55 s.op->newline();
a057c85c
MW
56 if (need_vma_tracker)
57 {
58 s.op->newline() << "/* ---- vma tracker ---- */";
7d8aa2ee 59 s.op->newline() << "rc = _stp_vma_init();";
a057c85c
MW
60 s.op->newline();
61 }
62
93646f4d 63 s.op->newline() << "/* ---- task finder ---- */";
a057c85c
MW
64 s.op->newline() << "if (rc == 0) {";
65 s.op->newline(1) << "rc = stap_start_task_finder();";
93646f4d
JS
66
67 s.op->newline() << "if (rc) {";
68 s.op->newline(1) << "stap_stop_task_finder();";
69 s.op->newline(-1) << "}";
a057c85c 70 s.op->newline(-1) << "}";
93646f4d
JS
71}
72
73
74void
75task_finder_derived_probe_group::emit_module_exit (systemtap_session& s)
76{
77 s.op->newline();
78 s.op->newline() << "/* ---- task finder ---- */";
79 s.op->newline() << "stap_stop_task_finder();";
80}
81
82
83// Declare that task_finder is needed in this session
84void
85enable_task_finder(systemtap_session& s)
86{
87 if (! s.task_finder_derived_probes)
a057c85c
MW
88 {
89 s.task_finder_derived_probes = new task_finder_derived_probe_group();
90 s.task_finder_derived_probes->need_vma_tracker = false;
91 }
92}
93
94// Declare that vma tracker is needed in this session,
95// implies that the task_finder is needed.
96void
97enable_vma_tracker(systemtap_session& s)
98{
99 enable_task_finder(s);
100 s.task_finder_derived_probes->need_vma_tracker = true;
101}
102
103// Whether the vma tracker is needed in this session.
104bool
105vma_tracker_enabled(systemtap_session& s)
106{
107 return (s.task_finder_derived_probes
108 && s.task_finder_derived_probes->need_vma_tracker);
93646f4d
JS
109}
110
93646f4d 111/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
This page took 0.072785 seconds and 5 git commands to generate.