remove files unneeded for lttv
[lttv.git] / lttv / doc / developer / developer_guide / html / x23.html
CommitLineData
7cb02901 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
2<HTML
3><HEAD
4><TITLE
5>A typical module</TITLE
6><META
7NAME="GENERATOR"
8CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9REL="HOME"
10TITLE="Linux Trace Toolkit Viewer Developer Guide"
11HREF="index.html"><LINK
12REL="UP"
13TITLE="Linux Trace Toolkit Viewer Text Module Tutorial"
14HREF="c18.html"><LINK
15REL="PREVIOUS"
16TITLE="Linux Trace Toolkit Viewer Text Module Tutorial"
17HREF="c18.html"><LINK
18REL="NEXT"
19TITLE="The hooks"
20HREF="x33.html"></HEAD
21><BODY
22CLASS="sect1"
23BGCOLOR="#FFFFFF"
24TEXT="#000000"
25LINK="#0000FF"
26VLINK="#840084"
27ALINK="#0000FF"
28><DIV
29CLASS="NAVHEADER"
30><TABLE
31SUMMARY="Header navigation table"
32WIDTH="100%"
33BORDER="0"
34CELLPADDING="0"
35CELLSPACING="0"
36><TR
37><TH
38COLSPAN="3"
39ALIGN="center"
40>Linux Trace Toolkit Viewer Developer Guide</TH
41></TR
42><TR
43><TD
44WIDTH="10%"
45ALIGN="left"
46VALIGN="bottom"
47><A
48HREF="c18.html"
49ACCESSKEY="P"
50>Prev</A
51></TD
52><TD
53WIDTH="80%"
54ALIGN="center"
55VALIGN="bottom"
56>Chapter 1. Linux Trace Toolkit Viewer Text Module Tutorial</TD
57><TD
58WIDTH="10%"
59ALIGN="right"
60VALIGN="bottom"
61><A
62HREF="x33.html"
63ACCESSKEY="N"
64>Next</A
65></TD
66></TR
67></TABLE
68><HR
69ALIGN="LEFT"
70WIDTH="100%"></DIV
71><DIV
72CLASS="sect1"
73><H1
74CLASS="sect1"
75><A
76NAME="AEN23"
77>1.2. A typical module</A
78></H1
79><P
80>&#13;A typical module must have a init() and destroy() function. Please refer to
81lttv/modules/text/textDump.c for the detail of these functions.
82</P
83><P
84>&#13;The init() function is called when the library is loaded and destroy()
85inversely. It adds options to the command line by calling "lttv_option_add" from
86option.h
87</P
88><P
89>&#13;The module communicates with the main lttv program through the use of global
90attributes. Use lttv/attribute.h, lttv/iattribute.h and lttv/lttv.h, and then
91LTTV_IATTRIBUTE(lttv_global_attributes()) to get the pointer to these
92global attributes.
93</P
94><P
95>&#13;You can then add your hooks (functions that follows the prototype of a hook, as
96defined in lttv/hook.h) in the different hook lists defined in lttv/lttv.h. Note
97that hooks have an assigned priority. This is necessary to inform the trace
98reader that a specific hook needs to be called, for example, before or after the
99state update done for an event by the state module. For that specific example, a
100hook could use the LTTV_PRIO_STATE-5 to get called before the state update and a
101second hook could use the LTTV_PRIO_STATE+5 to get called after the state
102update. This is especially important for graphical module, which is the subject
103of a the chapter named "Linux Trace Toolkit Viewer Graphical Module Tutorial".
104</P
105><P
106>&#13;You should also take a look at lttv/state.c, where by_id hooks are used. When
107you only need some specific events, you should use this interface. It makes the
108event filtering sooner in the dispatch chain : you hook doesn't have to be
109called for each event, only the ones selected. That improves the performances a
110lot!
111</P
112><P
113>&#13;Note that you should use the lttv_trace_find_hook method from
114lttv/tracecontext.h to connect the hook to the right facility/event type. See
115state.c for an example. A problem that may arise is that the LttvTraceHook
116structure must be passed as hook_data when registering the hook. In fact, it is
117not necessary for it to be directly passed as the hook_data parameter. As long
118as the hook function can access the LttvTraceHook fields necessary to parse the
119LttEvent, there is no problem. In a complex viewer where you need a pointer to
120your own data structure, just keep a pointer to the LttvTraceHook structure
121inside your own data structure, and give to pointer to your data structure in
122parameter as the hook_data.
123</P
124><P
125>&#13;Then, you should use the macro LTTV_MODULE, defined in lttv/module.h. It allows
126you to specify the module name, a short and a long description, the init and
127destroy functions and the module dependencies. That permits to the module
128backend to load the right dependencies when needed.
129</P
130><P
131>&#13;A typical text module will depend on batchAnalysis for the batch computation of a
132trace, and simply register before and after trace hooks, as weel as the most
133important one : a event hook.
134</P
135></DIV
136><DIV
137CLASS="NAVFOOTER"
138><HR
139ALIGN="LEFT"
140WIDTH="100%"><TABLE
141SUMMARY="Footer navigation table"
142WIDTH="100%"
143BORDER="0"
144CELLPADDING="0"
145CELLSPACING="0"
146><TR
147><TD
148WIDTH="33%"
149ALIGN="left"
150VALIGN="top"
151><A
152HREF="c18.html"
153ACCESSKEY="P"
154>Prev</A
155></TD
156><TD
157WIDTH="34%"
158ALIGN="center"
159VALIGN="top"
160><A
161HREF="index.html"
162ACCESSKEY="H"
163>Home</A
164></TD
165><TD
166WIDTH="33%"
167ALIGN="right"
168VALIGN="top"
169><A
170HREF="x33.html"
171ACCESSKEY="N"
172>Next</A
173></TD
174></TR
175><TR
176><TD
177WIDTH="33%"
178ALIGN="left"
179VALIGN="top"
180>Linux Trace Toolkit Viewer Text Module Tutorial</TD
181><TD
182WIDTH="34%"
183ALIGN="center"
184VALIGN="top"
185><A
186HREF="c18.html"
187ACCESSKEY="U"
188>Up</A
189></TD
190><TD
191WIDTH="33%"
192ALIGN="right"
193VALIGN="top"
194>The hooks</TD
195></TR
196></TABLE
197></DIV
198></BODY
199></HTML
200>
This page took 0.055451 seconds and 4 git commands to generate.