Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#include "FWCore/MessageService/test/makeSignals.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/MessageLogger/interface/MessageDrop.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include <iostream>
#include <string>
#include <csignal>

#define RAISE_SEGV
//#define RAISE_USR2

namespace edmtest {

  void makeSignals::analyze(edm::StreamID, edm::Event const& e, edm::EventSetup const& /*unused*/
  ) const {
#ifdef RAISE_SEGV
    int signum = 11;
    std::string SigName("SIGSEGV");
#endif

#ifdef RAISE_USR2
    int signum = 12;
    std::string SigName("SIGUSR2");
#endif
    edm::MessageDrop::instance()->debugEnabled = true;

    LogTrace("cat_A") << "LogTrace was used to send this mess"
                      << "age";
    LogDebug("cat_B") << "LogDebug was used to send this other message";
    edm::LogVerbatim("cat_A") << "LogVerbatim was us"
                              << "ed to send this message";
    if (edm::isInfoEnabled())
      edm::LogInfo("cat_B") << "LogInfo was used to send this other message\n";

    if (e.id().event() == 5) {
      std::cerr << "Raising Signal " << SigName << " = " << signum << std::endl;
      edm::LogInfo("Signals") << "Raising Signal " << SigName << " = " << signum;
#ifdef RAISE_SEGV
      raise(SIGSEGV);
#endif

#ifdef RAISE_USR2
      raise(SIGUSR2);
#endif

      //  Force a Seg Fault
      //  int * pint = 0;
      //  int rint = *pint;
    }
  }  // makeSignals::analyze()
}  // namespace edmtest

using edmtest::makeSignals;
DEFINE_FWK_MODULE(makeSignals);