-
Notifications
You must be signed in to change notification settings - Fork 45
Conversation
@hhellyer could you document how this is supposed to be used? :D |
I've added some sample output. |
@hhellyer it looks like there are conflicts in |
Is it possible to get the equivalent information on AIX and Windows? |
Also needs tests. |
@richardlau It looked like Windows had globals (__argv, __argc) which you could use, though I've not tested them as I don't have a windows box easily accessible. See: https://msdn.microsoft.com/en-us/library/dn727674.aspx for details, there may be a better way - I only had a quick look. |
Windows: GetCommandLine() AIX: getargs(). I actually used this to fix libuv/libuv#464 (although in that case we were only interested in the first argument of the command line). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like tests for this to be added and coverage extended to Windows and AIX.
Looks good
|
…ort on Linux, Mac and AIX. On Linux it reads /proc/self/cmdline. On Mac is uses _NSGetArgv and _NSGetArgc. On AIX it reads /proc/PID/psinfo. The command line is read and stored at startup so files aren't opened when a crash is occuring.
I've added AIX support. Note that on AIX we get the wrong command but that's because of nodejs/node#10607 and we give the same result as the ps command. I've squashed the commits down, it looks like github shows the changes on the branch and not a diff against the merge destination which is confusing if you pull in changes from there, which I had done. At least I think that's what was happening... :-) |
commandline_string += seperator + argv[i]; | ||
seperator = " "; | ||
} | ||
#elif _AIX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation for this #elif
block is different from the rest of this function, please can you make it consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the function was wrong and didn't match the file. I'd indented when starting #ifdef sections. I've adjusted the rest of the function to be correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about additional tests to validate we get he command line section ?
int argc = *_NSGetArgc(); | ||
|
||
commandline_string = ""; | ||
std::string seperator = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seperator
-> separator
fclose(psinfo_fd); | ||
if (bytesread == sizeof(psinfo_t)) { | ||
commandline_string = ""; | ||
std::string seperator = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: seperator
-> separator
Add a check for the command line to common.js. Add expected command line to all the test cases that pass an expected pid.
I've added the testcases or extended the existing ones. |
This change adds the command line to NodeReport on Windows. It uses the Windows GetCommandLine() API to obtain the command line. Also includes a minor change to print "Command line:" rather than "Command line arguments:" in the report as prefix, plus updates to the testcases.
Added commit dd20187 for support on Windows. I think this PR has all we need now. |
@@ -36,18 +36,18 @@ exports.validate = (t, report, options) => { | |||
const expectedVersions = options ? | |||
options.expectedVersions || nodeComponents : | |||
nodeComponents; | |||
const plan = REPORT_SECTIONS.length + nodeComponents.length + 2; | |||
var plan = REPORT_SECTIONS.length + nodeComponents.length + 2; | |||
if( options.commandline ) plan++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces -> if (options.commandline) plan++;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
const nodeReportSection = getSection(reportContents, 'NodeReport'); | ||
t.match(nodeReportSection, new RegExp('Process ID: ' + pid), | ||
t.contains(nodeReportSection, new RegExp('Process ID: ' + pid), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hhellyer said it fixed a test failure, but http://www.node-tap.org/asserts/ indicates that .contains is simply a synonym for .match, so I have reverted it. The tests pass ok for me on Linux, Windows and Mac.
// On Windows we need to strip out double quotes from the command line in the | ||
// report, and escape the backslashes in the regex comparison string. | ||
t.match(nodeReportSection.replace(/"/g,''), | ||
new RegExp('Command line: ' + (options.commandline).replace(/\\/g,'\\\\')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is > 80 chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM subject to fixing the minor comments from Richard L
Currect spacing on if test, revert use of t.contains to t.match, reduce line lengths to 80 or less.
if (options && options.commandline) { | ||
if (this.isWindows()) { | ||
// On Windows we need to strip double quotes from the command line in | ||
// the report, and escape backslashes in the regex comparison string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n.b. I'm not seeing any double quotes in the reported command line in the reports generated from the tests on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might depend on the shell or the executable path. This is what I am seeing on Windows:
==== NodeReport ================================================================
Event: JavaScript API, location: "TriggerReport"
Filename: NodeReport.20170110.113318.2184.001.txt
Dump event time: 2017/01/10 11:33:18
Module load time: 2017/01/10 11:33:18
Process ID: 2184
Command line: "C:\Program Files\nodejs6\node.exe" C:\tmp\nodereport\test\test-api-bad-processobj.js child
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think it might be spaces in the paths -- I get the same if I use Node.js installed under C:\Program Files
On Linux it reads /proc/self/cmdline. On Mac is uses _NSGetArgv and _NSGetArgc. On AIX it reads /proc/PID/psinfo. On Windows it uses the GetCommandLine() API. The command line is read and stored at startup so files aren't opened when a crash is occuring. PR-URL: #34 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Landed as c6db073 |
This patch adds the command line used to start the process to nodereport.
It's based off https://github.com/rnchamberlain/nodereport/tree/clang_warning so it could be built and tested on Mac. It should merge cleanly once that has been landed.
One line is added to the NodeReport file. Sample output from a test script that generates a report:
> node --no-warnings my_application.js -a an_argument file.txt
First part of the generated NodeReport file: