Skip to content

Commit 166e44a

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 166e44a

File tree

8 files changed

+52
-0
lines changed

8 files changed

+52
-0
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 program
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-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+
} /* jerry_port_init */
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+
} /* jerry_port_init */
41+
2142
/**
2243
* Default implementation of jerry_port_sleep, uses 'Sleep'.
2344
*/

targets/os/mbedos/jerry-port.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
#include "mbed.h"
2222

23+
void
24+
jerry_port_init (void)
25+
{
26+
} /* jerry_port_init */
27+
2328
/**
2429
* Aborts the program.
2530
*/

targets/os/nuttx/jerry-port.c

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
#include "jerryscript-port.h"
2121

22+
void
23+
jerry_port_init (void)
24+
{
25+
} /* jerry_port_init */
26+
2227
/**
2328
* Default implementation of jerry_port_log. Prints log messages to stderr.
2429
*/

targets/os/riot/source/jerry-port.c

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
#include "jerryscript-port.h"
2020

21+
void
22+
jerry_port_init (void)
23+
{
24+
} /* jerry_port_init */
25+
2126
/**
2227
* Dummy function to get the time zone adjustment.
2328
*

targets/os/zephyr/src/jerry-port.c

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
#include "getline-zephyr.h"
2424

25+
void
26+
jerry_port_init (void)
27+
{
28+
} /* jerry_port_init */
29+
2530
/**
2631
* Aborts the program.
2732
*/

0 commit comments

Comments
 (0)