Put tint::debugger::Break() behind a build flag
Breaking isn't always desirable, as there are many tests that intentionally trigger ICEs, which are caught by a EXPECT_DEATH(). On Linux the break also performs IO, which will likely cause problems in Chromium's sandboxed environment. Change-Id: Ic2e1f5d13c9e986c066eaf364ffa5759c7299f6a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81103 Reviewed-by: Antonio Maiorano <amaiorano@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
16446e5b74
commit
1c6c6b19ab
|
@ -92,6 +92,8 @@ option_if_not_defined(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF)
|
|||
option_if_not_defined(TINT_ENABLE_ASAN "Enable address sanitizer" OFF)
|
||||
option_if_not_defined(TINT_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
|
||||
|
||||
option_if_not_defined(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF)
|
||||
|
||||
option_if_not_defined(TINT_EMIT_COVERAGE "Emit code coverage information" OFF)
|
||||
|
||||
option_if_not_defined(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
|
||||
|
|
|
@ -53,6 +53,11 @@ add_library(tint_diagnostic_utils
|
|||
)
|
||||
tint_default_compile_options(tint_diagnostic_utils)
|
||||
|
||||
if (TINT_ENABLE_BREAK_IN_DEBUGGER)
|
||||
set_source_files_properties(utils/debugger.cc
|
||||
PROPERTIES COMPILE_DEFINITIONS "TINT_ENABLE_BREAK_IN_DEBUGGER=1" )
|
||||
endif()
|
||||
|
||||
set(TINT_LIB_SRCS
|
||||
../include/tint/tint.h
|
||||
ast/access.cc
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "src/utils/debugger.h"
|
||||
|
||||
#ifdef TINT_ENABLE_BREAK_IN_DEBUGGER
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#elif defined(__linux__)
|
||||
|
@ -23,7 +25,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define TINT_DEBUGGER_BREAK_DEFINED
|
||||
void tint::debugger::Break() {
|
||||
if (::IsDebuggerPresent()) {
|
||||
::DebugBreak();
|
||||
|
@ -32,6 +34,7 @@ void tint::debugger::Break() {
|
|||
|
||||
#elif defined(__linux__)
|
||||
|
||||
#define TINT_DEBUGGER_BREAK_DEFINED
|
||||
void tint::debugger::Break() {
|
||||
// A process is being traced (debugged) if "/proc/self/status" contains a
|
||||
// line with "TracerPid: <non-zero-digit>...".
|
||||
|
@ -51,9 +54,10 @@ void tint::debugger::Break() {
|
|||
raise(SIGTRAP);
|
||||
}
|
||||
}
|
||||
#endif // platform
|
||||
|
||||
#else
|
||||
#endif // TINT_ENABLE_BREAK_IN_DEBUGGER
|
||||
|
||||
#ifndef TINT_DEBUGGER_BREAK_DEFINED
|
||||
void tint::debugger::Break() {}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,8 +16,12 @@
|
|||
#define SRC_UTILS_DEBUGGER_H_
|
||||
|
||||
namespace tint::debugger {
|
||||
/// If debugger is attached, will break into it at the call site.
|
||||
|
||||
/// If debugger is attached and the `TINT_ENABLE_BREAK_IN_DEBUGGER` preprocessor
|
||||
/// macro is defined for `debugger.cc`, calling `Break()` will cause the
|
||||
/// debugger to break at the call site.
|
||||
void Break();
|
||||
|
||||
} // namespace tint::debugger
|
||||
|
||||
#endif // SRC_UTILS_DEBUGGER_H_
|
||||
|
|
Loading…
Reference in New Issue