drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
ut0dbg.cc
1/*****************************************************************************
2
3Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/*****************************************************************/
25
26#include "univ.i"
27#include "ut0dbg.h"
28#include "ha_prototypes.h"
29
30#if defined(__GNUC__) && (__GNUC__ > 2)
31#else
33UNIV_INTERN ulint ut_dbg_zero = 0;
34#endif
35
36#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
39UNIV_INTERN ibool ut_dbg_stop_threads = FALSE;
40#endif
41#ifndef UT_DBG_USE_ABORT
43UNIV_INTERN ulint* ut_dbg_null_ptr = NULL;
44#endif
45
46/*************************************************************/
48#ifdef __cplusplus
49extern "C"
50#endif
51UNIV_INTERN
52void
54/*====================*/
55 const char* expr,
56 const char* file,
57 ulint line)
58{
59 ut_print_timestamp(stderr);
60#ifdef UNIV_HOTBACKUP
61 fprintf(stderr, " InnoDB: Assertion failure in file %s line %lu\n",
62 innobase_basename(file), line);
63#else /* UNIV_HOTBACKUP */
64 fprintf(stderr,
65 " InnoDB: Assertion failure in thread %lu"
66 " in file %s line %lu\n",
68 innobase_basename(file), line);
69#endif /* UNIV_HOTBACKUP */
70 if (expr) {
71 fprintf(stderr,
72 "InnoDB: Failing assertion: %s\n", expr);
73 }
74
75 fputs("InnoDB: We intentionally generate a memory trap.\n"
76 "InnoDB: Submit a detailed bug report"
77 " to http://bugs.mysql.com.\n"
78 "InnoDB: If you get repeated assertion failures"
79 " or crashes, even\n"
80 "InnoDB: immediately after the mysqld startup, there may be\n"
81 "InnoDB: corruption in the InnoDB tablespace. Please refer to\n"
82 "InnoDB: " REFMAN "forcing-innodb-recovery.html\n"
83 "InnoDB: about forcing recovery.\n", stderr);
84#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
86#endif
87}
88
89#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
90/*************************************************************/
92UNIV_INTERN
93void
95/*===============*/
96 const char* file,
97 ulint line)
98{
99#ifndef UNIV_HOTBACKUP
100 fprintf(stderr, "InnoDB: Thread %lu stopped in file %s line %lu\n",
102 innobase_basename(file), line);
103 os_thread_sleep(1000000000);
104#endif /* !UNIV_HOTBACKUP */
105}
106#endif
107
108#ifdef UNIV_COMPILE_TEST_FUNCS
109
110#include <sys/types.h>
111#include <sys/time.h>
112#include <sys/resource.h>
113
114#include <unistd.h>
115
116#ifndef timersub
117#define timersub(a, b, r) \
118 do { \
119 (r)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
120 (r)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
121 if ((r)->tv_usec < 0) { \
122 (r)->tv_sec--; \
123 (r)->tv_usec += 1000000; \
124 } \
125 } while (0)
126#endif /* timersub */
127
128/*******************************************************************/
130UNIV_INTERN
131void
132speedo_reset(
133/*=========*/
134 speedo_t* speedo)
135{
136 gettimeofday(&speedo->tv, NULL);
137
138 getrusage(RUSAGE_SELF, &speedo->ru);
139}
140
141/*******************************************************************/
144UNIV_INTERN
145void
146speedo_show(
147/*========*/
148 const speedo_t* speedo)
149{
150 struct rusage ru_now;
151 struct timeval tv_now;
152 struct timeval tv_diff;
153
154 getrusage(RUSAGE_SELF, &ru_now);
155
156 gettimeofday(&tv_now, NULL);
157
158#define PRINT_TIMEVAL(prefix, tvp) \
159 fprintf(stderr, "%s% 5ld.%06ld sec\n", \
160 prefix, (tvp)->tv_sec, (tvp)->tv_usec)
161
162 timersub(&tv_now, &speedo->tv, &tv_diff);
163 PRINT_TIMEVAL("real", &tv_diff);
164
165 timersub(&ru_now.ru_utime, &speedo->ru.ru_utime, &tv_diff);
166 PRINT_TIMEVAL("user", &tv_diff);
167
168 timersub(&ru_now.ru_stime, &speedo->ru.ru_stime, &tv_diff);
169 PRINT_TIMEVAL("sys ", &tv_diff);
170}
171
172#endif /* UNIV_COMPILE_TEST_FUNCS */
const char * innobase_basename(const char *path_name)
UNIV_INTERN void os_thread_sleep(ulint tm)
Definition os0thread.cc:265
UNIV_INTERN os_thread_id_t os_thread_get_curr_id(void)
Definition os0thread.cc:93
UNIV_INTERN ulint os_thread_pf(os_thread_id_t a)
Definition os0thread.cc:72
ulint * ut_dbg_null_ptr
Definition ut0dbg.cc:43
UNIV_INTERN void ut_dbg_stop_thread(const char *file, ulint line)
Definition ut0dbg.cc:94
ulint ut_dbg_zero
Definition ut0dbg.cc:33
ibool ut_dbg_stop_threads
Definition ut0dbg.cc:39
UNIV_INTERN void ut_dbg_assertion_failed(const char *expr, const char *file, ulint line)
Definition ut0dbg.cc:53
UNIV_INTERN void ut_print_timestamp(FILE *file)
Definition ut0ut.cc:239