Ignore:
Timestamp:
May 2, 2022, 3:33:52 PM (3 years ago)
Author:
Justin Michaud
Message:

Add option to JSC shell to wait for a USR2 signal before exiting to aid in collection of vmmaps
https://bugs.webkit.org/show_bug.cgi?id=239919

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

  • jsc.cpp:

(main):

Source/WTF:

  • wtf/threads/Signals.h:

(WTF::toSystemSignal):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r293588 r293688  
    9696#include <wtf/WallTime.h>
    9797#include <wtf/text/StringBuilder.h>
     98#include <wtf/threads/BinarySemaphore.h>
    9899#include <wtf/threads/Signals.h>
    99100
     
    30363037#endif
    30373038
     3039#if OS(UNIX)
     3040    BinarySemaphore waitToExit;
     3041
     3042    if (getenv("JS_SHELL_WAIT_FOR_SIGUSR2_TO_EXIT")) {
     3043        addSignalHandler(Signal::Usr, SignalHandler([&] (Signal, SigInfo&, PlatformRegisters&) {
     3044            dataLogLn("Signal handler hit, we can exit now.");
     3045            waitToExit.signal();
     3046            return SignalAction::Handled;
     3047        }));
     3048        activateSignalHandlersFor(Signal::Usr);
     3049    }
     3050#endif
     3051
    30383052    // We can't use destructors in the following code because it uses Windows
    30393053    // Structured Exception Handling
     
    30493063        getc(stdin);
    30503064    }
     3065
     3066#if OS(UNIX)
     3067    if (getenv("JS_SHELL_WAIT_FOR_SIGUSR2_TO_EXIT")) {
     3068        WTF::fastDisableScavenger();
     3069        fprintf(stdout, "\njs shell waiting for `kill -USR2 [pid]` to exit\n");
     3070        fflush(stdout);
     3071
     3072        waitToExit.wait();
     3073
     3074        fprintf(stdout, "\njs shell exiting\n");
     3075        fflush(stdout);
     3076    }
     3077#endif
    30513078
    30523079    jscExit(res);
Note: See TracChangeset for help on using the changeset viewer.