Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: francis.giraldeau@gmail.com (Francis Giraldeau)
Subject: [lttng-dev] [RFC] User space stack trace on system calls
Date: Sat, 31 Aug 2013 01:16:49 -0400	[thread overview]
Message-ID: <52217C41.20604@gmail.com> (raw)
In-Reply-To: <52216A3F.8000200@gmail.com>

Le 2013-08-30 23:59, Francis Giraldeau a ?crit :
> On 2013-08-30 23:38, Francis Giraldeau wrote :
>> We actually
>> found a way to insert code inside the probe with code blocks that
>> returns a value. Thanks to Simon Marchi for this C trick!
> 
> Well, it turns out that the function save_stack_trace_user() is called
> even when the tracepoint is not enabled, so this is a major issue.
> Hum... Then why does it work for UST tracepoint macro?

By moving the probe custom code inside the macro itself, it's called
only when the tracepoint is enabled. The difference is that the UST
tracepoint in the C code is a macro that gets expanded, while in the
kernel trace_somethig is an actual function call.

diff --git a/instrumentation/events/lttng-module/addons.h
b/instrumentation/events/lttng-module/addons.h
index 8a764b0..26623b3 100644
--- a/instrumentation/events/lttng-module/addons.h
+++ b/instrumentation/events/lttng-module/addons.h
@@ -200,15 +200,23 @@ TRACE_EVENT(sys_entry,
 )

 TRACE_EVENT(sys_entry_callsite,
-       TP_PROTO(int id, int len, unsigned long *entries),
-       TP_ARGS(id, len, entries),
+       TP_PROTO(int id),
+       TP_ARGS(id),
        TP_STRUCT__entry(
                __field(short, id)
-               __dynamic_array_hex(unsigned long, callsite, len)
+               __dynamic_array_hex(unsigned long, callsite, ({
+                       extern int stack_trace_get_size(void);
+                       int x = stack_trace_get_size();
+                       x;
+               }))
        ),
        TP_fast_assign(
                tp_assign(id, id)
-               tp_memcpy_dyn(callsite, entries)
+               tp_memcpy_dyn(callsite, ({
+                       extern unsigned long *stack_trace_get_entries(void);
+                       unsigned long *entries = stack_trace_get_entries();
+                       entries;
+               }))
        ),
        TP_printk("%d", __entry->id)
 )





      reply	other threads:[~2013-08-31  5:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-31  3:38 Francis Giraldeau
2013-08-31  3:59 ` Francis Giraldeau
2013-08-31  5:16   ` Francis Giraldeau [this message]

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=52217C41.20604@gmail.com \
    --to=francis.giraldeau@gmail.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