diff options
author | Mark Wielaard <mark@klomp.org> | 2013-08-02 20:49:48 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-08-03 09:32:03 +0200 |
commit | eeb3b8dc5c771915f9c011e95ae20babdf70bd02 (patch) | |
tree | f1602f8e92a9a0f9873bf0335e03cf23433b9e34 | |
parent | c2e2fbe6601ef14122371c380d91a48425a2b669 (diff) |
Add SDT probes for RTL_LOG_STRING_NEW/DELETE.
Change-Id: I938259f90aee9d277c9ff5b72c9120b93311cbd3
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | config_host/config_probes.h.in | 7 | ||||
-rw-r--r-- | configure.ac | 48 | ||||
-rw-r--r-- | sal/rtl/strimp.hxx | 18 | ||||
-rw-r--r-- | sal/rtl/string.cxx | 7 | ||||
-rw-r--r-- | sal/rtl/ustrbuf.cxx | 4 | ||||
-rw-r--r-- | sal/rtl/ustring.cxx | 4 |
6 files changed, 84 insertions, 4 deletions
diff --git a/config_host/config_probes.h.in b/config_host/config_probes.h.in new file mode 100644 index 000000000000..b15a1f077ea9 --- /dev/null +++ b/config_host/config_probes.h.in @@ -0,0 +1,7 @@ +#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 diff --git a/configure.ac b/configure.ac index 7809430f957f..c623f386d883 100644 --- a/configure.ac +++ b/configure.ac @@ -5322,6 +5322,54 @@ if test "$ENABLE_VALGRIND" = FALSE; then fi AC_SUBST([VALGRIND_CFLAGS]) + +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_host/config_probes.h]) + dnl =================================================================== dnl Compiler plugins dnl =================================================================== diff --git a/sal/rtl/strimp.hxx b/sal/rtl/strimp.hxx index f54b88231fed..544d5796560f 100644 --- a/sal/rtl/strimp.hxx +++ b/sal/rtl/strimp.hxx @@ -20,6 +20,11 @@ #ifndef INCLUDED_RTL_SOURCE_STRIMP_HXX #define INCLUDED_RTL_SOURCE_STRIMP_HXX +#include <config_probes.h> +#if USE_SDT_PROBES +#include <sys/sdt.h> +#endif + #include <osl/interlck.h> #include "sal/types.h" @@ -46,8 +51,21 @@ sal_Int16 rtl_ImplGetDigit( sal_Unicode ch, sal_Int16 nRadix ); sal_Bool rtl_ImplIsWhitespace( sal_Unicode c ); // string lifetime instrumentation / diagnostics +#if USE_SDT_PROBES +# define PROBE_SNAME(n,b) n ## _ ## b +# define PROBE_NAME(n,b) PROBE_SNAME(n,b) +# define PROBE_NEW PROBE_NAME (new_string,RTL_LOG_STRING_BITS) +# define PROBE_DEL PROBE_NAME (delete_string,RTL_LOG_STRING_BITS) +# define RTL_LOG_STRING_NEW(s) \ + DTRACE_PROBE4(libreoffice, PROBE_NEW, s, \ + (s)->refCount, (s)->length, (s)->buffer) +# define RTL_LOG_STRING_DELETE(s) \ + DTRACE_PROBE4(libreoffice, PROBE_DEL, s, \ + (s)->refCount, (s)->length, (s)->buffer) +#else # define RTL_LOG_STRING_NEW(s) # define RTL_LOG_STRING_DELETE(s) +#endif /* USE_SDT_PROBES */ #endif /* INCLUDED_RTL_SOURCE_STRIMP_HXX */ diff --git a/sal/rtl/string.cxx b/sal/rtl/string.cxx index a68c0932d115..313706d797e8 100644 --- a/sal/rtl/string.cxx +++ b/sal/rtl/string.cxx @@ -61,10 +61,9 @@ static rtl_String const aImplEmpty_rtl_String = #define IMPL_RTL_STRINGDATA rtl_String #define IMPL_RTL_EMPTYSTRING aImplEmpty_rtl_String -#undef RTL_LOG_STRING_NEW -#define RTL_LOG_STRING_NEW(s) -#undef RTL_LOG_STRING_DELETE -#define RTL_LOG_STRING_DELETE(s) +#if USE_SDT_PROBES +#define RTL_LOG_STRING_BITS 8 +#endif /* ======================================================================= */ diff --git a/sal/rtl/ustrbuf.cxx b/sal/rtl/ustrbuf.cxx index 9010a0ea0cdd..30f4efe39c7f 100644 --- a/sal/rtl/ustrbuf.cxx +++ b/sal/rtl/ustrbuf.cxx @@ -24,6 +24,10 @@ #include <rtl/ustrbuf.hxx> #include <strimp.hxx> +#if USE_SDT_PROBES +#define RTL_LOG_STRING_BITS 16 +#endif + void SAL_CALL rtl_uStringbuffer_newFromStr_WithLength( rtl_uString ** newStr, const sal_Unicode * value, sal_Int32 count) diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index bdebd897a71b..1c02dfc9d041 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -69,6 +69,10 @@ static rtl_uString const aImplEmpty_rtl_uString = #define IMPL_RTL_INTERN static void internRelease (rtl_uString *pThis); +#if USE_SDT_PROBES +#define RTL_LOG_STRING_BITS 16 +#endif + /* ======================================================================= */ /* Include String/UString template code */ |