Print all core dump records.
394{
395 std::ostringstream
os;
397 const time_t
now =
time(
nullptr);
398
399 os <<
"-------------------------------------------------------------------------------------" <<
"\n";
400 os <<
"Core dump from " <<
name() <<
" on " << System::hostName()
401 << " at " << ctime_r(&now, buf) ;
403
404
407
408 os <<
"Caught signal " << signo
409 << "(" << strsignal(signo) << "). Details: "
410 << "\n";
411
415 << "\n";
416
419 << "\n";
420
421#ifndef __APPLE__
422
424 << std::hex <<
m_siginfo->si_ptr <<
")" << std::dec <<
"\n";
425#endif
426
427
429
430 const long pagesz = sysconf(_SC_PAGESIZE);
431 os <<
" vmem = " <<
s.vm_pages*pagesz/1024./1024. <<
" MB\n"
432 <<
" rss = " <<
s.rss_pages*pagesz/1024./1024. <<
" MB\n";
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 os <<
" total-ram = " <<
sys.totalram * mem_units <<
" MB\n"
444 <<
" free-ram = " <<
sys.freeram * mem_units <<
" MB\n"
445 <<
" buffer-ram= " <<
sys.bufferram* mem_units <<
" MB\n"
446 <<
" total-swap= " <<
sys.totalswap* mem_units <<
" MB\n"
447 <<
" free-swap = " <<
sys.freeswap * mem_units <<
" MB\n";
448 }
449 }
450#endif
451
452
453 if (signo == SIGILL || signo == SIGFPE || signo == SIGSEGV || signo == SIGBUS)
454 os <<
" addr = " << std::hex <<
m_siginfo->si_addr << std::dec <<
"\n";
455
457 }
458
460
461 SmartIF<IAlgManager> algMgr{serviceLocator()->as<IAlgManager>()};
462 SmartIF<IAlgContextSvc> algContextSvc;
463
464
465
466 if (Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() == 0) {
467 algContextSvc = service("AlgContextSvc", false);
468 }
469
470
472
473
474 std::string currentAlg;
475
476
477 if (Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 0) {
478 const EventContext ctx(0,t);
479 ATH_MSG_DEBUG(
"Using AlgExecStateSvc to determine current algorithm(s)");
480 try {
481 for (const IAlgorithm* alg : algMgr->getAlgorithms()) {
482 auto aes =
alg->execState(ctx);
483 if (aes.state()==AlgExecState::State::Executing)
484 currentAlg += (
alg->name() +
" ");
485 }
486 }
487 catch (const GaudiException&) {
488 ATH_MSG_INFO(
"No information from AlgExecStateSvc because no algorithm was executed yet.");
489 }
490 }
491 else if (algContextSvc) {
492 ATH_MSG_DEBUG(
"Using AlgContextSvc to determine current algorithm");
493 IAlgorithm*
alg = algContextSvc->currentAlg();
494 if (alg) currentAlg =
alg->name();
495 }
496 else {
497 ATH_MSG_WARNING(
"AlgExecStateSvc or AlgContextSvc not available. Cannot determine current algorithm.");
498 }
499
500 if (currentAlg.empty()) currentAlg = "<NONE>";
501 os <<
"Slot " << std::setw(3) <<
t <<
" : Current algorithm = " << currentAlg << std::endl;
502
503
505 if (!
sys.LastInc.empty()) {
506 os <<
" : Last Incident = " <<
sys.LastInc << std::endl
507 <<
" : Event ID = " <<
sys.EvId << std::endl;
508 }
509
510
512 if (!usr.empty()) {
513 for (auto &s : usr) {
514 os <<
" : (usr) " <<
s.first <<
" = " <<
s.second << std::endl;
515 }
516 }
517 }
518
519 if (algContextSvc) {
520 os <<
"Algorithm stack: ";
521 if ( algContextSvc->algorithms().empty() )
os <<
"<EMPTY>" <<
"\n";
522 else {
524 for (auto alg : algContextSvc->algorithms()) {
525 if (alg)
os <<
" " <<
alg->name() <<
"\n";
526 }
527 }
528 }
529
531 os <<
"| AtlasBaseDir : " << std::setw(66) <<
getenv(
"AtlasBaseDir") <<
" |\n";
532 os <<
"| AtlasVersion : " << std::setw(66) <<
getenv(
"AtlasVersion") <<
" |\n";
533 os <<
"| BINARY_TAG : " << std::setw(66) <<
getenv(
"BINARY_TAG") <<
" |\n";
535 os <<
" Note: to see line numbers in below stacktrace you might consider running following :\n";
536 os <<
" atlasAddress2Line --file <logfile>\n";
537
538 SmartIF<IAthenaSummarySvc> iass{service("AthenaSummarySvc", false)};
539 if (iass) {
540 iass->addSummary(
"CoreDumpSvc",
os.str());
541 iass->setStatus(1);
542 iass->createSummary().ignore();
543 }
544
546}
#define ATH_MSG_WARNING(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()