foundationdb/fdbserver/SigStack.cpp
Lukas Joswiak 153de33f57 Revert "Merge pull request #4802 from sfc-gh-ljoswiak/revert/actor-lineage"
This reverts commit 6499fa178e8f65a22105c2cd062a67209b562973, reversing
changes made to 15126319577f915f28aa6308bbf066dc7ec992a2.
2021-06-04 13:31:55 -07:00

24 lines
583 B
C++

#include "flow/flow.h"
#include <csignal>
#include <iostream>
#include <string_view>
// This is not yet correct, as this is not async safe
// However, this should be good enough for an initial
// proof of concept.
extern "C" void stackSignalHandler(int sig) {
auto stack = getActorStackTrace();
int i = 0;
while (!stack.empty()) {
auto s = stack.back();
stack.pop_back();
std::string_view n(reinterpret_cast<const char*>(s.begin()), s.size());
std::cout << i << ": " << n << std::endl;
++i;
}
}
void setupStackSignal() {
std::signal(SIGUSR1, &stackSignalHandler);
}