Skip to content

Commit 64b1633

Browse files
committed
Disable the debug popup on MSVC/win32 by introduce new jerry_port_init function
For not popup dialog when crash happend on MSVC/win32 related issue: jerryscript-project#4463 JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
1 parent 9c8ca52 commit 64b1633

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

jerry-core/api/jerryscript.c

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ jerry_return (const jerry_value_t value) /**< return value */
166166
void
167167
jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
168168
{
169+
jerry_port_init ();
169170
#if JERRY_EXTERNAL_CONTEXT
170171
size_t total_size = jerry_port_context_alloc (sizeof (jerry_context_t));
171172
JERRY_UNUSED (total_size);

jerry-core/include/jerryscript-port.h

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ typedef enum
4949
JERRY_FATAL_FAILED_ASSERTION = 120 /**< Assertion failed */
5050
} jerry_fatal_code_t;
5151

52+
/**
53+
* Init the port environment
54+
*/
55+
void jerry_port_init (void);
56+
5257
/**
5358
* Signal the port that the process experienced a fatal failure from which it cannot
5459
* recover.

jerry-main/main-desktop.c

+22-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#include <stdlib.h>
1919
#include <string.h>
2020

21+
#if defined(_WIN32)
22+
#include <windows.h>
23+
24+
#include <crtdbg.h>
25+
#endif /* _WIN32 */
26+
2127
#include "jerryscript-port.h"
2228
#include "jerryscript.h"
2329

@@ -115,7 +121,22 @@ main (int argc, char **argv)
115121

116122
main_args_t arguments;
117123
arguments.sources_p = sources_p;
118-
124+
#if defined(_WIN32)
125+
if (!IsDebuggerPresent ())
126+
{
127+
/* Disable all of the possible ways Windows conspires to make automated
128+
testing impossible. */
129+
#if defined(_MSC_VER)
130+
_set_error_mode (_OUT_TO_STDERR);
131+
_CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
132+
_CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
133+
_CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
134+
_CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
135+
_CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
136+
_CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
137+
#endif /* _MSC_VER */
138+
}
139+
#endif /* _WIN32 */
119140
if (!main_parse_args (argc, argv, &arguments))
120141
{
121142
return arguments.parse_result;

jerry-port/common/jerry-port-process.c

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
#include "jerryscript-port.h"
1919

20+
#ifdef __GNUC__
21+
void JERRY_ATTR_WEAK
22+
jerry_port_init (void)
23+
{
24+
}
25+
#endif
26+
2027
/**
2128
* Default implementation of jerry_port_fatal. Calls 'abort' if exit code is
2229
* non-zero, 'exit' otherwise.

jerry-port/unix/jerry-port-unix-process.c

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
#include <unistd.h>
2727

28+
void
29+
jerry_port_init (void)
30+
{
31+
}
32+
2833
/**
2934
* Default implementation of jerry_port_sleep, uses 'usleep'.
3035
*/

jerry-port/win/jerry-port-win-process.c

+21
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@
1818

1919
#include <windows.h>
2020

21+
#include <crtdbg.h>
22+
23+
void
24+
jerry_port_init (void)
25+
{
26+
if (!IsDebuggerPresent ())
27+
{
28+
/* Disable all of the possible ways Windows conspires to make automated
29+
testing impossible. */
30+
#if defined(_MSC_VER)
31+
_set_error_mode (_OUT_TO_STDERR);
32+
_CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
33+
_CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
34+
_CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
35+
_CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
36+
_CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
37+
_CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
38+
#endif /* _MSC_VER */
39+
}
40+
}
41+
2142
/**
2243
* Default implementation of jerry_port_sleep, uses 'Sleep'.
2344
*/

0 commit comments

Comments
 (0)