[PATCH] D63750: [WIP} Dump current PrettyStackTrace on SIGINFO (Ctrl-T)

Jordan Rose via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 19:48:50 PDT 2019


jordan_rose created this revision.
jordan_rose added a reviewer: jfb.
Herald added subscribers: llvm-commits, kristina, dexonsmith.
Herald added a project: LLVM.

Support SIGINFO (and SIGUSR1 for POSIX purposes) to tell what long-running jobs are doing, as inspired by BSD tools (including on macOS), by dumping the current PrettyStackTrace.

This adds a new kind of signal handler for non-fatal "info" signals, similar to the "interrupt" handler that already exists for SIGINT (Ctrl-C). It then uses that handler to update a "generation count" managed by the PrettyStackTrace infrastructure, which is then checked whenever a PrettyStackTraceEntry is pushed or popped on each thread. If the generation has changed—i.e. if the user has pressed Ctrl-T—the stack trace is dumped, though unfortunately it can't include the deepest entry because that one is currently being constructed/destructed.

Still to do:

- Instead of having this always be on, make it a per-thread opt-in. That leaves the potential for it to be useful in multi-threaded programs.

Out of scope:

- Multiple SIGINFO callbacks. I don't know how interesting this is anyway, given that they're still bound by what a signal handler can do.

- Windows support. Windows console programs don't seem to have a SIGINFO equivalent anyway, so when someone figures out the right thing, they can add equivalent support.

- Choosing whether to include SIGUSR1. I did this just because it was mentioned when I was looking up things about SIGINFO, but SIGINFO is the one I care about, so if people tell me they're not sure about SIGUSR1 I'll just remove it.

- Figuring out how to print the actual current PrettyStackTrace, instead of the parent one, despite the construction/destruction problem. The simplest answer I can think of requires changing all of the PrettyStackTraceEntry instances in existence, which probably isn't going to fly for something that's ultimately a convenience feature. Someone else can figure it out.


Repository:
  rL LLVM

https://reviews.llvm.org/D63750

Files:
  include/llvm/Support/Signals.h
  lib/Support/PrettyStackTrace.cpp
  lib/Support/Unix/Signals.inc
  lib/Support/Windows/Signals.inc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63750.206355.patch
Type: text/x-patch
Size: 9475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190625/ea4e9976/attachment.bin>


More information about the llvm-commits mailing list