Re: Tracing kernel modules
Mathieu Desnoyers <[email protected]>
| Newsgroups | gmane.linux.kernel.tracing |
|---|---|
| Message-ID | <20070413213528.GA28283@Krystal> |
* Filled Void ([email protected]) wrote: > Hi, > > I'm trying to trace my own kernel module, so I've created an XML > facilities file with the events I want and used "genevent" to generate the > necessary C code for it. First, it seems that genevent doesn't create the > ltt_get_index_from_facility_mymodule() function that the > ltt-facility-mymodule.h uses. Am I suppose to create this manually or add > the following to the top of ltt-facility-mymodule.h: > > #include <ltt/ltt-facility-select-default.h> > #define ltt_get_index_from_facility_mymodule ltt_get_index_from_facility > Yes, you have to do this manually. > Second, I'd like to keep my module (and the facility loader) completely > separate from the kernel source. So I've got my module in a completely > separate directory and the ltt facility loader in a subdirectory "ltt" of > that directory. Using the above method, I get the following errors when > compiling my module: > > WARNING: "ltt_facility_get_mymodule_29DE9FD8" > [/home/fv/mymodule/mymodule.ko] undefined! > WARNING: "ltt_get_index_from_facility" [/home/fv/mymodule/mymodule.ko] > undefined! > Make sure you include <ltt/ltt-facility-select-default.h> and then your local <ltt-facility-mymodule.h> headers (in this order). both ltt_facility_get_mymodule_29DE9FD8 and ltt_get_index_from_facility are defined in headers : ltt_facility_get_mymodule_29DE9FD8 in ltt-facility-id-mymodule.h (included by ltt-facility-mymodule.h) : make sure the include is correct, since I suspect your header is not in the kernel tree. ltt_get_index_from_facility is defined in <ltt/ltt-facility-select-default.h>, which must be included before ltt-facility-mymodule.h. > Since the facility loader is compiled as a separate module, it should wait > until runtime to lookup those symbols. What am I missing? Those should be defined by the headers and are required by _both_ the facility loader and the module you try to instrument. > Is this the > recommended approach for tracing modules? Also, the QUICKSTART guide > mentions creating a probe, but the README for genevent doesn't. Isn't the > README more up-to-date? The QUICKSTART specifies that you can use the markers/probe infrastructure to connect a probe dynamically to the marker in your code. The idea : Add a MARK(subsystem_event, "format string", args); in your code Create a probe like the ones found in ltt/probes, which will connect a callback to the marker when the module is loaded. Within the probe callback, call the tracer trace_facility_event(args) function, passing the parameters expected in the variable arguments. So, basically, it's a way to split the tracer functions from the kernel code. But you can always call the tracer functions directly from the kernel code if you wish, just like described in genevent. I hope it makes things clearer. Keep in mind that this is not meant to be the final interface for adding new intrumentation. The version found in LTTng 0.9.X differs in that it does not rely on genevent anymore : the serialization of the information passed as parameter to the marker is now done dynamically by using the format string. Mathieu > > Thanks! > > fv > _______________________________________________ > Ltt-dev mailing list > [email protected] > http://listserv.shafik.org/mailman/listinfo/ltt-dev > -- Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68