ATLAS Offline Software
SealDebug.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
21 #ifndef CXXUTILS_SEAL_DEBUG_H // wlav SEAL_BASE_DEBUG_H
22 #define CXXUTILS_SEAL_DEBUG_H // wlav SEAL_BASE_DEBUG_H
23 
25 #include "CxxUtils/SealCommon.h" // sss -- needed for IOFD
26 # include <cstddef>
27 # include <atomic>
28 
29 // wlav copied from SealBase/sysapi/DebugAids.h
30 // Windows doesn't have this, so fake a suitable substitute
31 # ifdef _WIN32
32 # define STDERR_HANDLE GetStdHandle (STD_ERROR_HANDLE)
33 # else
34 # define STDERR_HANDLE STDERR_FILENO
35 # endif
36 
37 // Define a suitable wrapper to write to system file descriptors.
38 // This is needed because on Windows we are using HANDLEs, not the
39 // compiler's crippled posixy interface.
40 # ifdef _WIN32
41 # define MYWRITE(fd,data,n) do { DWORD written; WriteFile(fd,data,n,\
42  &written,0); } while (0)
43 # else
44 # define MYWRITE(fd,data,n) write(fd,data,n)
45 # endif
46 
47 
48 namespace Athena { // wlav
49 
50 
51 // wlav copied from SealBase/BitTraits.h
53 template <class T>
54 struct BitTraits
55 {
57  enum { Bits = sizeof (T) * CHAR_BIT };
58 
60  enum { Bytes = Bits / 8 + ((Bits % 8) > 0) };
61 
63  enum { Digits = (Bits * 30103) / 100000 + 1 };
64  // 30103 =~ M_LN2 / M_LN10 * 100000
65 
67  enum { HexDigits = Bits / 4 + ((Bits % 4) > 0) };
68 };
69 
70 
72 class DebugAids
73 {
74 public:
75  // Miscellaneous functions
77  static void stacktrace ATLAS_NOT_THREAD_SAFE (IOFD fd = IOFD_INVALID);
78  static void coredump (int sig, ...);
79  // sss
80  static void stacktraceLine ATLAS_NOT_THREAD_SAFE (IOFD fd,
81  unsigned long addr);
82  static void setStackTraceAddr2Line ATLAS_NOT_THREAD_SAFE (const char* path);
83 
84  // fwinkl
85  static unsigned long enableCoreFiles();
86  static void disableCoreFiles();
87 private:
88  static std::atomic<IOFD> s_stackTraceFd;
89 };
90 
91 
92 } // namespace Athena wlav
93 #endif // CXXUTILS_SEAL_DEBUG_H wlav SEAL_BASE_DEBUG_H
Athena::DebugAids::ATLAS_NOT_THREAD_SAFE
static void stacktrace ATLAS_NOT_THREAD_SAFE(IOFD fd=IOFD_INVALID)
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
Athena::DebugAids::coredump
static void coredump(int sig,...)
Drop a core dump and continue.
Definition: SealDebug.cxx:971
Athena::BitTraits::Digits
@ Digits
Definition: SealDebug.h:63
Athena::BitTraits::Bytes
@ Bytes
Definition: SealDebug.h:60
SealCommon.h
Collecting a few shared bits and pieces from SEAL headers.
Athena::BitTraits::HexDigits
@ HexDigits
Definition: SealDebug.h:67
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
IOFD
int IOFD
Type the system uses for channel descriptors.
Definition: SealCommon.h:27
Athena::DebugAids::ATLAS_NOT_THREAD_SAFE
static void stacktraceLine ATLAS_NOT_THREAD_SAFE(IOFD fd, unsigned long addr)
python.BuildSignatureFlags.sig
sig
Definition: BuildSignatureFlags.py:215
Athena::DebugAids::ATLAS_NOT_THREAD_SAFE
static void setStackTraceAddr2Line ATLAS_NOT_THREAD_SAFE(const char *path)
Athena::DebugAids::stacktraceFd
static IOFD stacktraceFd(IOFD fd=IOFD_INVALID)
Set and return the file descriptor for stack trace output.
Definition: SealDebug.cxx:604
ReadFromCoolCompare.fd
fd
Definition: ReadFromCoolCompare.py:196
Athena::BitTraits
Describe the bit features of an integral type T.
Definition: SealDebug.h:55
IOFD_INVALID
#define IOFD_INVALID
Invalid channel descriptor constant.
Definition: SealCommon.h:20
Athena::DebugAids::enableCoreFiles
static unsigned long enableCoreFiles()
Try to enable core dump files by raising the soft size limit to the hard limit.
Definition: SealDebug.cxx:1027
Athena::BitTraits::Bits
@ Bits
Definition: SealDebug.h:57
checker_macros.h
Define macros for attributes used to control the static checker.
Athena::DebugAids::disableCoreFiles
static void disableCoreFiles()
Disable core dump files by setting the soft limit to 0.
Definition: SealDebug.cxx:1047
Athena::DebugAids::s_stackTraceFd
static std::atomic< IOFD > s_stackTraceFd
The default output file descriptor for #stacktrace().
Definition: SealDebug.h:88
Athena::DebugAids
Utilities for debugging support.
Definition: SealDebug.h:73