diff options
author | cjihrig <cjihrig@gmail.com> | 2019-03-31 06:05:48 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-04-03 03:48:59 +0300 |
commit | d5a5b99eafe157080db13f8221ecb64c3a092788 (patch) | |
tree | a14779d7d7cdd7f1fded63ca63eb2b61aa994c48 /src/node_report.cc | |
parent | 19442656789a7edd327d453a16f699d4f5259a5c (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>
Diffstat (limited to 'src/node_report.cc')
-rw-r--r-- | src/node_report.cc | 16 |
1 files changed, 16 insertions, 0 deletions
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"); |