Bug 163493

Summary: Add a $vm.getpid() method.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, jfbastien, keith_miller, msaboff, saam
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch.
mark.lam: review-, mark.lam: commit-queue-
proposed patch. none

Description Mark Lam 2016-10-15 16:20:51 PDT
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.
Comment 1 Mark Lam 2016-10-15 16:24:07 PDT
Created attachment 291730 [details]
proposed patch.
Comment 2 JF Bastien 2016-10-15 16:41:05 PDT
Comment on attachment 291730 [details]
proposed patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=291730&action=review

Test that it returns a non-0 and non-1 integer?

> Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp:416
> +    return JSValue::encode(JSValue(getpid()));

Does that work on Windows? Docs say deprecated, but I don't see why they'd remove it.
Comment 3 Mark Lam 2016-10-15 16:48:16 PDT
(In reply to comment #2)
> Comment on attachment 291730 [details]
> proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=291730&action=review
> 
> Test that it returns a non-0 and non-1 integer?

I don't think it matters.  This is just a debugging tool, and we just want whatever int value getpid() returns.

> > Source/JavaScriptCore/tools/JSDollarVMPrototype.cpp:416
> > +    return JSValue::encode(JSValue(getpid()));
> 
> Does that work on Windows? Docs say deprecated, but I don't see why they'd
> remove it.

Good catch.  Let me fix.
Comment 4 Mark Lam 2016-10-15 17:10:10 PDT
Created attachment 291731 [details]
proposed patch.
Comment 5 JF Bastien 2016-10-15 17:46:00 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > Comment on attachment 291730 [details]
> > proposed patch.
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=291730&action=review
> > 
> > Test that it returns a non-0 and non-1 integer?
> 
> I don't think it matters.  This is just a debugging tool, and we just want
> whatever int value getpid() returns.

Yeah but broken debugging is worst debugging. Unlikely to fail given the posix spec, but getting just 0 is really annoying.

I don't care much about it, just seems weird, so lgtm either way.
Comment 6 Saam Barati 2016-10-15 18:23:56 PDT
Comment on attachment 291731 [details]
proposed patch.

r=me
Comment 7 WebKit Commit Bot 2016-10-15 18:46:57 PDT
Comment on attachment 291731 [details]
proposed patch.

Clearing flags on attachment: 291731

Committed r207387: <http://trac.webkit.org/changeset/207387>
Comment 8 WebKit Commit Bot 2016-10-15 18:47:01 PDT
All reviewed patches have been landed.  Closing bug.