lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
* two tracepoints header files of one provider
@ 2019-10-07 13:59 Yonghong Yan
  0 siblings, 0 replies; 4+ messages in thread
From: Yonghong Yan @ 2019-10-07 13:59 UTC (permalink / raw)
  To: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 119 bytes --]

For lttng-ust, can I put the tracepoint definition in two files, but they
use the same provider.


Thank you.
Yonghong

[-- Attachment #1.2: Type: text/html, Size: 498 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: two tracepoints header files of one provider
       [not found]   ` <CACJEY840r3D+SSGAkRnkAMpPJhQ7mUC2vj19cZFkVpgoxz1e8w@mail.gmail.com>
@ 2019-10-07 19:53     ` Mathieu Desnoyers
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2019-10-07 19:53 UTC (permalink / raw)
  To: Yonghong Yan; +Cc: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 4304 bytes --]

----- On Oct 7, 2019, at 12:42 PM, Yonghong Yan <yanyh15@gmail.com> wrote: 

> Thank you.

> I got most. To confirm, I have two header files, each defines its own
> tracepoint, they are from the same provider. The source files that use the
> header files have its own #define TRACEPOINT_CREATE_PROBES and #define
> TRACEPOINT_DEFINE. This won't work since two files have those defines. But if I
> remove #define TRACEPOINT_CREATE_PROBES#define TRACEPOINT_DEFINE from one of
> the two .c file, it should work.

The example below is bogus. 

Each of your tp_one.h and tp_two.h should have its own provider name, not "hello_world" for both. 

You should _only_ have a single header implementation file per provider name within an application. 

In my previous email, I was only refering to a case where you would want to define+create probes within 
a compile unit, and use the tracepoints (call them) from various other compile units in the program. 

Thanks, 

Mathieu 

> tp_one.h file:

> #undef TRACEPOINT_PROVIDER #define TRACEPOINT_PROVIDER hello_world #undef
> TRACEPOINT_INCLUDE #define TRACEPOINT_INCLUDE "./tp_one.h" #if
> !defined(_TP_ONE_H) || defined(TRACEPOINT_HEADER_MULTI_READ) #define _TP_ONE_H
> #include <lttng/tracepoint.h> TRACEPOINT_EVENT ( hello_world ,
> my_first_tracepoint , TP_ARGS ( int , my_integer_arg , char * , my_string_arg
> ), TP_FIELDS ( ctf_string ( my_string_field , my_string_arg ) ctf_integer ( int
> , my_integer_field , my_integer_arg ) ) ) #endif /* _TP_ONE_H */ #include
> <lttng/tracepoint-event.h>

> tp_one.c
> #define TRACEPOINT_CREATE_PROBES #define TRACEPOINT_DEFINE #include "tp_one.h"

> tp_two.h file:

> #undef TRACEPOINT_PROVIDER #define TRACEPOINT_PROVIDER hello_world #undef
> TRACEPOINT_INCLUDE #define TRACEPOINT_INCLUDE "./tp_two.h" #if
> !defined(_TP_TWO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) #define _TP_TWO_H
> #include <lttng/tracepoint.h> TRACEPOINT_EVENT ( hello_world ,
> my_second_tracepoint , TP_ARGS ( int , my_integer_arg , char * , my_string_arg
> ), TP_FIELDS ( ctf_string ( my_string_field , my_string_arg ) ctf_integer ( int
> , my_integer_field , my_integer_arg ) ) ) #endif /* _TP_TWO_H */ #include
> <lttng/tracepoint-event.h>

> tp_two.c
> #define TRACEPOINT_CREATE_PROBES #define TRACEPOINT_DEFINE #include "tp_two.h"

> hello.c
> use the two tracepoints defined in the two files.

> To compile (compile file one by one).
> gcc -o hello tp-one.c tp-two.c hello.c -llttng-ust -ldl

> On Mon, Oct 7, 2019 at 12:22 PM Mathieu Desnoyers < [
> mailto:mathieu.desnoyers@efficios.com | mathieu.desnoyers@efficios.com ] >
> wrote:

>> ----- On Oct 7, 2019, at 9:59 AM, Yonghong Yan [ mailto:yanyh15@gmail.com |
>> yanyh15@gmail.com ] wrote:

>> > For lttng-ust, can I put the tracepoint definition in two files, but they use
>> > the same provider.

>> Based on the terminology here: [
>> https://lttng.org/docs/v2.10/#doc-tracing-your-own-user-application |
>> https://lttng.org/docs/v2.10/#doc-tracing-your-own-user-application ]

>> You need to have at most one instance of your tracepoint provider where
>> the header is included with TRACEPOINT_CREATE_PROBES, and exactly one
>> instance where TRACEPOINT_DEFINE is defined. (both can end up being within
>> the same object if you wish).

>> Then you can include your tracepoint provider header file at will across
>> other compile units in your program. Just make sure none of
>> TRACEPOINT_CREATE_PROBES nor TRACEPOINT_DEFINE are defined in those other
>> compile units. You can therefore call tracepoints from a given probe from
>> various compile units in your program.

>> Hoping this helps clarifying things,

>> Mathieu

>> > Thank you.
>> > Yonghong

>> > _______________________________________________
>> > lttng-dev mailing list
>> > [ mailto:lttng-dev@lists.lttng.org | lttng-dev@lists.lttng.org ]
>>> [ https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev |
>> > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev ]
>> --
>> Mathieu Desnoyers
>> EfficiOS Inc.
>> [ http://www.efficios.com/ | http://www.efficios.com ]

> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 

[-- Attachment #1.2: Type: text/html, Size: 28451 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: two tracepoints header files of one provider
       [not found] ` <625499791.2728.1570465339442.JavaMail.zimbra@efficios.com>
@ 2019-10-07 16:42   ` Yonghong Yan
       [not found]   ` <CACJEY840r3D+SSGAkRnkAMpPJhQ7mUC2vj19cZFkVpgoxz1e8w@mail.gmail.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Yonghong Yan @ 2019-10-07 16:42 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 3237 bytes --]

Thank you.

I got most. To confirm, I have two header files, each defines its own
tracepoint, they are from the same provider. The source files that use the
header files have its own #define TRACEPOINT_CREATE_PROBES and #define
TRACEPOINT_DEFINE. This won't work since two files have those defines. But
if I remove #define TRACEPOINT_CREATE_PROBES#define TRACEPOINT_DEFINE from
one of the two .c file, it should work.

tp_one.h file:

#undef TRACEPOINT_PROVIDER#define TRACEPOINT_PROVIDER hello_world
#undef TRACEPOINT_INCLUDE#define TRACEPOINT_INCLUDE "./tp_one.h"
#if !defined(_TP_ONE_H) ||
defined(TRACEPOINT_HEADER_MULTI_READ)#define _TP_ONE_H
#include <lttng/tracepoint.h>
TRACEPOINT_EVENT(
    hello_world,
    my_first_tracepoint,
    TP_ARGS(
        int, my_integer_arg,
        char*, my_string_arg
    ),
    TP_FIELDS(
        ctf_string(my_string_field, my_string_arg)
        ctf_integer(int, my_integer_field, my_integer_arg)
    ))
#endif /* _TP_ONE_H */
#include <lttng/tracepoint-event.h>


tp_one.c

#define TRACEPOINT_CREATE_PROBES#define TRACEPOINT_DEFINE
#include "tp_one.h"


tp_two.h file:

#undef TRACEPOINT_PROVIDER#define TRACEPOINT_PROVIDER hello_world
#undef TRACEPOINT_INCLUDE#define TRACEPOINT_INCLUDE "./tp_two.h"
#if !defined(_TP_TWO_H) ||
defined(TRACEPOINT_HEADER_MULTI_READ)#define _TP_TWO_H
#include <lttng/tracepoint.h>
TRACEPOINT_EVENT(
    hello_world,
    my_second_tracepoint,
    TP_ARGS(
        int, my_integer_arg,
        char*, my_string_arg
    ),
    TP_FIELDS(
        ctf_string(my_string_field, my_string_arg)
        ctf_integer(int, my_integer_field, my_integer_arg)
    ))
#endif /* _TP_TWO_H */
#include <lttng/tracepoint-event.h>


tp_two.c

#define TRACEPOINT_CREATE_PROBES#define TRACEPOINT_DEFINE
#include "tp_two.h"


hello.c
use the two tracepoints defined in the two files.

To compile (compile file one by one).

gcc -o hello tp-one.c tp-two.c hello.c -llttng-ust -ldl




On Mon, Oct 7, 2019 at 12:22 PM Mathieu Desnoyers <
mathieu.desnoyers@efficios.com> wrote:

>
>
> ----- On Oct 7, 2019, at 9:59 AM, Yonghong Yan yanyh15@gmail.com wrote:
>
> > For lttng-ust, can I put the tracepoint definition in two files, but
> they use
> > the same provider.
>
> Based on the terminology here:
> https://lttng.org/docs/v2.10/#doc-tracing-your-own-user-application
>
> You need to have at most one instance of your tracepoint provider where
> the header is included with TRACEPOINT_CREATE_PROBES, and exactly one
> instance where TRACEPOINT_DEFINE is defined. (both can end up being within
> the same object if you wish).
>
> Then you can include your tracepoint provider header file at will across
> other compile units in your program. Just make sure none of
> TRACEPOINT_CREATE_PROBES nor TRACEPOINT_DEFINE are defined in those other
> compile units. You can therefore call tracepoints from a given probe from
> various compile units in your program.
>
> Hoping this helps clarifying things,
>
> Mathieu
>
> > Thank you.
> > Yonghong
>
> > _______________________________________________
> > lttng-dev mailing list
> > lttng-dev@lists.lttng.org
> > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> --
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
>

[-- Attachment #1.2: Type: text/html, Size: 29404 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: two tracepoints header files of one provider
       [not found] <CACJEY85GRrq=dHRfbnvuRqAgP_cF-ErWn4k3vK=DtCH6QvxSdQ@mail.gmail.com>
@ 2019-10-07 16:22 ` Mathieu Desnoyers
       [not found] ` <625499791.2728.1570465339442.JavaMail.zimbra@efficios.com>
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2019-10-07 16:22 UTC (permalink / raw)
  To: Yonghong Yan; +Cc: lttng-dev



----- On Oct 7, 2019, at 9:59 AM, Yonghong Yan yanyh15@gmail.com wrote:

> For lttng-ust, can I put the tracepoint definition in two files, but they use
> the same provider.

Based on the terminology here: https://lttng.org/docs/v2.10/#doc-tracing-your-own-user-application

You need to have at most one instance of your tracepoint provider where
the header is included with TRACEPOINT_CREATE_PROBES, and exactly one
instance where TRACEPOINT_DEFINE is defined. (both can end up being within
the same object if you wish).

Then you can include your tracepoint provider header file at will across
other compile units in your program. Just make sure none of 
TRACEPOINT_CREATE_PROBES nor TRACEPOINT_DEFINE are defined in those other
compile units. You can therefore call tracepoints from a given probe from
various compile units in your program.

Hoping this helps clarifying things,

Mathieu

> Thank you.
> Yonghong

> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-07 19:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 13:59 two tracepoints header files of one provider Yonghong Yan
     [not found] <CACJEY85GRrq=dHRfbnvuRqAgP_cF-ErWn4k3vK=DtCH6QvxSdQ@mail.gmail.com>
2019-10-07 16:22 ` Mathieu Desnoyers
     [not found] ` <625499791.2728.1570465339442.JavaMail.zimbra@efficios.com>
2019-10-07 16:42   ` Yonghong Yan
     [not found]   ` <CACJEY840r3D+SSGAkRnkAMpPJhQ7mUC2vj19cZFkVpgoxz1e8w@mail.gmail.com>
2019-10-07 19:53     ` Mathieu Desnoyers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).