From: jderehag@hotmail.com (Jesper Derehag)
Subject: [lttng-dev] singleton tracepoints?
Date: Fri, 24 Apr 2015 08:48:14 +0000 [thread overview]
Message-ID: <DUB123-W3249E97F49BFE46B49CB85DDEC0@phx.gbl> (raw)
Hi,
I have been thinking a little bit about if there is some way to both define/implement and call tracepoints in a single call.
Normally, defining tracepoints goes something along these lines:
1. Define tracepoint in tp.h?
? ? ? ? TRACE_EVENT(..)
2. Generate probes in tp.c
? ? ? ?&define TRACEPOINT_CREATE_PROBES
? ? ? ?&include "tp.h"
3. Call tracepoint in main.c
? ? ? ?tracepoint(...);
Obviously you could join points 1&2 if you use?lttng-gen-tp. It requires that you have a tracepoint definintioin file somewhere.
So the use case would then be to both "define" and call tracepoints in a single call.
I was thinking of something like this:
(Bad name, I know..)
singleton_tracepoint(TRACE_WARN, provider, name, const char*, "Something bad has happened!");
So the hard question then, how could we implement this?
I have so far thought of 4 possible approaches (and they are really not very well thought through, kind of brainstorming here):
1. Continue with the macro-magic as previously used tracepoint-event.h
? ? Cant think of any way to make this work. tracepoint-event.h hevaily relies on recursively including itself and the calling tracepoint definition.
? ? To replicate this behavior from inside a function simply wont work, or?
2. Somehow circumvent the "recursive includes from inside a function" problem by utilizing c++ function templates (or possibly lambda functions from c++11)
? ? Will likely not work either since templates are expanded during compilation and not during preprocessing. So the idea of creating a new scope
? ? within the template to create probes will not work either?
3. Re-implement the entire tracepoint callstack
? ? Getting a little bit closer, by doing that we can atleast inject trace packets with the correct formating and so on.
? ? But I dont see how one could also maintain the user workflow of beeing able to list probes and so on without having registered it?
? ??
? ? 3.1 Lazy register probes
? ? ? ? ? If probe was not registered previously (as we pass the singleton_tracepoint), register it then.
? ? 3.2 Never register singleton probes
? ? ? ? ? Make it possible to enable unknown tracepoints, perhaps it is already?
4. Extend lttng-gen-tp to also parse src-code for singleton_tracepoints and then generate probes as usual based on the definition.
? ? Could maybe be a little bit tricky since you need to do a bit of fuzzy parsing (exclude mentions of singleton_tracepoint(..) in comments and so on).
? ? But definetly the easiest (and portable) implementation, but would significantly add to build times.
Thoughts?
Regards,
Jesper
reply other threads:[~2015-04-24 8:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DUB123-W3249E97F49BFE46B49CB85DDEC0@phx.gbl \
--to=jderehag@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox