12#include <config_features.h>
14#include <osl/conditn.hxx>
16#include <rtl/string.hxx>
24#if defined HAVE_VALGRIND_HEADERS
25#include <valgrind/memcheck.h>
30volatile bool gbWatchdogFiring =
false;
31osl::Condition* gpWatchdogExit =
nullptr;
34template <
typename Zone>
struct WatchdogHelper
36 static inline sal_uInt64 nLastEnters = 0;
37 static inline int nUnchanged = 0;
38 static inline bool bFired =
false;
39 static inline bool bAbortFired =
false;
40 static void setLastEnters() { nLastEnters = Zone::enterCount(); }
47 if (nLastEnters == Zone::enterCount())
51 Zone::checkDebug(nUnchanged, aTimingValues);
58 gbWatchdogFiring =
true;
59 SAL_WARN(
"vcl.watchdog",
"Watchdog triggered: hard disable " << Zone::name());
64 gbWatchdogFiring =
false;
72 SAL_WARN(
"vcl.watchdog",
"Watchdog gave up: hard exiting " << Zone::name());
82 SAL_WARN(
"vcl.watchdog",
"Watchdog gave up: aborting " << Zone::name());
83 gbWatchdogFiring =
true;
106 TimeValue aQuarterSecond(0, 1000 * 1000 * 1000 * 0.25);
109#if HAVE_FEATURE_OPENGL
110 WatchdogHelper<OpenGLZone>::setLastEnters();
113 WatchdogHelper<SkiaZone>::setLastEnters();
116 gpWatchdogExit->wait(&aQuarterSecond);
118#if defined HAVE_VALGRIND_HEADERS
119 if (RUNNING_ON_VALGRIND)
127#if HAVE_FEATURE_OPENGL
128 WatchdogHelper<OpenGLZone>::check();
131 WatchdogHelper<SkiaZone>::check();
134 }
while (!gpWatchdogExit->check());
139 if (gxWatchdog !=
nullptr)
141 if (getenv(
"SAL_DISABLE_WATCHDOG"))
143 gpWatchdogExit =
new osl::Condition();
145 gxWatchdog->launch();
150 if (gbWatchdogFiring)
154 gpWatchdogExit->set();
162 delete gpWatchdogExit;
163 gpWatchdogExit =
nullptr;
virtual void execute() override
#define SAL_WARN(area, stream)
bool isDebuggerAttached()
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC css::uno::Sequence< css::uno::Reference< css::xml::dom::XElement > > check(dp_misc::DescriptionInfoset const &infoset)