Skip to content

Commit af35d40

Browse files
committed
report: use uv_gettimeofday for dumpEventTimeStamp
dumpEventTimeStamp was not implemented on Windows, and did not include any error checking. This commit adds Windows support and error checking. PR-URL: #27029 Reviewed-By: Refael Ackermann <[email protected]>
1 parent 90cf2d5 commit af35d40

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/node_report.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,14 @@ static void WriteNodeReport(Isolate* isolate,
209209
tm_struct.tm_min,
210210
tm_struct.tm_sec);
211211
writer.json_keyvalue("dumpEventTime", timebuf);
212-
struct timeval ts;
213-
gettimeofday(&ts, nullptr);
214-
writer.json_keyvalue("dumpEventTimeStamp",
215-
std::to_string(ts.tv_sec * 1000 + ts.tv_usec / 1000));
216212
#endif
213+
214+
uv_timeval64_t ts;
215+
if (uv_gettimeofday(&ts) == 0) {
216+
writer.json_keyvalue("dumpEventTimeStamp",
217+
std::to_string(ts.tv_sec * 1000 + ts.tv_usec / 1000));
218+
}
219+
217220
// Report native process ID
218221
writer.json_keyvalue("processId", pid);
219222

src/node_report.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
#include "uv.h"
66
#include "v8.h"
77

8-
#ifdef _WIN32
9-
#include <time.h>
10-
#else
11-
#include <sys/time.h>
8+
#ifndef _WIN32
129
#include <sys/types.h>
1310
#include <unistd.h>
1411
#endif

test/common/report.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ function _validateContent(data) {
7070
assert(typeof header.filename === 'string' || header.filename === null);
7171
assert.notStrictEqual(new Date(header.dumpEventTime).toString(),
7272
'Invalid Date');
73-
if (isWindows)
74-
assert.strictEqual(header.dumpEventTimeStamp, undefined);
75-
else
76-
assert(String(+header.dumpEventTimeStamp), header.dumpEventTimeStamp);
77-
73+
assert(String(+header.dumpEventTimeStamp), header.dumpEventTimeStamp);
7874
assert(Number.isSafeInteger(header.processId));
7975
assert.strictEqual(typeof header.cwd, 'string');
8076
assert(Array.isArray(header.commandLine));

0 commit comments

Comments
 (0)