00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #include "univ.i"
00027 #include "ut0dbg.h"
00028
00029 #if defined(__GNUC__) && (__GNUC__ > 2)
00030 #else
00031
00032 UNIV_INTERN ulint ut_dbg_zero = 0;
00033 #endif
00034
00035 #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
00036
00038 UNIV_INTERN ibool ut_dbg_stop_threads = FALSE;
00039 #endif
00040 #ifndef UT_DBG_USE_ABORT
00041
00042 UNIV_INTERN ulint* ut_dbg_null_ptr = NULL;
00043 #endif
00044
00045
00047 #ifdef __cplusplus
00048 extern "C"
00049 #endif
00050 UNIV_INTERN
00051 void
00052 ut_dbg_assertion_failed(
00053
00054 const char* expr,
00055 const char* file,
00056 ulint line)
00057 {
00058 ut_print_timestamp(stderr);
00059 #ifdef UNIV_HOTBACKUP
00060 fprintf(stderr, " InnoDB: Assertion failure in file %s line %lu\n",
00061 file, line);
00062 #else
00063 fprintf(stderr,
00064 " InnoDB: Assertion failure in thread %lu"
00065 " in file %s line %lu\n",
00066 os_thread_pf(os_thread_get_curr_id()), file, line);
00067 #endif
00068 if (expr) {
00069 fprintf(stderr,
00070 "InnoDB: Failing assertion: %s\n", expr);
00071 }
00072
00073 fputs("InnoDB: We intentionally generate a memory trap.\n"
00074 "InnoDB: Submit a detailed bug report"
00075 " to http://bugs.mysql.com.\n"
00076 "InnoDB: If you get repeated assertion failures"
00077 " or crashes, even\n"
00078 "InnoDB: immediately after the mysqld startup, there may be\n"
00079 "InnoDB: corruption in the InnoDB tablespace. Please refer to\n"
00080 "InnoDB: " REFMAN "forcing-recovery.html\n"
00081 "InnoDB: about forcing recovery.\n", stderr);
00082 #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
00083 ut_dbg_stop_threads = TRUE;
00084 #endif
00085 }
00086
00087 #if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
00088
00090 UNIV_INTERN
00091 void
00092 ut_dbg_stop_thread(
00093
00094 const char* file,
00095 ulint line)
00096 {
00097 #ifndef UNIV_HOTBACKUP
00098 fprintf(stderr, "InnoDB: Thread %lu stopped in file %s line %lu\n",
00099 os_thread_pf(os_thread_get_curr_id()), file, line);
00100 os_thread_sleep(1000000000);
00101 #endif
00102 }
00103 #endif
00104
00105 #ifdef UNIV_COMPILE_TEST_FUNCS
00106
00107 #include <sys/types.h>
00108 #include <sys/time.h>
00109 #include <sys/resource.h>
00110
00111 #include <unistd.h>
00112
00113 #ifndef timersub
00114 #define timersub(a, b, r) \
00115 do { \
00116 (r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
00117 (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
00118 if ((r)->tv_usec < 0) { \
00119 (r)->tv_sec--; \
00120 (r)->tv_usec += 1000000; \
00121 } \
00122 } while (0)
00123 #endif
00124
00125
00127 UNIV_INTERN
00128 void
00129 speedo_reset(
00130
00131 speedo_t* speedo)
00132 {
00133 gettimeofday(&speedo->tv, NULL);
00134
00135 getrusage(RUSAGE_SELF, &speedo->ru);
00136 }
00137
00138
00141 UNIV_INTERN
00142 void
00143 speedo_show(
00144
00145 const speedo_t* speedo)
00146 {
00147 struct rusage ru_now;
00148 struct timeval tv_now;
00149 struct timeval tv_diff;
00150
00151 getrusage(RUSAGE_SELF, &ru_now);
00152
00153 gettimeofday(&tv_now, NULL);
00154
00155 #define PRINT_TIMEVAL(prefix, tvp) \
00156 fprintf(stderr, "%s% 5ld.%06ld sec\n", \
00157 prefix, (tvp)->tv_sec, (tvp)->tv_usec)
00158
00159 timersub(&tv_now, &speedo->tv, &tv_diff);
00160 PRINT_TIMEVAL("real", &tv_diff);
00161
00162 timersub(&ru_now.ru_utime, &speedo->ru.ru_utime, &tv_diff);
00163 PRINT_TIMEVAL("user", &tv_diff);
00164
00165 timersub(&ru_now.ru_stime, &speedo->ru.ru_stime, &tv_diff);
00166 PRINT_TIMEVAL("sys ", &tv_diff);
00167 }
00168
00169 #endif