11#include " node_report.h"
2- #include " node_version.h"
32#include " v8.h"
43#include " time.h"
5- #include " zlib.h"
6- #include " ares.h"
74
85#include < fcntl.h>
96#include < string.h>
@@ -52,7 +49,7 @@ using v8::String;
5249using v8::V8;
5350
5451// Internal/static function declarations
55- static void PrintVersionInformation (FILE* fp);
52+ static void PrintVersionInformation (FILE* fp, Isolate* isolate );
5653static void PrintJavaScriptStack (FILE* fp, Isolate* isolate, DumpEvent event, const char * location);
5754static void PrintStackFromStackTrace (FILE* fp, Isolate* isolate, DumpEvent event);
5855static void PrintStackFrame (FILE* fp, Isolate* isolate, Local<StackFrame> frame, int index, void * pc);
@@ -70,6 +67,7 @@ const char* v8_states[] = {"JS", "GC", "COMPILER", "OTHER", "EXTERNAL", "IDLE"};
7067static bool report_active = false ; // recursion protection
7168static char report_filename[NR_MAXNAME + 1 ] = " " ;
7269static char report_directory[NR_MAXPATH + 1 ] = " " ; // defaults to current working directory
70+ static std::string version;
7371#ifdef _WIN32
7472static SYSTEMTIME loadtime_tm_struct; // module load time
7573#else // UNIX, OSX
@@ -189,6 +187,28 @@ unsigned int ProcessNodeReportVerboseSwitch(const char* args) {
189187 return 0 ; // Default is verbose mode off
190188}
191189
190+ void SetVersionString (Isolate* isolate) {
191+ Nan::MaybeLocal<Value> process = Nan::Get (
192+ isolate->GetCurrentContext ()->Global (),
193+ Nan::New<String>(" process" ).ToLocalChecked ());
194+ Local<Value> versions = Nan::Get (process.ToLocalChecked ().As <Object>(),
195+ Nan::New<String>(" versions" ).ToLocalChecked ()).ToLocalChecked ();
196+ Local<Object> versionsObj = versions.As <Object>();
197+ Local<v8::Array> keys = Nan::GetOwnPropertyNames (versionsObj)
198+ .ToLocalChecked ();
199+ version.clear ();
200+ for (uint32_t i = 0 , nKeys = (*keys)->Length (); i < nKeys; i++) {
201+ Local<Value> compValue = Nan::Get (keys.As <Object>(), i).ToLocalChecked ();
202+ Local<Value> versValue = Nan::Get (versionsObj, compValue).ToLocalChecked ();
203+ Nan::Utf8String compName (compValue);
204+ Nan::Utf8String compVersion (versValue);
205+ version.append (*compName);
206+ version.append (" version: " );
207+ version.append (*compVersion);
208+ version.append (" \n " );
209+ }
210+ }
211+
192212/* ******************************************************************************
193213 * Function to save the nodereport module load time value
194214 *******************************************************************************/
@@ -317,7 +337,7 @@ void TriggerNodeReport(Isolate* isolate, DumpEvent event, const char* message, c
317337 fflush (fp);
318338
319339 // Print Node.js and OS version information
320- PrintVersionInformation (fp);
340+ PrintVersionInformation (fp, isolate );
321341 fflush (fp);
322342
323343// Print summary JavaScript stack backtrace
@@ -369,12 +389,10 @@ void TriggerNodeReport(Isolate* isolate, DumpEvent event, const char* message, c
369389 * Function to print Node.js version, OS version and machine information
370390 *
371391 ******************************************************************************/
372- static void PrintVersionInformation (FILE* fp) {
392+ static void PrintVersionInformation (FILE* fp, Isolate* isolate ) {
373393
374394 // Print Node.js and deps component versions
375- fprintf (fp, " \n Node.js version: %s\n " , NODE_VERSION);
376- fprintf (fp, " (v8: %s, libuv: %s, zlib: %s, ares: %s)\n " ,
377- V8::GetVersion (), uv_version_string (), ZLIB_VERSION, ARES_VERSION_STR);
395+ fprintf (fp, " \n %s" , version.c_str ());
378396
379397 // Print operating system and machine information (Windows)
380398#ifdef _WIN32
0 commit comments