Title: [207387] trunk/Source/_javascript_Core
Revision
207387
Author
mark....@apple.com
Date
2016-10-15 18:44:18 -0700 (Sat, 15 Oct 2016)

Log Message

Add a $vm.getpid() method.
https://bugs.webkit.org/show_bug.cgi?id=163493

Reviewed by Saam Barati.

This is especially useful when we need to know the pid of an instance of jsc in
the foreground that we're trying to attach a debugger to while the JSC tests are
running in the background with a gazillion other jsc processes live at the same
time.

Currently, $vm.getpid() is only supported on non-Windows platforms.
According to https://msdn.microsoft.com/en-us/library/ms235372.aspx, getpid() is
deprecated.  According to https://msdn.microsoft.com/en-us/library/t2y34y40.aspx,
_getpid() cannot be used in applications that execute in the Windows Runtime.

Since this is only a debugging tool and is not a required feature, I'll defer
the Windows implementation of this function till the time when someone actually
needs it.

* tools/JSDollarVMPrototype.cpp:
(JSC::functionGetPID):
(JSC::JSDollarVMPrototype::finishCreation):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (207386 => 207387)


--- trunk/Source/_javascript_Core/ChangeLog	2016-10-16 00:19:22 UTC (rev 207386)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-10-16 01:44:18 UTC (rev 207387)
@@ -1,3 +1,28 @@
+2016-10-15  Mark Lam  <mark....@apple.com>
+
+        Add a $vm.getpid() method.
+        https://bugs.webkit.org/show_bug.cgi?id=163493
+
+        Reviewed by Saam Barati.
+
+        This is especially useful when we need to know the pid of an instance of jsc in
+        the foreground that we're trying to attach a debugger to while the JSC tests are
+        running in the background with a gazillion other jsc processes live at the same
+        time.
+
+        Currently, $vm.getpid() is only supported on non-Windows platforms.
+        According to https://msdn.microsoft.com/en-us/library/ms235372.aspx, getpid() is
+        deprecated.  According to https://msdn.microsoft.com/en-us/library/t2y34y40.aspx,
+        _getpid() cannot be used in applications that execute in the Windows Runtime.
+
+        Since this is only a debugging tool and is not a required feature, I'll defer
+        the Windows implementation of this function till the time when someone actually
+        needs it.
+
+        * tools/JSDollarVMPrototype.cpp:
+        (JSC::functionGetPID):
+        (JSC::JSDollarVMPrototype::finishCreation):
+
 2016-10-15  Saam Barati  <sbar...@apple.com>
 
         Assertion failed under operationToLowerCase with a rope with zero length

Modified: trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp (207386 => 207387)


--- trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp	2016-10-16 00:19:22 UTC (rev 207386)
+++ trunk/Source/_javascript_Core/tools/JSDollarVMPrototype.cpp	2016-10-16 01:44:18 UTC (rev 207387)
@@ -411,6 +411,13 @@
     return JSValue::encode(jsString(exec, stream.toString()));
 }
 
+#if !PLATFORM(WIN)
+static EncodedJSValue JSC_HOST_CALL functionGetPID(ExecState*)
+{
+    return JSValue::encode(jsNumber(getpid()));
+}
+#endif
+
 void JSDollarVMPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
 {
     Base::finishCreation(vm);
@@ -434,6 +441,9 @@
     addFunction(vm, globalObject, "printStack", functionPrintStack, 0);
 
     addFunction(vm, globalObject, "value", functionValue, 1);
+#if !PLATFORM(WIN)
+    addFunction(vm, globalObject, "getpid", functionGetPID, 0);
+#endif
 }
 
 } // namespace JSC
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to