LCOV - code coverage report
Current view: top level - src/backend/utils/error - assert.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 0 10 0.0 %
Date: 2019-11-13 21:06:57 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * assert.c
       4             :  *    Assert code.
       5             :  *
       6             :  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  *
      10             :  * IDENTIFICATION
      11             :  *    src/backend/utils/error/assert.c
      12             :  *
      13             :  * NOTE
      14             :  *    This should eventually work with elog()
      15             :  *
      16             :  *-------------------------------------------------------------------------
      17             :  */
      18             : #include "postgres.h"
      19             : 
      20             : #include <unistd.h>
      21             : #ifdef HAVE_EXECINFO_H
      22             : #include <execinfo.h>
      23             : #endif
      24             : 
      25             : /*
      26             :  * ExceptionalCondition - Handles the failure of an Assert()
      27             :  */
      28             : void
      29           0 : ExceptionalCondition(const char *conditionName,
      30             :                      const char *errorType,
      31             :                      const char *fileName,
      32             :                      int lineNumber)
      33             : {
      34           0 :     if (!PointerIsValid(conditionName)
      35           0 :         || !PointerIsValid(fileName)
      36           0 :         || !PointerIsValid(errorType))
      37           0 :         write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
      38             :     else
      39             :     {
      40           0 :         write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
      41             :                      errorType, conditionName,
      42             :                      fileName, lineNumber);
      43             :     }
      44             : 
      45             :     /* Usually this shouldn't be needed, but make sure the msg went out */
      46           0 :     fflush(stderr);
      47             : 
      48             : #ifdef HAVE_BACKTRACE_SYMBOLS
      49             :     {
      50             :         void       *buf[100];
      51             :         int         nframes;
      52             : 
      53           0 :         nframes = backtrace(buf, lengthof(buf));
      54           0 :         backtrace_symbols_fd(buf, nframes, fileno(stderr));
      55             :     }
      56             : #endif
      57             : 
      58             : #ifdef SLEEP_ON_ASSERT
      59             : 
      60             :     /*
      61             :      * It would be nice to use pg_usleep() here, but only does 2000 sec or 33
      62             :      * minutes, which seems too short.
      63             :      */
      64             :     sleep(1000000);
      65             : #endif
      66             : 
      67           0 :     abort();
      68             : }

Generated by: LCOV version 1.13