summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-11-20 23:37:50 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2017-11-20 23:37:50 +0100
commitf526deb0407412e089382900e3fc4560eea3a938 (patch)
tree3900be9dae9cfc4f4920edaaa0ea9f54471c3cf4 /src/util.cc
parent7dc35e937d6b3cf57e6184dfc3d54633e5b69082 (diff)
downloadandroid-node-v8-f526deb0407412e089382900e3fc4560eea3a938.tar.gz
android-node-v8-f526deb0407412e089382900e3fc4560eea3a938.tar.bz2
android-node-v8-f526deb0407412e089382900e3fc4560eea3a938.zip
src: inspector context name = program title + pid
Report (for example) "node[1337]" as the human-readable name rather than the more generic and less helpful "Node.js Main Context." While not perfect yet, it should be an improvement to people that debug multiple processes from DevTools, VS Code, etc. PR-URL: https://github.com/nodejs/node/pull/17087 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc12
1 files changed, 12 insertions, 0 deletions
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();