GeezerVison is showing github.com — inspector: document bad usage for --inspect-port · tmarshall/node@3954ea9
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: doc/api/cli.md +12Lines changed: 12 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -112,6 +112,18 @@ added: v7.6.0 | 112 | 112 | --> | 113 | 113 |
| 114 | 114 | Activate inspector on host:port and break at start of user script. | | 115 | +Default host:port is 127.0.0.1:9229. | | 116 | + | | 117 | + | | 118 | +### `--inspect-port=[host:]port` | | 119 | +<!-- YAML | | 120 | +added: v7.6.0 | | 121 | +--> | | 122 | + | | 123 | +Set the host:port to be used when the inspector is activated. | | 124 | +Useful when activating the inspector by sending the `SIGUSR1` signal. | | 125 | + | | 126 | +Default host is 127.0.0.1. | 115 | 127 |
| 116 | 128 |
| 117 | 129 | ### `--no-deprecation` | |
Collapse file Copy file name to clipboardExpand all lines: doc/node.1 +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -106,6 +106,10 @@ instances for debugging and profiling. It uses the Chrome Debugging Protocol. | 106 | 106 | .BR \-\-inspect-brk \fI[=[host:]port]\fR | 107 | 107 | Activate inspector on host:port and break at start of user script. | 108 | 108 |
| | 109 | +.TP | | 110 | +.BR \-\-inspect-port \fI=[host:]port\fR | | 111 | +Set the host:port to be used when the inspector is activated. | | 112 | + | 109 | 113 | .TP | 110 | 114 | .BR \-\-no\-deprecation | 111 | 115 | Silence deprecation warnings. | |
Collapse file Copy file name to clipboardExpand all lines: src/node.cc +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3612,6 +3612,8 @@ static void PrintHelp() { | 3612 | 3612 | " --inspect-brk[=[host:]port]\n" | 3613 | 3613 | " activate inspector on host:port\n" | 3614 | 3614 | " and break at start of user script\n" | | 3615 | + " --inspect-port=[host:]port\n" | | 3616 | + " set host:port for inspector\n" | 3615 | 3617 | #endif | 3616 | 3618 | " --no-deprecation silence deprecation warnings\n" | 3617 | 3619 | " --trace-deprecation show stack traces on deprecations\n" | @@ -3798,7 +3800,7 @@ static void ParseArgs(int* argc, | 3798 | 3800 |
| 3799 | 3801 | CheckIfAllowedInEnv(argv[0], is_env, arg); | 3800 | 3802 |
| 3801 | | - if (debug_options.ParseOption(arg)) { | | 3803 | + if (debug_options.ParseOption(argv[0], arg)) { | 3802 | 3804 | // Done, consumed by DebugOptions::ParseOption(). | 3803 | 3805 | } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { | 3804 | 3806 | printf("%s\n", NODE_VERSION); | |
Collapse file Copy file name to clipboardExpand all lines: src/node_debug_options.cc +14-7Lines changed: 14 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,7 +62,7 @@ DebugOptions::DebugOptions() : | 62 | 62 | wait_connect_(false), http_enabled_(false), | 63 | 63 | host_name_("127.0.0.1"), port_(-1) { } | 64 | 64 |
| 65 | | -bool DebugOptions::ParseOption(const std::string& option) { | | 65 | +bool DebugOptions::ParseOption(const char* argv0, const std::string& option) { | 66 | 66 | bool enable_inspector = false; | 67 | 67 | bool has_argument = false; | 68 | 68 | std::string option_name; | @@ -72,21 +72,28 @@ bool DebugOptions::ParseOption(const std::string& option) { | 72 | 72 | if (pos == std::string::npos) { | 73 | 73 | option_name = option; | 74 | 74 | } else { | 75 | | - has_argument = true; | 76 | 75 | option_name = option.substr(0, pos); | 77 | 76 | argument = option.substr(pos + 1); | | 77 | + | | 78 | + if (argument.length() > 0) | | 79 | + has_argument = true; | | 80 | + else | | 81 | + argument.clear(); | 78 | 82 | } | 79 | 83 |
| 80 | 84 | if (option_name == "--inspect") { | 81 | 85 | enable_inspector = true; | 82 | 86 | } else if (option_name == "--inspect-brk") { | 83 | 87 | enable_inspector = true; | 84 | 88 | wait_connect_ = true; | 85 | | - } else if ((option_name != "--debug-port" && | 86 | | - option_name != "--inspect-port") || | 87 | | - !has_argument) { | 88 | | - // only other valid possibility is --inspect-port, | 89 | | - // which requires an argument | | 89 | + } else if (option_name == "--debug-port" || | | 90 | + option_name == "--inspect-port") { | | 91 | + if (!has_argument) { | | 92 | + fprintf(stderr, "%s: %s requires an argument\n", | | 93 | + argv0, option.c_str()); | | 94 | + exit(9); | | 95 | + } | | 96 | + } else { | 90 | 97 | return false; | 91 | 98 | } | 92 | 99 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node_debug_options.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,7 @@ namespace node { | 9 | 9 | class DebugOptions { | 10 | 10 | public: | 11 | 11 | DebugOptions(); | 12 | | - bool ParseOption(const std::string& option); | | 12 | + bool ParseOption(const char* argv0, const std::string& option); | 13 | 13 | bool inspector_enabled() const { | 14 | 14 | #if HAVE_INSPECTOR | 15 | 15 | return inspector_enabled_; | |
Collapse file Copy file name to clipboard +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +'use strict'; | | 2 | +require('../common'); | | 3 | + | | 4 | +// Tests that node exits consistently on bad option syntax. | | 5 | + | | 6 | +const assert = require('assert'); | | 7 | +const spawn = require('child_process').spawnSync; | | 8 | + | | 9 | +requiresArgument('--inspect-port'); | | 10 | +requiresArgument('--inspect-port='); | | 11 | +requiresArgument('--debug-port'); | | 12 | +requiresArgument('--debug-port='); | | 13 | +requiresArgument('--eval'); | | 14 | + | | 15 | +function requiresArgument(option) { | | 16 | + const r = spawn(process.execPath, [option], {encoding: 'utf8'}); | | 17 | + | | 18 | + assert.strictEqual(r.status, 9); | | 19 | + | | 20 | + const msg = r.stderr.split(/\r?\n/)[0]; | | 21 | + assert.strictEqual(msg, process.execPath + ': ' + option + | | 22 | + ' requires an argument'); | | 23 | +} |
|