Produce section with tracepoint callsite addresses
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Simon Marchi
so that it's possible to determine where each tracepoint is used (and supporting tracepoints being called at multiple locations). I made a prototype of gdb that reads the content of this section, available here:
Oops, here's the link to the right branch:
Quoted 21 lines · ----- On Sep 2, 2015, at 5:49 PM, Simon Marchi [email protected] wrote:
There used to be an integration between lttng-ust 0.x and gdb, where gdb could list locations of ust tracepoints and put its own tracepoints there. That means that this old-style lttng-ust marker:
trace_mark(ust, bar33, "str %s", "FOOBAZ");could be used to set a gdb tracepoint like this:
(gdb) strace -m ust/bar33
Later, support for SystemTap and DTrace tracepoints was added in the form of probe points. Therefore, it's possible to list static probes found in the program like this:
(gdb) info probes
Type Provider Name Where Semaphore Object
stapze_providerze_tracepoint0x00000000004004f1It's then possible to do many fun things with it, including setting a breakpoint at its location:
Quoted 7 lines
(gdb) b -probe ze_provider:ze_tracepoint
Breakpoint 1 at0x4004f1I'd like if gdb was able to do the same for lttng-ust tracepoints. Currently, you can make lttng-ust's tracepoint appear as SystemTap probes (--with-sdt), so one could argue that it already works, but it would be preferrable to have "native" support.
Indeed.
Quoted 28 lines
This patch adds a section in the ELF (
__lttng_callsites) and records pairs of pointers in it:<address of corresponding struct tracepoint> <callsite address>
so that it's possible to determine where each tracepoint is used (and supporting tracepoints being called at multiple locations). I made a prototype of gdb that reads the content of this section, available here:
https://github.com/simark/binutils-gdb.git
This is the result (not very exciting, but still):
(gdb) info probes
Type Provider Name Where Semaphore Object
lttngsample_componentmessage0x0000000000400cedn/a/home/emaisin/build/lttng-ust/doc/examples/easy-ust/sampleI'd like to know what you think about the way the information is laid out in the ELF. What should I be concerned about, especially in terms of future-proofing and portability? One thing I am aware of is that the use of an 8 bytes pointer for 32-bits architectures is not optimal (we are wasting _4
bytes_every time), but I couldn't find a way to tell gas "push a data word the size of a pointer". We would probably have to get an architecture-specific macro to define the right assembler directive for a pointer.
Quoted 1 line
Thanks in advance for the comments!
We should probably handle tracelog() and tracef() instrumentation facilities too.
About the 32 vs 64-bit: the Linux kernel has a macro called ASM_PTR() which does something like this. Basically, use preprocessor ifdefs to find out the size of long, and define a ASM_PTR with the right string result accordingly. Then use this macro in the assembly. See liburcu CAA_BITS_PER_LONG which can be used for this.
Quoted 9 lines
---
include/lttng/tracepoint.h| 16 +++++++++++++++-1 file changed, 15 insertions(+), 1 deletion(-)include/lttng/tracepoint.h +0
-0
include/lttng/tracepoint.h extern "C" { · line 58
Quoted 6 lines
include/lttng/tracepoint.h +3
-0@@ -53,13 +53,17 @@ extern "C" {#define tracepoint (provider, name, ...) \ do { \ + asm(".pushsection __lttng_callsites, \"a\", @progbits\n" \ + ".8byte __tracepoint_" #provider "___" #name "\n" \ + ".8byte 456f\n" \
Why 456 ? Could it simply be 1f ? It's relative to this asm snippet anyway, so I'm not sure why we would care about number clashes.
Quoted 17 lines
include/lttng/tracepoint.h +2
-1+" .popsection\n" \ + "456:\n"); \ STAP_PROBEV(provider, name, ## __VA_ARGS__); \if (tracepoint_enabled (provider, name)) \do_tracepoint (provider, name, __VA_ARGS__); \ } while (0)#define TP_ARGS (...) __VA_ARGS__ -/* * TP_ARGS takes tuples of type, argument separated by a comma. * It can take up to 10 tuples (which means that less than 10 tuples is @@ -323,6 +327,16 @@ extern struct lttng_ust_tracepoint * const__start___tracepoints_ptrs[]
__attribute__((weak, visibility("hidden"))); extern struct lttng_ust_tracepoint * const __stop___tracepoints_ptrs[] __attribute__((weak, visibility("hidden")));
include/lttng/tracepoint.h
Quoted 3 lines
include/lttng/tracepoint.h +3
-0+extern void * const __start___lttng_callsites[] + __attribute__((weak, visibility("hidden"))); +extern void *const __stop___lttng_callsites[]
If it's specific to lttng tracepoints, the name should say so. E.g. we may need something else for lttng tracef and tracelog.
Quoted 9 lines
include/lttng/tracepoint.h +6
-0+ __attribute__((weak, visibility("hidden"))); + +/* +* Make sure __start/stop__lttng_callsites symbols are generated. +*/ +static const void * const ___start__lttng_callsites __attribute__((used)) =
__start___lttng_callsites;
+static const void * const___stop__lttng_callsites__attribute__((used)) =__stop___lttng_callsites;
Did you test this in various build configurations ?
- Executable with single instrumented .o,
- Executable with many instrumented .o,
- .so with one instrumented .o,
- .so with many .o,
- Instrumented exec + lib.
We should add those tests into lttng-ust.
Thanks,
Mathieu
Quoted 11 lines
/*
* WhenTRACEPOINT_PROBE_DYNAMIC_LINKAGEis defined, we do not emit a
--
2.5.1_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com