Kaydet (Commit) eeb3b8dc authored tarafından Mark Wielaard's avatar Mark Wielaard Kaydeden (comit) Stephan Bergmann

Add SDT probes for RTL_LOG_STRING_NEW/DELETE.

Change-Id: I938259f90aee9d277c9ff5b72c9120b93311cbd3
Signed-off-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst c2e2fbe6
#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
......@@ -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 ===================================================================
......
......@@ -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 */
......
......@@ -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
/* ======================================================================= */
......
......@@ -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)
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment