summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/inspector_agent.cc3
-rw-r--r--src/inspector_io.cc13
-rw-r--r--src/node.cc13
-rw-r--r--src/node_internals.h3
-rw-r--r--src/util.cc12
5 files changed, 23 insertions, 21 deletions
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index 798b80df86..875c12efa0 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -302,7 +302,8 @@ class NodeInspectorClient : public V8InspectorClient {
: env_(env), platform_(platform), terminated_(false),
running_nested_loop_(false) {
client_ = V8Inspector::create(env->isolate(), this);
- contextCreated(env->context(), "Node.js Main Context");
+ // TODO(bnoordhuis) Make name configurable from src/node.cc.
+ contextCreated(env->context(), GetHumanReadableProcessName());
}
void runMessageLoopOnPause(int context_group_id) override {
diff --git a/src/inspector_io.cc b/src/inspector_io.cc
index a870c0a263..538cbab3c9 100644
--- a/src/inspector_io.cc
+++ b/src/inspector_io.cc
@@ -26,17 +26,6 @@ using v8_inspector::StringView;
template<typename Transport>
using TransportAndIo = std::pair<Transport*, InspectorIo*>;
-std::string GetProcessTitle() {
- char title[2048];
- int err = uv_get_process_title(title, sizeof(title));
- if (err == 0) {
- return title;
- } else {
- // Title is too long, or could not be retrieved.
- return "Node.js";
- }
-}
-
std::string ScriptPath(uv_loop_t* loop, const std::string& script_name) {
std::string script_path;
@@ -484,7 +473,7 @@ std::vector<std::string> InspectorIoDelegate::GetTargetIds() {
}
std::string InspectorIoDelegate::GetTargetTitle(const std::string& id) {
- return script_name_.empty() ? GetProcessTitle() : script_name_;
+ return script_name_.empty() ? GetHumanReadableProcessName() : script_name_;
}
std::string InspectorIoDelegate::GetTargetUrl(const std::string& id) {
diff --git a/src/node.cc b/src/node.cc
index 0bd9a44658..e1b80c239c 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -1653,14 +1653,11 @@ NO_RETURN void Assert(const char* const (*args)[4]) {
auto message = (*args)[2];
auto function = (*args)[3];
- char exepath[256];
- size_t exepath_size = sizeof(exepath);
- if (uv_exepath(exepath, &exepath_size))
- snprintf(exepath, sizeof(exepath), "node");
-
- fprintf(stderr, "%s[%u]: %s:%s:%s%s Assertion `%s' failed.\n",
- exepath, GetProcessId(), filename, linenum,
- function, *function ? ":" : "", message);
+ char name[1024];
+ GetHumanReadableProcessName(&name);
+
+ fprintf(stderr, "%s: %s:%s:%s%s Assertion `%s' failed.\n",
+ name, filename, linenum, function, *function ? ":" : "", message);
fflush(stderr);
Abort();
diff --git a/src/node_internals.h b/src/node_internals.h
index 7c4a0d9fa2..b7d032c68d 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -251,6 +251,9 @@ void RegisterSignalHandler(int signal,
uint32_t GetProcessId();
bool SafeGetenv(const char* key, std::string* text);
+std::string GetHumanReadableProcessName();
+void GetHumanReadableProcessName(char (*name)[1024]);
+
template <typename T, size_t N>
constexpr size_t arraysize(const T(&)[N]) { return N; }
diff --git a/src/util.cc b/src/util.cc
index 0fb897bc8e..2aa9fb026e 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -113,6 +113,18 @@ void LowMemoryNotification() {
}
}
+std::string GetHumanReadableProcessName() {
+ char name[1024];
+ GetHumanReadableProcessName(&name);
+ return name;
+}
+
+void GetHumanReadableProcessName(char (*name)[1024]) {
+ char title[1024] = "Node.js";
+ uv_get_process_title(title, sizeof(title));
+ snprintf(*name, sizeof(*name), "%s[%u]", title, GetProcessId());
+}
+
uint32_t GetProcessId() {
#ifdef _WIN32
return GetCurrentProcessId();