'application using lttng compile errors with aarch64-xilinx-linux-g++

I am trying to porting lttng on xilinx mpsoc with linux OS, I have write a demo as same as lttng "Record user application events", it runs on Ubuntu perfectly

g++  -c -I. hello-tp.c
g++  -c hello.c
g++ -o hello hello-tp.o hello.o  -llttng-ust -ldl

but when I compile it on arm linux platform I got errors:

    aarch64-xilinx-linux-g++  -mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/david/project/zcu102/images/linux/sdk/sysroots/cortexa72-cortexa53-xilinx-linux  -O2 -pipe -g -feliminate-unused-debug-types  -c -I. hello-tp.c
In file included from hello-tp.c:4:
hello-tp.h:16:27: error: expected constructor, destructor, or type conversion before ‘(’ token
   16 | LTTNG_UST_TRACEPOINT_EVENT(hello_world, my_first_tracepoint, LTTNG_ARGS, LTTNG_FIELDS)
      |                           ^
make: *** [Makefile:14: hello-tp.o] Error 1

here is the code hello-tp.h:

#undef LTTNG_UST_TRACEPOINT_PROVIDER
#define LTTNG_UST_TRACEPOINT_PROVIDER hello_world

#undef LTTNG_UST_TRACEPOINT_INCLUDE
#define LTTNG_UST_TRACEPOINT_INCLUDE "./hello-tp.h"

#if !defined(_HELLO_TP_H) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ)
#define _HELLO_TP_H

#include <lttng/tracepoint.h>

#define LTTNG_ARGS LTTNG_UST_TP_ARGS(int, my_integer_arg, char *, my_string_arg)

#define LTTNG_FIELDS LTTNG_UST_TP_FIELDS(lttng_ust_field_string(my_string_field, my_string_arg) lttng_ust_field_integer(int, my_integer_field, my_integer_arg))

LTTNG_UST_TRACEPOINT_EVENT(hello_world, my_first_tracepoint, LTTNG_ARGS, LTTNG_FIELDS)

#endif /* _HELLO_TP_H */

#include <lttng/tracepoint-event.h>

hello-tp.c

#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
#define LTTNG_UST_TRACEPOINT_DEFINE

#include "hello-tp.h"

hello.c

#include <stdio.h>
#include "hello-tp.h"

int main(int argc, char *argv[])
{
    unsigned int i;

    puts("Hello, World!\nPress Enter to continue...");

    /*
     * The following getchar() call only exists for the purpose of this
     * demonstration, to pause the application in order for you to have
     * time to list its tracepoints. You don't need it otherwise.
     */
    getchar();

    /*
     * An lttng_ust_tracepoint() call.
     *
     * Arguments, as defined in `hello-tp.h`:
     *
     * 1. Tracepoint provider name (required)
     * 2. Tracepoint name (required)
     * 3. `my_integer_arg` (first user-defined argument)
     * 4. `my_string_arg` (second user-defined argument)
     *
     * Notice the tracepoint provider and tracepoint names are
     * C identifiers, NOT strings: they're in fact parts of variables
     * that the macros in `hello-tp.h` create.
     */
    lttng_ust_tracepoint(hello_world, my_first_tracepoint, 23,
                         "hi there!");

    for (i = 0; i < argc; i++) {
        lttng_ust_tracepoint(hello_world, my_first_tracepoint,
                             i, argv[i]);
    }

    puts("Quitting now!");
    lttng_ust_tracepoint(hello_world, my_first_tracepoint,
                         i * i, "i^2");
    return 0;
}

Makefile

APP = hello

# Add any other object files to this list below
APP_OBJS = hello-tp.o hello.o

all: build

build: $(APP)

$(APP): $(APP_OBJS)
    $(CXX) -o $@ $(APP_OBJS) $(LDFLAGS) -llttng -ldl

hello-tp.o : hello-tp.c hello-tp.h
    $(CXX) $(CXXFLAGS) -c -I. $<

hello.o : hello.c
    $(CXX) $(CXXFLAGS) -c $<

clean:
    rm -f $(APP) *.o

Is there anyone met such issue? I guess the problem is caused by complier but I don't find any clue...



Solution 1:[1]

I just ran into this problem. Check your LTTNG version. The 2.13 release (current) uses LTTNG_UST_TRACEPOINT_PROVIDER. However, older releases uses TRACEPOINT_PROVIDER. The prefix LTTNG_UST has been added all over the place. See https://lttng.org/man/3/lttng-ust/v2.13/#doc-_compatibility_with_previous_apis

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pwnna