Print all core dump records.
399{
400 std::ostringstream
os;
402 const time_t
now =
time(
nullptr);
403
404#define PR(FMT, ...) std::println(os, FMT __VA_OPT__(,) __VA_ARGS__)
405
406 PR(
"-------------------------------------------------------------------------------------");
407 std::print (os, "Core dump from {} on {} at {}",
408 name(), System::hostName(), ctime_r(&now, buf));
410
411
414
415 PR (
"Caught signal {}({}). Details: ", signo, strsignal(signo));
416
417 PR (
" errno = {}, code = {} ({})",
419
421#ifndef __APPLE__
422
424#endif
425
426
428
429 const long pagesz = sysconf(_SC_PAGESIZE);
430 PR (
" vmem = {} MB\n"
431 " rss = {} MB",
432 s.vm_pages*pagesz/1024./1024.,
s.rss_pages*pagesz/1024./1024.);
433
434#ifndef __APPLE__
435
436
437
438 {
440 if ( 0 == sysinfo(&sys) ) {
441
442 const float mem_units =
sys.mem_unit/(1024.*1024.);
443 PR (
" total-ram = {} MB\n"
444 " free-ram = {} MB\n"
445 " buffer-ram= {} MB\n"
446 " total-swap= {} MB\n"
447 " free-swap = {} MB",
448 sys.totalram * mem_units,
449 sys.freeram * mem_units,
450 sys.bufferram* mem_units,
451 sys.totalswap* mem_units,
452 sys.freeswap * mem_units);
453 }
454 }
455#endif
456
457
458 if (signo == SIGILL || signo == SIGFPE || signo == SIGSEGV || signo == SIGBUS)
460
462 }
463
465
466 SmartIF<IAlgManager> algMgr{serviceLocator()->as<IAlgManager>()};
467 SmartIF<IAlgContextSvc> algContextSvc;
468
469
470
471 if (Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() == 0) {
472 algContextSvc = service("AlgContextSvc", false);
473 }
474
475
477
478
479 std::string currentAlg;
480
481
482 if (Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 0) {
483 const EventContext ctx(0,t);
484 ATH_MSG_DEBUG(
"Using AlgExecStateSvc to determine current algorithm(s)");
485 try {
486 for (const IAlgorithm* alg : algMgr->getAlgorithms()) {
487 auto aes =
alg->execState(ctx);
488 if (aes.state()==AlgExecState::State::Executing)
489 currentAlg += (
alg->name() +
" ");
490 }
491 }
492 catch (const GaudiException&) {
493 ATH_MSG_INFO(
"No information from AlgExecStateSvc because no algorithm was executed yet.");
494 }
495 }
496 else if (algContextSvc) {
497 ATH_MSG_DEBUG(
"Using AlgContextSvc to determine current algorithm");
498 IAlgorithm*
alg = algContextSvc->currentAlg();
499 if (alg) currentAlg =
alg->name();
500 }
501 else {
502 ATH_MSG_WARNING(
"AlgExecStateSvc or AlgContextSvc not available. Cannot determine current algorithm.");
503 }
504
505 if (currentAlg.empty()) currentAlg = "<NONE>";
506 PR (
"Slot {:3} : Current algorithm = {}", t, currentAlg);
507
508
510 if (!
sys.LastInc.empty()) {
511 PR (
" : Last Incident = {}\n"
512 " : Event ID = {}",
514 }
515
516
518 if (!usr.empty()) {
519 for (auto &s : usr) {
520 PR (
" : (usr) {} = {}",
s.first,
s.second);
521 }
522 }
523 }
524
525 if (algContextSvc) {
526 std::print (os, "Algorithm stack: ");
527 if ( algContextSvc->algorithms().empty() )
529 else {
531 for (auto alg : algContextSvc->algorithms()) {
532 if (alg)
PR (
" {}",
alg->name());
533 }
534 }
535 }
536
538 "| AtlasBaseDir : {:66} |\n"
539 "| AtlasVersion : {:66} |\n"
540 "| BINARY_TAG : {:66} |\n"
541 "{}"
542 " Note: to see line numbers in below stacktrace you might consider running following :\n"
543 " atlasAddress2Line --file <logfile>",
544 horizLine,
548 horizLine);
549
550 SmartIF<IAthenaSummarySvc> iass{service("AthenaSummarySvc", false)};
551 if (iass) {
552 iass->addSummary(
"CoreDumpSvc",
os.str());
553 iass->setStatus(1);
554 iass->createSummary().ignore();
555 }
556#undef PR
557
559}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
static const char * describe(int sig, int code)
Return the description for signal info code code for signal number sig.
siginfo_t * m_siginfo
Pointer to siginfo_t struct (set by signal handler).
std::atomic< EventID::event_number_t > m_eventCounter
Event counter.
time(flags, cells_name, *args, **kw)
std::string getenv(const std::string &variableName)
get an environment variable
struct athena_statm read_athena_statm()