aaba06d2fc
...as seen with path set 2 of <https://gerrit.libreoffice.org/c/core/+/155121/2> "Bump baseline to C++20", > In file included from /home/tdf/lode/jenkins/workspace/android_arm/vcl/source/app/watchdog.cxx:19: > In file included from /home/tdf/lode/jenkins/workspace/android_arm/vcl/inc/opengl/zone.hxx:16: > /home/tdf/lode/jenkins/workspace/android_arm/include/comphelper/crashzone.hxx:59:39: error: increment of object of volatile-qualified type 'CrashZone::AtomicCounter' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile] > static void enter() { gnEnterCount++; } > ^ > /home/tdf/lode/jenkins/workspace/android_arm/include/comphelper/crashzone.hxx:60:39: error: increment of object of volatile-qualified type 'CrashZone::AtomicCounter' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile] > static void leave() { gnLeaveCount++; } > ^ > /home/tdf/lode/jenkins/workspace/android_arm/include/comphelper/crashzone.hxx:59:39: error: increment of object of volatile-qualified type 'CrashZone::AtomicCounter' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile] > static void enter() { gnEnterCount++; } > ^ > /home/tdf/lode/jenkins/workspace/android_arm/include/comphelper/crashzone.hxx:54:19: note: in instantiation of member function 'CrashZone<SkiaZone>::enter' requested here > CrashZone() { enter(); } > ^ > /home/tdf/lode/jenkins/workspace/android_arm/vcl/inc/skia/zone.hxx:23:5: note: in instantiation of member function 'CrashZone<SkiaZone>::CrashZone' requested here > SkiaZone() { assert(comphelper::SolarMutex::get()->IsCurrentThread()); } > ^ > In file included from /home/tdf/lode/jenkins/workspace/android_arm/vcl/source/app/watchdog.cxx:19: > In file included from /home/tdf/lode/jenkins/workspace/android_arm/vcl/inc/opengl/zone.hxx:16: > /home/tdf/lode/jenkins/workspace/android_arm/include/comphelper/crashzone.hxx:60:39: error: increment of object of volatile-qualified type 'CrashZone::AtomicCounter' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile] > static void leave() { gnLeaveCount++; } > ^ > /home/tdf/lode/jenkins/workspace/android_arm/include/comphelper/crashzone.hxx:55:20: note: in instantiation of member function 'CrashZone<SkiaZone>::leave' requested here > ~CrashZone() { leave(); } > ^ > /home/tdf/lode/jenkins/workspace/android_arm/vcl/inc/skia/zone.hxx:23:5: note: in instantiation of member function 'CrashZone<SkiaZone>::~CrashZone' requested here > SkiaZone() { assert(comphelper::SolarMutex::get()->IsCurrentThread()); } > ^ (<https://ci.libreoffice.org/job/gerrit_android_arm/31168/>) Change-Id: Ia63c54ed5bde6678ef6b544c1edad9600534ff05 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155264 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
77 lines
3 KiB
C++
77 lines
3 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#ifndef INCLUDED_COMPHELPER_CRASHZONE_H
|
|
#define INCLUDED_COMPHELPER_CRASHZONE_H
|
|
|
|
#include <sal/config.h>
|
|
|
|
#include <atomic>
|
|
#include <csignal>
|
|
#include <type_traits>
|
|
|
|
struct CrashWatchdogTimingsValues
|
|
{
|
|
/// delays to take various actions in 1/4 of a second increments.
|
|
int mnDisableEntries;
|
|
int const mnAbortAfter;
|
|
};
|
|
|
|
/**
|
|
* A generic class for detecting if a given crash or a lock-up came from a specific
|
|
* area of code (such as OpenGL).
|
|
* Use this helper to track that.
|
|
* The class is a template so that there can be multiple instances of static variables.
|
|
*/
|
|
template <typename Dummy> class CrashZone
|
|
{
|
|
// gnEnterCount and gnLeaveCount are accessed both from multiple threads (cf.
|
|
// WatchdogThread::execute; so need to be of atomic type) and from signal handlers (cf.
|
|
// VCLExceptionSignal_impl; so need to be of lock-free atomic type). sig_atomic_t is chosen as
|
|
// the underlying type under the assumption that it is most likely to lead to an atomic type
|
|
// that is actually lock-free. However, gnEnterCount and gnLeaveCount are both monotonically
|
|
// increasing, so will eventually overflow, so the underlying type better be unsigned, which
|
|
// sig_atomic_t is not guaranteed to be:
|
|
#if !defined ARM32 || (defined ARM32 && defined __ARM_PCS_VFP)
|
|
using AtomicCounter = std::atomic<std::make_unsigned_t<std::sig_atomic_t>>;
|
|
static_assert(AtomicCounter::is_always_lock_free);
|
|
#else
|
|
using AtomicCounter = volatile std::make_unsigned_t<std::sig_atomic_t>;
|
|
#endif
|
|
|
|
/// how many times have we entered a zone
|
|
static inline AtomicCounter gnEnterCount = 0;
|
|
/// how many times have we left a new zone
|
|
static inline AtomicCounter gnLeaveCount = 0;
|
|
|
|
public:
|
|
CrashZone() { enter(); }
|
|
~CrashZone() { leave(); }
|
|
static bool isInZone() { return gnEnterCount != gnLeaveCount; }
|
|
static const AtomicCounter& enterCount() { return gnEnterCount; }
|
|
#if defined ARM32 && !defined __ARM_PCS_VFP && defined __clang__
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wdeprecated-volatile"
|
|
#endif
|
|
// prefer creating instances to manually calling enter()/leave()
|
|
static void enter() { gnEnterCount++; }
|
|
static void leave() { gnLeaveCount++; }
|
|
#if defined ARM32 && !defined __ARM_PCS_VFP && defined __clang__
|
|
#pragma clang diagnostic pop
|
|
#endif
|
|
// these should be implemented for each specific zone if needed
|
|
// static void hardDisable();
|
|
// static const CrashWatchdogTimingsValues& getCrashWatchdogTimingsValues();
|
|
// static void checkDebug(int nUnchanged, const CrashWatchdogTimingsValues& aTimingValues);
|
|
// static const char* name();
|
|
};
|
|
|
|
#endif // INCLUDED_COMPHELPER_CRASHZONE_H
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|