Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-03-31 06:05:48 +0300
committerBeth Griggs <Bethany.Griggs@uk.ibm.com>2019-04-10 17:30:28 +0300
commitd3c148118cc25e7240790a5e76c57e41f1066ed0 (patch)
tree9a063018c8515929d5cced006f864366a5e0f389
parentfec9f76037dbba59772218fc87de294e32a601d2 (diff)
report: add cwd to report
The diagnostic report currently contains command line information, and the environment, which contains the PWD environment variable. This combination covers the majority of cases, but it would be useful to have the result of uv_cwd() as an additional data point. This commit adds that information. PR-URL: https://github.com/nodejs/node/pull/27022 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
-rw-r--r--doc/api/report.md1
-rw-r--r--src/node_report.cc16
-rw-r--r--test/common/report.js3
3 files changed, 19 insertions, 1 deletions
diff --git a/doc/api/report.md b/doc/api/report.md
index a7715751d57..5427d3d8329 100644
--- a/doc/api/report.md
+++ b/doc/api/report.md
@@ -28,6 +28,7 @@ is provided below for reference.
"dumpEventTime": "2018-12-21T00:50:11Z",
"dumpEventTimeStamp": "1545371411331",
"processId": 8974,
+ "cwd": "/home/nodeuser/project/node",
"commandLine": [
"/home/nodeuser/project/node/out/Release/node",
"--experimental-report",
diff --git a/src/node_report.cc b/src/node_report.cc
index f9cf9211434..3ca120457f1 100644
--- a/src/node_report.cc
+++ b/src/node_report.cc
@@ -18,6 +18,14 @@
#include <atomic>
#include <fstream>
#include <iomanip>
+#include <climits> // PATH_MAX
+
+#ifdef _WIN32
+/* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */
+#define PATH_MAX_BYTES (MAX_PATH * 4)
+#else
+#define PATH_MAX_BYTES (PATH_MAX)
+#endif
#ifndef _WIN32
extern char** environ;
@@ -213,6 +221,14 @@ static void WriteNodeReport(Isolate* isolate,
// Report native process ID
writer.json_keyvalue("processId", pid);
+ {
+ // Report the process cwd.
+ char buf[PATH_MAX_BYTES];
+ size_t cwd_size = sizeof(buf);
+ if (uv_cwd(buf, &cwd_size) == 0)
+ writer.json_keyvalue("cwd", buf);
+ }
+
// Report out the command line.
if (!node::per_process::cli_options->cmdline.empty()) {
writer.json_arraystart("commandLine");
diff --git a/test/common/report.js b/test/common/report.js
index a9c1d038d22..f3942c5d298 100644
--- a/test/common/report.js
+++ b/test/common/report.js
@@ -63,7 +63,7 @@ function _validateContent(data) {
'nodejsVersion', 'wordSize', 'arch', 'platform',
'componentVersions', 'release', 'osName', 'osRelease',
'osVersion', 'osMachine', 'host', 'glibcVersionRuntime',
- 'glibcVersionCompiler'];
+ 'glibcVersionCompiler', 'cwd'];
checkForUnknownFields(header, headerFields);
assert.strictEqual(typeof header.event, 'string');
assert.strictEqual(typeof header.trigger, 'string');
@@ -76,6 +76,7 @@ function _validateContent(data) {
assert(String(+header.dumpEventTimeStamp), header.dumpEventTimeStamp);
assert(Number.isSafeInteger(header.processId));
+ assert.strictEqual(typeof header.cwd, 'string');
assert(Array.isArray(header.commandLine));
header.commandLine.forEach((arg) => {
assert.strictEqual(typeof arg, 'string');