@@ -200,6 +200,7 @@ static std::string trace_enabled_categories; // NOLINT(runtime/string)
200200static std::string trace_file_pattern = // NOLINT(runtime/string)
201201 " node_trace.${rotation}.log" ;
202202static bool abort_on_uncaught_exception = false ;
203+ static std::string report_events; // NOLINT(runtime/string)
203204
204205// Bit flag used to track security reverts (see node_revert.h)
205206unsigned int reverted = 0 ;
@@ -2569,6 +2570,14 @@ void LoadEnvironment(Environment* env) {
25692570 return ;
25702571 }
25712572
2573+ #if defined(NODE_REPORT)
2574+ fprintf (stderr, " report events: %s \n " , report_events.c_str ());
2575+ if (!report_events.empty ()) {
2576+ nodereport::InitializeNodeReport ();
2577+ nodereport::SetEvents (env->isolate (), report_events.c_str ());
2578+ }
2579+ #endif
2580+
25722581 // Bootstrap Node.js
25732582 Local<Object> bootstrapper = Object::New (env->isolate ());
25742583 SetupBootstrapObject (env, bootstrapper);
@@ -3044,6 +3053,22 @@ static void ParseArgs(int* argc,
30443053 // Also a V8 option. Pass through as-is.
30453054 new_v8_argv[new_v8_argc] = arg;
30463055 new_v8_argc += 1 ;
3056+ } else if (strcmp (arg, " --report-events" ) == 0 ) {
3057+ const char * events = argv[index + 1 ];
3058+ if (events == nullptr ) {
3059+ fprintf (stderr, " %s: %s requires an argument\n " , argv[0 ], arg);
3060+ exit (9 );
3061+ }
3062+ args_consumed += 1 ;
3063+ report_events = events;
3064+ fprintf (stderr, " parsed events %s \n " , report_events.c_str ());
3065+ // Replace ',' with '+' separators
3066+ std::size_t c = report_events.find_first_of (" ," );
3067+ while (c != std::string::npos) {
3068+ report_events.replace (c, 1 , " +" );
3069+ c = report_events.find_first_of (" ," , c + 1 );
3070+ }
3071+ fprintf (stderr, " filtered events %s \n " , report_events.c_str ());
30473072 } else {
30483073 // V8 option. Pass through as-is.
30493074 new_v8_argv[new_v8_argc] = arg;
@@ -3691,11 +3716,6 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
36913716
36923717 env.set_trace_sync_io (trace_sync_io);
36933718
3694- #if defined(NODE_REPORT)
3695- nodereport::InitializeNodeReport ();
3696- nodereport::SetEvents (isolate, " fatalerror+signal" );
3697- #endif
3698-
36993719 {
37003720 SealHandleScope seal (isolate);
37013721 bool more;
0 commit comments