This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug translator/13974] sdt.h is incompatible with clang


https://sourceware.org/bugzilla/show_bug.cgi?id=13974

Mark Wielaard <mjw at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mjw at redhat dot com

--- Comment #2 from Mark Wielaard <mjw at redhat dot com> ---
BTW. It might a good idea to add some configure check before using a feature
like SDT probes. Even really old g++ versions have been observed to have
trouble with using probe macros in C++ contructors or destructors for example.

This configure snippet seems to find all troubling C++ compilers (for C any gcc
version seems to be fine, only clang seems to have issues):

dnl ===================================================================
dnl Check if SDT probes (for systemtap, gdb, dtrace) are available
dnl ===================================================================

# We need at least the sys/sdt.h include header.
AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='TRUE'], [SDT_H_FOUND='FALSE'])
if test "$SDT_H_FOUND" = "TRUE"; then
  # Found sys/sdt.h header, now make sure the c++ compiler works.
  # Old g++ versions had problems with probes in constructors/destructors.
  AC_MSG_CHECKING([working sys/sdt.h and c++ support])
  AC_LANG_PUSH([C++])
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
    #include <sys/sdt.h>
    class ProbeClass
    {
    private:
      int& ref;
      const char *name;

    public:
      ProbeClass(int& v, const char *n) : ref(v), name(n)
      {
        DTRACE_PROBE2(_test_, cons, name, ref);
      }

      void method(int min)
      {
        DTRACE_PROBE3(_test_, meth, name, ref, min);
        ref -= min;
      }

      ~ProbeClass()
      {
        DTRACE_PROBE2(_test_, dest, name, ref);
      }
    };
  ]],[[
    int i = 64;
    DTRACE_PROBE1(_test_, call, i);
    ProbeClass inst = ProbeClass(i, "call");
    inst.method(24);
  ]])], [AC_MSG_RESULT([yes]); AC_DEFINE([USE_SDT_PROBES])],
        [AC_MSG_RESULT([no, sdt.h or c++ compiler too old])])
  AC_LANG_POP([C++])
fi
AC_CONFIG_HEADERS([config_probes.h])

Where config_probes.h.in might be something like:

#ifndef CONFIG_PROBES_H
#define CONFIG_PROBES_H

/* Whether we have and can use sys/sdt.h for probes.  */
#define USE_SDT_PROBES 0

#endif

-- 
You are receiving this mail because:
You are the assignee for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]