HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
debugger_win32_impl.hpp
1// Copyright Take Vos 2021-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
8#include "../macros.hpp"
9#include "debugger_intf.hpp"
10#include <exception>
11
12hi_export_module(hikogui.utility.debugger : impl);
13
14hi_warning_push();
15// C6320: Exception-filter expression is the constant EXCEPTION_EXECUTE_HANDLER.
16// This might mask exceptions that were not intended to be handled.
17hi_warning_ignore_msvc(6320);
18
19hi_export namespace hi { inline namespace v1 {
20
21inline hi_no_inline bool prepare_debug_break() noexcept
22{
23 if (IsDebuggerPresent()) {
24 // When running under the debugger, __debugbreak() after returning.
25 return true;
26
27 } else {
28 __try {
29 __try {
30 // Attempt to break, causing an exception.
31 DebugBreak();
32
33 // The UnhandledExceptionFilter() will be called to attempt to attach a debugger.
34 // * If the jit-debugger is not configured the user gets a error dialogue-box that
35 // with "Abort", "Retry (Debug)", "Ignore". The "Retry" option will only work
36 // when the application is already being debugged.
37 // * When the jit-debugger is configured the user gets a dialogue window which allows
38 // a selection of debuggers and a "OK (Debug)", "Cancel (aborts application)".
39
41 // The jit-debugger is not configured and the user pressed any of the buttons.
42 return false;
43 }
44
46 // User pressed "OK", debugger has been attached, __debugbreak() after return.
47 return true;
48 }
49
50 // The jit-debugger was configured, but the use pressed Cancel.
51 return false;
52 }
53}
54
55
56}} // namespace hi::inline v1
57
58hi_warning_pop();
Rules for working with win32 headers.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
bool prepare_debug_break() noexcept
Prepare for breaking in the debugger.
Definition debugger_win32_impl.hpp:21
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377