MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ut0dbg.cc
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1994, 2009, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along with
14 this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /*****************************************************************/
26 #include "univ.i"
27 #include "ut0dbg.h"
28 #ifndef UNIV_HOTBACKUP
29 # include "ha_prototypes.h"
30 #endif /* !UNIV_HOTBACKUP */
31 
32 #if defined(__GNUC__) && (__GNUC__ > 2)
33 #else
34 
35 UNIV_INTERN ulint ut_dbg_zero = 0;
36 #endif
37 
38 /*************************************************************/
40 UNIV_INTERN
41 void
43 /*====================*/
44  const char* expr,
45  const char* file,
46  ulint line)
47 {
48  ut_print_timestamp(stderr);
49 #ifdef UNIV_HOTBACKUP
50  fprintf(stderr, " InnoDB: Assertion failure in file %s line %lu\n",
51  file, line);
52 #else /* UNIV_HOTBACKUP */
53  fprintf(stderr,
54  " InnoDB: Assertion failure in thread %lu"
55  " in file %s line %lu\n",
57  innobase_basename(file), line);
58 #endif /* UNIV_HOTBACKUP */
59  if (expr) {
60  fprintf(stderr,
61  "InnoDB: Failing assertion: %s\n", expr);
62  }
63 
64  fputs("InnoDB: We intentionally generate a memory trap.\n"
65  "InnoDB: Submit a detailed bug report"
66  " to http://bugs.mysql.com.\n"
67  "InnoDB: If you get repeated assertion failures"
68  " or crashes, even\n"
69  "InnoDB: immediately after the mysqld startup, there may be\n"
70  "InnoDB: corruption in the InnoDB tablespace. Please refer to\n"
71  "InnoDB: " REFMAN "forcing-innodb-recovery.html\n"
72  "InnoDB: about forcing recovery.\n", stderr);
73 }
74 
75 #ifdef UNIV_COMPILE_TEST_FUNCS
76 
77 #include <sys/types.h>
78 #include <sys/time.h>
79 #include <sys/resource.h>
80 
81 #include <unistd.h>
82 
83 #ifndef timersub
84 #define timersub(a, b, r) \
85  do { \
86  (r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
87  (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
88  if ((r)->tv_usec < 0) { \
89  (r)->tv_sec--; \
90  (r)->tv_usec += 1000000; \
91  } \
92  } while (0)
93 #endif /* timersub */
94 
95 /*******************************************************************/
97 UNIV_INTERN
98 void
99 speedo_reset(
100 /*=========*/
101  speedo_t* speedo)
102 {
103  gettimeofday(&speedo->tv, NULL);
104 
105  getrusage(RUSAGE_SELF, &speedo->ru);
106 }
107 
108 /*******************************************************************/
111 UNIV_INTERN
112 void
113 speedo_show(
114 /*========*/
115  const speedo_t* speedo)
116 {
117  struct rusage ru_now;
118  struct timeval tv_now;
119  struct timeval tv_diff;
120 
121  getrusage(RUSAGE_SELF, &ru_now);
122 
123  gettimeofday(&tv_now, NULL);
124 
125 #define PRINT_TIMEVAL(prefix, tvp) \
126  fprintf(stderr, "%s% 5ld.%06ld sec\n", \
127  prefix, (tvp)->tv_sec, (tvp)->tv_usec)
128 
129  timersub(&tv_now, &speedo->tv, &tv_diff);
130  PRINT_TIMEVAL("real", &tv_diff);
131 
132  timersub(&ru_now.ru_utime, &speedo->ru.ru_utime, &tv_diff);
133  PRINT_TIMEVAL("user", &tv_diff);
134 
135  timersub(&ru_now.ru_stime, &speedo->ru.ru_stime, &tv_diff);
136  PRINT_TIMEVAL("sys ", &tv_diff);
137 }
138 
139 #endif /* UNIV_COMPILE_TEST_FUNCS */