Trigger printAllStacks with SIGUSR1 (was: [squeak-dev] Headless Linux squeak running max cpu)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Trigger printAllStacks with SIGUSR1 (was: [squeak-dev] Headless Linux squeak running max cpu)

David T. Lewis
 
On Sun, Jul 18, 2010 at 12:24:00PM -0700, Eliot Miranda wrote:

<snip>

> In Cog platforms/unix/vm/sqUnixMain.c you'll find code to cause SIGUSR1 to
> print all stacks.  This can easily be ported to the standard VM. Is the
> above with Cog or the standard VM?

It would be best not to tie printAllStacks() to a specific signal, because
SIGUSR1 is often used by third-party libraries that may be embedded in
plugins or called through FFI. Perhaps it could be to enabled via a command
line option if it is going to be part of the VM proper.

But the feature also seemed like a reasonable fit for OSProcessPlugin,
so I added it to OSPP and OSProcess (SqueakSource latest versions).
OSPP already had a mechanism for forwarding arbitrary unix signals to
Smalltalk semaphores, so the printAllStacks() hook is embedded into that
framework. The updates are:

OSProcessPlugin 4.3.4

Add #primitivePrintAllStacksOnSignal to attach the printAllStacks()
interpreter debugging function to a unix signal. Intended for debugging
support to enable SIGUSR1 to trigger a stack trace on console output.

OSProcess 4.3.13

Implement debugging stack dump methods:
  UnixOSProcessAccessor>>setPrintAllStacksOnSigUsr1
  UnixOSProcessAccessor>>clearPrintAllStacksOnSigUsr1
  UnixOSProcessAccessor>>primPrintAllStacksOnSignal:

To enable printAllStacks() on receipt of a SIGUSR1 signal:
    OSProcess accessor setPrintAllStacksOnSigUsr1

To disable printAllStacks() and restore the default SIGUSR1 handler:
    OSProcess accessor clearPrintAllStacksOnSigUsr1

Dave