Skip to content

Commit

Permalink
Disable the debug popup on MSVC/win32 by introduce new jerry_port_ini…
Browse files Browse the repository at this point in the history
…t 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 luoyonggang@gmail.com
  • Loading branch information
lygstate committed Dec 7, 2024
1 parent 94bce93 commit 193c3b2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions jerry-core/api/jerryscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ jerry_return (const jerry_value_t value) /**< return value */
void
jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
{
jerry_port_init ();
#if JERRY_EXTERNAL_CONTEXT
size_t total_size = jerry_port_context_alloc (sizeof (jerry_context_t));
JERRY_UNUSED (total_size);
Expand Down
5 changes: 5 additions & 0 deletions jerry-core/include/jerryscript-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ typedef enum
JERRY_FATAL_FAILED_ASSERTION = 120 /**< Assertion failed */
} jerry_fatal_code_t;

/**
* Init the program
*/
void jerry_port_init (void);

/**
* Signal the port that the process experienced a fatal failure from which it cannot
* recover.
Expand Down
7 changes: 7 additions & 0 deletions jerry-port/common/jerry-port-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

#include "jerryscript-port.h"

#ifndef _WIN32
void JERRY_ATTR_WEAK
jerry_port_init (void)
{
} /* jerry_port_init */
#endif

/**
* Default implementation of jerry_port_fatal. Calls 'abort' if exit code is
* non-zero, 'exit' otherwise.
Expand Down
21 changes: 21 additions & 0 deletions jerry-port/win/jerry-port-win-process.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@

#include <windows.h>

#include <crtdbg.h>

void
jerry_port_init (void)
{
if (!IsDebuggerPresent ())
{
/* Disable all of the possible ways Windows conspires to make automated
testing impossible. */
#if defined(_MSC_VER)
_set_error_mode (_OUT_TO_STDERR);
_CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
#endif /* _MSC_VER */
}
} /* jerry_port_init */

/**
* Default implementation of jerry_port_sleep, uses 'Sleep'.
*/
Expand Down

0 comments on commit 193c3b2

Please sign in to comment.