mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 02:18:05 +08:00
Previously when compiler crashed, no cmdline was printed. Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
39 lines
930 B
C++
39 lines
930 B
C++
/*
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "shared/offline_compiler/source/utilities/windows/seh_exception.h"
|
|
#include "shared/source/helpers/abort.h"
|
|
|
|
#include <setjmp.h>
|
|
|
|
static jmp_buf jmpbuf;
|
|
|
|
class SafetyGuardWindows {
|
|
public:
|
|
template <typename T, typename Object, typename Method>
|
|
T call(Object *object, Method method, T retValueOnCrash) {
|
|
int jump = 0;
|
|
jump = setjmp(jmpbuf);
|
|
|
|
if (jump == 0) {
|
|
__try {
|
|
return (object->*method)();
|
|
} __except (SehException::filter(GetExceptionCode(), GetExceptionInformation())) {
|
|
if (onExcept) {
|
|
onExcept();
|
|
}
|
|
longjmp(jmpbuf, 1);
|
|
}
|
|
}
|
|
return retValueOnCrash;
|
|
}
|
|
|
|
typedef void (*callbackFunction)();
|
|
callbackFunction onExcept = nullptr;
|
|
};
|