~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/ut/ut0dbg.cc

  • Committer: Stewart Smith
  • Date: 2008-10-15 04:21:24 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: stewart@flamingspork.com-20081015042124-kdmb74bcbky1k1nz
remove my_pthread_[gs]etspecific

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1994, 2009, Innobase Oy. 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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/*****************************************************************//**
20
 
@file ut/ut0dbg.c
21
 
Debug utilities for Innobase.
22
 
 
23
 
Created 1/30/1994 Heikki Tuuri
24
 
**********************************************************************/
25
 
 
26
 
#include "univ.i"
27
 
#include "ut0dbg.h"
28
 
 
29
 
#if defined(__GNUC__) && (__GNUC__ > 2)
30
 
#else
31
 
/** This is used to eliminate compiler warnings */
32
 
UNIV_INTERN ulint       ut_dbg_zero     = 0;
33
 
#endif
34
 
 
35
 
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
36
 
/** If this is set to TRUE by ut_dbg_assertion_failed(), all threads
37
 
will stop at the next ut_a() or ut_ad(). */
38
 
UNIV_INTERN ibool       ut_dbg_stop_threads     = FALSE;
39
 
#endif
40
 
#ifndef UT_DBG_USE_ABORT
41
 
/** A null pointer that will be dereferenced to trigger a memory trap */
42
 
UNIV_INTERN ulint*      ut_dbg_null_ptr         = NULL;
43
 
#endif
44
 
 
45
 
/*************************************************************//**
46
 
Report a failed assertion. */
47
 
#ifdef __cplusplus
48
 
extern "C"
49
 
#endif
50
 
UNIV_INTERN
51
 
void
52
 
ut_dbg_assertion_failed(
53
 
/*====================*/
54
 
        const char* expr,       /*!< in: the failed assertion (optional) */
55
 
        const char* file,       /*!< in: source file containing the assertion */
56
 
        ulint line)             /*!< in: line number of the assertion */
57
 
{
58
 
        ut_print_timestamp(stderr);
59
 
#ifdef UNIV_HOTBACKUP
60
 
        fprintf(stderr, "  InnoDB: Assertion failure in file %s line %lu\n",
61
 
                file, line);
62
 
#else /* UNIV_HOTBACKUP */
63
 
        fprintf(stderr,
64
 
                "  InnoDB: Assertion failure in thread %lu"
65
 
                " in file %s line %lu\n",
66
 
                os_thread_pf(os_thread_get_curr_id()), file, line);
67
 
#endif /* UNIV_HOTBACKUP */
68
 
        if (expr) {
69
 
                fprintf(stderr,
70
 
                        "InnoDB: Failing assertion: %s\n", expr);
71
 
        }
72
 
 
73
 
        fputs("InnoDB: We intentionally generate a memory trap.\n"
74
 
              "InnoDB: Submit a detailed bug report"
75
 
              " to http://bugs.mysql.com.\n"
76
 
              "InnoDB: If you get repeated assertion failures"
77
 
              " or crashes, even\n"
78
 
              "InnoDB: immediately after the mysqld startup, there may be\n"
79
 
              "InnoDB: corruption in the InnoDB tablespace. Please refer to\n"
80
 
              "InnoDB: " REFMAN "forcing-recovery.html\n"
81
 
              "InnoDB: about forcing recovery.\n", stderr);
82
 
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
83
 
        ut_dbg_stop_threads = TRUE;
84
 
#endif
85
 
}
86
 
 
87
 
#if defined(UNIV_SYNC_DEBUG) || !defined(UT_DBG_USE_ABORT)
88
 
/*************************************************************//**
89
 
Stop a thread after assertion failure. */
90
 
UNIV_INTERN
91
 
void
92
 
ut_dbg_stop_thread(
93
 
/*===============*/
94
 
        const char*     file,
95
 
        ulint           line)
96
 
{
97
 
#ifndef UNIV_HOTBACKUP
98
 
        fprintf(stderr, "InnoDB: Thread %lu stopped in file %s line %lu\n",
99
 
                os_thread_pf(os_thread_get_curr_id()), file, line);
100
 
        os_thread_sleep(1000000000);
101
 
#endif /* !UNIV_HOTBACKUP */
102
 
}
103
 
#endif
104
 
 
105
 
#ifdef UNIV_COMPILE_TEST_FUNCS
106
 
 
107
 
#include <sys/types.h>
108
 
#include <sys/time.h>
109
 
#include <sys/resource.h>
110
 
 
111
 
#include <unistd.h>
112
 
 
113
 
#ifndef timersub
114
 
#define timersub(a, b, r)                                               \
115
 
        do {                                                            \
116
 
                (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;                \
117
 
                (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;             \
118
 
                if ((r)->tv_usec < 0) {                                 \
119
 
                        (r)->tv_sec--;                                  \
120
 
                        (r)->tv_usec += 1000000;                        \
121
 
                }                                                       \
122
 
        } while (0)
123
 
#endif /* timersub */
124
 
 
125
 
/*******************************************************************//**
126
 
Resets a speedo (records the current time in it). */
127
 
UNIV_INTERN
128
 
void
129
 
speedo_reset(
130
 
/*=========*/
131
 
        speedo_t*       speedo) /*!< out: speedo */
132
 
{
133
 
        gettimeofday(&speedo->tv, NULL);
134
 
 
135
 
        getrusage(RUSAGE_SELF, &speedo->ru);
136
 
}
137
 
 
138
 
/*******************************************************************//**
139
 
Shows the time elapsed and usage statistics since the last reset of a
140
 
speedo. */
141
 
UNIV_INTERN
142
 
void
143
 
speedo_show(
144
 
/*========*/
145
 
        const speedo_t* speedo) /*!< in: speedo */
146
 
{
147
 
        struct rusage   ru_now;
148
 
        struct timeval  tv_now;
149
 
        struct timeval  tv_diff;
150
 
 
151
 
        getrusage(RUSAGE_SELF, &ru_now);
152
 
 
153
 
        gettimeofday(&tv_now, NULL);
154
 
 
155
 
#define PRINT_TIMEVAL(prefix, tvp)              \
156
 
        fprintf(stderr, "%s% 5ld.%06ld sec\n",  \
157
 
                prefix, (tvp)->tv_sec, (tvp)->tv_usec)
158
 
 
159
 
        timersub(&tv_now, &speedo->tv, &tv_diff);
160
 
        PRINT_TIMEVAL("real", &tv_diff);
161
 
 
162
 
        timersub(&ru_now.ru_utime, &speedo->ru.ru_utime, &tv_diff);
163
 
        PRINT_TIMEVAL("user", &tv_diff);
164
 
 
165
 
        timersub(&ru_now.ru_stime, &speedo->ru.ru_stime, &tv_diff);
166
 
        PRINT_TIMEVAL("sys ", &tv_diff);
167
 
}
168
 
 
169
 
#endif /* UNIV_COMPILE_TEST_FUNCS */