X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils%2Ftestapp%2Fuserspace-probe-sdt-binary%2Fuserspace-probe-sdt-binary.c;fp=tests%2Futils%2Ftestapp%2Fuserspace-probe-sdt-binary%2Fuserspace-probe-sdt-binary.c;h=c70713979d8933b5621085345295cd83ce3e0d64;hp=0000000000000000000000000000000000000000;hb=a9c2df2bfce7a27b53ee5d5101f259f3e1f506b1;hpb=5a1c0a75771c4b95f9518be0e1960a25bb691caf diff --git a/tests/utils/testapp/userspace-probe-sdt-binary/userspace-probe-sdt-binary.c b/tests/utils/testapp/userspace-probe-sdt-binary/userspace-probe-sdt-binary.c new file mode 100644 index 000000000..c70713979 --- /dev/null +++ b/tests/utils/testapp/userspace-probe-sdt-binary/userspace-probe-sdt-binary.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2017 Francis Deslauriers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "foobar_provider.h" +#include "libfoo.h" +#include "sema.h" + +int main(int argc, char *argv[]) +{ + void *handle; + void (*bar_function)(); + + FOOBAR_TP1(); + FOOBAR_TP2(); + /* + * This SDT tracepoint has an argument. Argument extraction is not support + * at the moment but tracing of the tracepoint should work. + */ + FOOBAR_TP_WITH_ARG(42); + + /* Call function containing an SDT tracepoint in shared object */ + foo_function(); + + /* + * Load a show shared object and call a function containing an SDT + * tracepoint + */ + handle = dlopen("libbar.so", RTLD_LAZY); + if (!handle) { + fprintf(stderr, "Can't dlopen libbar.so"); + return -1; + } + bar_function = (void (*)())dlsym(handle, "bar_function"); + bar_function(); + dlclose(handle); + + /* This tracepoint has 2 callsites in this binary */ + FOOBAR_TP2(); + + /* + * This function is defined in libfoo AND in libzzz. For a test, libzzz is + * LD_PRELOADed and should override this function + */ + overridable_function(); + + /* + * This function is calling a SDT tracepoint that is guarded by a + * semaphore. + */ + sema_function(); + return 0; +} +