| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7ecec67 commit 362b8c7
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -302,7 +302,8 @@ class NodeInspectorClient : public V8InspectorClient { | |||
| 302 | 302 | : env_(env), platform_(platform), terminated_(false), | |
| 303 | 303 | running_nested_loop_(false) { | |
| 304 | 304 | client_ = V8Inspector::create(env->isolate(), this); | |
| 305 | - contextCreated(env->context(), "Node.js Main Context"); | ||
| 305 | + // TODO(bnoordhuis) Make name configurable from src/node.cc. | ||
| 306 | + contextCreated(env->context(), GetHumanReadableProcessName()); | ||
| 306 | 307 | } | |
| 307 | 308 | ||
| 308 | 309 | void runMessageLoopOnPause(int context_group_id) override { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,17 +26,6 @@ using v8_inspector::StringView; | |||
| 26 | 26 | template<typename Transport> | |
| 27 | 27 | using TransportAndIo = std::pair<Transport*, InspectorIo*>; | |
| 28 | 28 | ||
| 29 | - std::string GetProcessTitle() { | ||
| 30 | - char title[2048]; | ||
| 31 | - int err = uv_get_process_title(title, sizeof(title)); | ||
| 32 | - if (err == 0) { | ||
| 33 | - return title; | ||
| 34 | - } else { | ||
| 35 | - // Title is too long, or could not be retrieved. | ||
| 36 | - return "Node.js"; | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | 29 | std::string ScriptPath(uv_loop_t* loop, const std::string& script_name) { | |
| 41 | 30 | std::string script_path; | |
| 42 | 31 | ||
@@ -484,7 +473,7 @@ std::vector<std::string> InspectorIoDelegate::GetTargetIds() { | |||
| 484 | 473 | } | |
| 485 | 474 | ||
| 486 | 475 | std::string InspectorIoDelegate::GetTargetTitle(const std::string& id) { | |
| 487 | - return script_name_.empty() ? GetProcessTitle() : script_name_; | ||
| 476 | + return script_name_.empty() ? GetHumanReadableProcessName() : script_name_; | ||
| 488 | 477 | } | |
| 489 | 478 | ||
| 490 | 479 | std::string InspectorIoDelegate::GetTargetUrl(const std::string& id) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1989,14 +1989,11 @@ NO_RETURN void Assert(const char* const (*args)[4]) { | |||
| 1989 | 1989 | auto message = (*args)[2]; | |
| 1990 | 1990 | auto function = (*args)[3]; | |
| 1991 | 1991 | ||
| 1992 | - char exepath[256]; | ||
| 1993 | - size_t exepath_size = sizeof(exepath); | ||
| 1994 | - if (uv_exepath(exepath, &exepath_size)) | ||
| 1995 | - snprintf(exepath, sizeof(exepath), "node"); | ||
| 1996 | - | ||
| 1997 | - fprintf(stderr, "%s[%u]: %s:%s:%s%s Assertion `%s' failed.\n", | ||
| 1998 | - exepath, GetProcessId(), filename, linenum, | ||
| 1999 | - function, *function ? ":" : "", message); | ||
| 1992 | + char name[1024]; | ||
| 1993 | + GetHumanReadableProcessName(&name); | ||
| 1994 | + | ||
| 1995 | + fprintf(stderr, "%s: %s:%s:%s%s Assertion `%s' failed.\n", | ||
| 1996 | + name, filename, linenum, function, *function ? ":" : "", message); | ||
| 2000 | 1997 | fflush(stderr); | |
| 2001 | 1998 | ||
| 2002 | 1999 | Abort(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,6 +169,9 @@ void RegisterSignalHandler(int signal, | |||
| 169 | 169 | uint32_t GetProcessId(); | |
| 170 | 170 | bool SafeGetenv(const char* key, std::string* text); | |
| 171 | 171 | ||
| 172 | + std::string GetHumanReadableProcessName(); | ||
| 173 | + void GetHumanReadableProcessName(char (*name)[1024]); | ||
| 174 | + | ||
| 172 | 175 | template <typename T, size_t N> | |
| 173 | 176 | constexpr size_t arraysize(const T(&)[N]) { return N; } | |
| 174 | 177 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,6 +113,18 @@ void LowMemoryNotification() { | |||
| 113 | 113 | } | |
| 114 | 114 | } | |
| 115 | 115 | ||
| 116 | + std::string GetHumanReadableProcessName() { | ||
| 117 | + char name[1024]; | ||
| 118 | + GetHumanReadableProcessName(&name); | ||
| 119 | + return name; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + void GetHumanReadableProcessName(char (*name)[1024]) { | ||
| 123 | + char title[1024] = "Node.js"; | ||
| 124 | + uv_get_process_title(title, sizeof(title)); | ||
| 125 | + snprintf(*name, sizeof(*name), "%s[%u]", title, GetProcessId()); | ||
| 126 | + } | ||
| 127 | + | ||
| 116 | 128 | uint32_t GetProcessId() { | |
| 117 | 129 | #ifdef _WIN32 | |
| 118 | 130 | return GetCurrentProcessId(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,9 +23,18 @@ async function testContextCreatedAndDestroyed() { | |||
| 23 | 23 | ||
| 24 | 24 | session.post('Runtime.enable'); | |
| 25 | 25 | let contextCreated = await mainContextPromise; | |
| 26 | - strictEqual('Node.js Main Context', | ||
| 27 | - contextCreated.params.context.name, | ||
| 28 | - JSON.stringify(contextCreated)); | ||
| 26 | + { | ||
| 27 | + const { name } = contextCreated.params.context; | ||
| 28 | + if (common.isSunOS || common.isWindows) { | ||
| 29 | + // uv_get_process_title() is unimplemented on Solaris-likes, it returns | ||
| 30 | + // an empy string. On the Windows CI buildbots it returns "Administrator: | ||
| 31 | + // Windows PowerShell[42]" because of a GetConsoleTitle() quirk. Not much | ||
| 32 | + // we can do about either, just verify that it contains the PID. | ||
| 33 | + strictEqual(name.includes(`[${process.pid}]`), true); | ||
| 34 | + } else { | ||
| 35 | + strictEqual(`${process.argv0}[${process.pid}]`, name); | ||
| 36 | + } | ||
| 37 | + } | ||
| 29 | 38 | ||
| 30 | 39 | const secondContextCreatedPromise = | |
| 31 | 40 | notificationPromise('Runtime.executionContextCreated'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments